مزامنة كاملة للمجلدات وجهات الاتصال والتقاويم المشتركة بين خوادم Kerio Connect الموزعة

مساء الخير يا هبر!



مهمة



في مؤسستي ، يتم استخدام خادم البريد على نظام Kerio Connect الأساسي ؛ يتم تثبيت خوادم البريد التي تخدم مستخدميها في مدن مختلفة. في البداية ، لم يكن هناك هيكل موزع ، حيث تختلف المجالات في المستوى الثالث ، مما يشير إلى مدينة الموقع. كل شيء يعمل وكان الجميع سعداء. يوم واحد جيد - حددت الإدارة مهمة ، تقويمًا مشتركًا للشؤون بين جميع المواقع!



خلفية



في البداية ، كانت الفكرة هي رفع نطاق بريد كيريو الموزع وسوف يفعل كل شيء بنفسه. قيل ، تم إنشاء المجال الموزع ، لكنه لم يكن موجودًا ، كان الخادم جاهزًا لمزامنة التقاويم والمجلدات وجهات الاتصال - بين المجالات الموجودة على نفس الخادم ، ولكن لم يكن على الإطلاق يقوم بمزامنة البيانات بين عدة خوادم.



بالطبع ، لم أكن أتوقع مثل هذه الخدعة ولم أكن أؤمن لفترة طويلة بغياب الوظيفة التي أحتاجها. في وقت لاحق وجدت تأكيدًا وثائقيًا لهذه الحقيقة. مما كنت في حيرة وخيبة أمل كثيرا.



تحولت المهمة بسلاسة إلى مشكلة.



ما هي الخيارات



  • قم بإنشاء عميلين على خوادم مختلفة ، والتي تبادلت البيانات اللازمة مع بعض برامج الجهات الخارجية. كان من الضروري العثور على برنامج تابع لجهة خارجية من شأنه تنفيذ هذه الوظيفة - لا أحب هذا أشعل النار ، ولكن يبدو أن هذا كان الحل السريع الوحيد.
  • . , Kerio , , - , , - .


, Kerio , , — .



, “ ”, 6 :



  • – .
  • — .


, – DFS







  • , OS Windows. ( Linux. OS)
  • , — .
  • DFS .
  • Kerio, , , Kerio . ( )
  • DFS.
  • - ( )




( )



1. Kerio Distributed domain





Master , .



, Kerio , ,



:







, 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"، {}، token)



يتم إعطاء مثال على التنفيذ في - 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 - يجب أن تثق بيثون في شهادة كيريو.



أيضًا في الملف ، يجب تحديد حساب له حقوق أداء هذه الوظيفة (المشرف - مجلدات البريد المشتركة) لخادم البريد.



آمل أن تكون مقالتي مفيدة لمسؤولي كيريو كونيكت.




All Articles