下午好,哈伯!
一个任务
在我的组织中,Kerio Connect平台上使用了邮件服务器;为用户提供服务的邮件服务器安装在不同的城市。最初没有分布式结构,因为域在第三级上有所不同,表示站点所在的城市。一切正常,每个人都很高兴。美好的一天-管理层设定了任务,所有站点之间的事务日历相同!
背景
最初的想法是提高Distributed Kerio邮件域,他将自己做所有事情。据说已经创建了分布式域,但是它不存在,服务器已准备好在同一服务器上的域之间同步日历,文件夹,联系人,但根本不打算在多个服务器之间同步数据。
当然,我没想到会有这样的花招,而且很长一段时间都不敢相信我缺少所需的功能。后来我发现这个事实的书面证明。比起我,我感到非常困惑和失望。
任务顺利地变成了问题。
有哪些选择
- 在不同的服务器上创建两个客户端,这些服务器与某些第三方软件交换了必要的数据。有必要找到可以实现此功能的非常第三方软件-我不喜欢这样,但看来这是唯一快速的解决方案。
- . , Kerio , , - , , - .
, Kerio , , — .
, “ ”, 6 :
- – .
- — .
, – DFS
- , OS Windows. ( Linux. OS)
- , — .
- DFS .
- Kerio, , , Kerio . ( )
- DFS.
- - ( )
( )
1. Kerio Distributed domain
Master , .
:
, Master :
—
— .
! , ( — )
— , .
— ( ) .
2. Kerio
, . , , .
– , , , - , .
.
~DataMail\mail\#public\ \#msgs
~DataMail\mail\**Domain**\#public\ \#msgs
, , #msgs — , .
3. DFS
DFS, , .
DFS — Windows Server, ,
MS DFS
DFS – .
.
( — ) .
.
4.
(DFS), — - - , - .
, , . 6 – 12 .
, - , DFS, - , #msgs , .
Kerio , , 6 .
, index.fld, Kerio . , , , , , Kerio - index.fld
— - - .
, - — , , , .
?
.
, —
. , - #msgs, , . .
, , (15 ) 3-4 .
, , .
Kerio API
, , –
session = callMethod("Domains.checkPublicFoldersIntegrity",{}, token)
, , - , .
, , , .
CMD
Re-index.bat
@echo off
set dir=%~dp0
%dir:~0,2%
CD "%~dp0\"
md "%CD%\LOG\"
md "%CD%\Setup\"
ECHO -Start- >> "%CD%\LOG\%Computername%.log"
ECHO Start -> %Computername% %Date% %Time% >> "%CD%\LOG\%Computername%.log"
SetLocal EnableDelayedExpansion
for /f "UseBackQ Delims=" %%A IN ("%CD%\Setup\%Computername%.List") do (
set /a c+=1
set "m!c!=%%A"
)
set d=%c%
Echo Folder = %c%
ECHO Folder = %c% >> "%CD%\LOG\%Computername%.log"
ECHO.
ECHO. >> "%CD%\LOG\%Computername%.log"
:start
cls
if %c% LSS 1 exit
set /a id=1
set R=0
:Find
REM PF-Start
if "%id%" gtr "%c%" if %R% == 1 Goto Reindex
if "%id%" gtr "%c%" timeout 60 && Goto start
For /F "tokens=1-3" %%a IN ('Dir "!m%id%!\#msgs\" /-C/S/A:-D') Do Set 2DirSize!id!=!DS!& Set DS=%%c
if "2DirSize!id!" == "" set 1DirSize!id!=!2DirSize%id%!
echo %id%
ECHO !m%id%!
echo Count [ !1DirSize%id%! -- !2DirSize%id%! ]
if "!1DirSize%id%!" == "!2DirSize%id%!" ECHO Synk
REM DEL index.fld
if "!1DirSize%id%!" NEQ "!2DirSize%id%!" del /f /q !m%id%!\index.fld && del /f /q !m%id%!\indexlog.fld && del /f /q !m%id%!\search.fld && set R=1 && ECHO RE-index Count && ECHO RE-index Count %Date% %Time% - Delete !m%id%! >> "%CD%\LOG\%Computername%.log"
set 1DirSize!id!=!2DirSize%id%!
ECHO.
ECHO.
set /a id+=1
goto Find
:Reindex
ECHO. >> "%CD%\LOG\%Computername%.log"
ECHO --- RE-INDEX - Start - %Date% %Time% --- >> "%CD%\LOG\%Computername%.log"
ECHO. >> ----------------------------------- >> "%CD%\LOG\%Computername%.log"
call PublicFolders.py
timeout 60
goto start
exit
( , )
\Setup\%Computername%.List
%Computername% — ( .)
%Computername%.List – , , .
, , .
.
, , , : index.fld, indexlog.fld, search.fld
— .
LOG .
索引
编制过程索引编制过程简化为API函数Kerio
Session = callMethod(“ Domains.checkPublicFoldersIntegrity”,{},令牌)的执行
在python PublicFolders.py中给出了执行的示例
import json
import urllib.request
import http.cookiejar
""" Cookie storage is necessary for session handling """
jar = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
urllib.request.install_opener(opener)
""" Hostname or ip address of your Kerio Control instance with protocol, port and credentials """
server = "http://127.0.0.1:4040"
username = "user"
password = "password"
def callMethod(method, params, token = None):
"""
Remotely calls given method with given params.
:param: method string with fully qualified method name
:param: params dict with parameters of remotely called method
:param: token CSRF token is always required except login method. Use method "Session.login" to obtain this token.
"""
data = {"method": method ,"id":1, "jsonrpc":"2.0", "params": params}
req = urllib.request.Request(url = server + '/admin/api/jsonrpc/')
req.add_header('Content-Type', 'application/json')
if (token is not None):
req.add_header('X-Token', token)
httpResponse = urllib.request.urlopen(req, json.dumps(data).encode())
if (httpResponse.status == 200):
body = httpResponse.read().decode()
return json.loads(body)
session = callMethod("Session.login", {"userName":username, "password":password, "application":{"vendor":"Kerio", "name":"Control Api-Local", "version":"Python"}})
token = session["result"]["token"]
print (session)
session = callMethod("Domains.checkPublicFoldersIntegrity",{"domainId": "test2.local"}, token)
print (session)
callMethod("Session.logout",{}, token)
http://127.0.0.1:4040可以保留不变,但是,如果您需要HTTPS,则python必须信任Kerio证书。
另外,在文件中,您还必须指定一个具有执行邮件服务器此功能的权限的帐户(“管理员”-共享邮件文件夹)。
我希望我的文章对Kerio Connect管理员有用。