{"id":301281,"date":"2020-04-04T15:00:15","date_gmt":"2020-04-04T15:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301281"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301281","title":{"rendered":"\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 Zimbra Collaboration OSE \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Active Directory"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/495688\/\">\n<h2>1. \u041f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440 zimbra \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435 \u0432 Active Directory (AD). \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 AD, \u0442\u043e \u043e\u043d \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0441\u044f, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435, \u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0410 \u0432\u043e\u0442 \u043f\u043e\u0442\u043e\u043c, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 zimbra.<\/p>\n<p>  \u0427\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 powershell (\u0437\u0430\u0447\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c ldapsearch) \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u044b zmprov, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0438\u0434\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>2. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>  \u041e\u0421 \u0441\u0435\u0440\u0432\u0435\u0440\u0430: CentOS 7<br \/>  \u042f\u0437\u044b\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430: bash<br \/>  \u0414\u043e\u043c\u0435\u043d Zimbra: test.ru<br \/>  \u0421\u0435\u0440\u0432\u0435\u0440 Zimbra: zimbra.test.local<br \/>  \u0414\u043e\u043c\u0435\u043d Active Directory: test.local<br \/>  \u0413\u0440\u0443\u043f\u043f\u0430 AD \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u043e\u0447\u0442\u0435: mail <\/p>\n<p>  \u0423 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0447\u0442\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0430\u044f\u0441\u044f \u043e\u0442 \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043d\u0430, \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0447\u0442\u0443 \u0432\u043d\u043e\u0441\u0438\u043c \u0432 AD \u0432 \u043f\u043e\u043b\u0435 mail \u0438 \u043f\u043e \u043d\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u043b\u0438\u0430\u0441 \u0432 zimbra (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0430\u0441\u044f \u043f\u0443\u043f\u043a\u0438\u043d \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u043e\u0434 \u043b\u043e\u0433\u0438\u043d\u043e\u043c vasia, \u043d\u043e \u043f\u043e\u0447\u0442\u0443 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0435\u0449\u0435 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c v.pupkin@test.ru)<\/p>\n<h2>3. \u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 AD \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 mail<\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 zimbra \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438<\/li>\n<li>\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 zimbra \u043d\u0430 \u0444\u0430\u0439\u043b\u044b \u0444\u043e\u0440\u043c\u0430\u0442\u0430: \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u2014 \u043b\u043e\u0433\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/li>\n<li>\u0423\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 zimbra \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 (admin, gal,antivirus)<\/li>\n<li>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 AD \u0438 zimbra<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f (\u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f), \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043b\u0438\u0430\u0441\u043e\u0432<\/li>\n<li>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 zimbra (\u043e\u0434\u0438\u043d \u0432\u044b\u0437\u043e\u0432 zmprov)<\/li>\n<li>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0447\u0435\u0442 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 (\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0447\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c)<\/li>\n<li>\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438<\/li>\n<\/ol>\n<p>  <\/p>\n<h2>4. \u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438<\/h2>\n<p>  \u0423 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u2014 \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u043e\u0433\u0434\u0430 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0418 \u0437\u0430\u043f\u0443\u0441\u043a \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u00aball\u00bb, \u0442\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u044b mail \u0432 AD. <\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f base64 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 AD \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0443\u0441\u0441\u043a\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash # #1. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 # #1.1 \u041e\u0431\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 #\u041f\u0443\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443 path=&quot;\/mnt\/zimbra\/user-sync&quot; #\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u043a\u0430 timestamp=`date +%F-%H-%M` #\u043f\u0443\u0442\u044c \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c tmp_dir=$path\/tmp #\u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0430\u043c \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 zimbra zim_us=$tmp_dir\/zim-us #\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0430\u043c \u043b\u043e\u0433\u043e\u0432 log_dir=$path\/log #\u0438\u043c\u044f \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 log=$log_dir\/grouplog_$timestamp.txt #\u043f\u0443\u0442\u044c \u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 usname=$tmp_dir\/usname #\u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 zmprov zmcmdfile=$tmp_dir\/zmcmdfile #\u043f\u0443\u0442\u044c \u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 AD  userfil=$tmp_dir\/userfil #\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e\u0447\u0442\u044b mutt=&quot;\/usr\/bin\/mutt&quot;  # #1.2 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 zimbra #\u0438\u043c\u044f \u0434\u043e\u043c\u0435\u043d\u0430 Zimbra domain=&quot;test.ru&quot; #\u043f\u0443\u0442\u044c \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u043b\u0435\u0442\u0443 zmprov zmprov=&quot;\/opt\/zimbra\/bin\/zmprov&quot; # #1.3 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a AD \u043f\u043e LDAP #LDAP search ldapsearch=\/opt\/zimbra\/common\/bin\/ldapsearch # \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 (\u043b\u0438\u0431\u043e \u0441\u0435\u0440\u0432\u0435\u0440, \u043b\u0438\u0431\u043e \u0434\u043e\u043c\u0435\u043d (\u0435\u0441\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430)) ldap_server=&quot;ldap:\/\/test.local:389&quot; #\u0411\u0430\u0437\u043e\u0432\u0430\u044f OU \u043f\u043e\u0438\u0441\u043a\u0430 basedn=&quot;DC=test,DC=local&quot; #\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a AD \u043f\u043e LDAP binddn=&quot;CN=zimbra,CN=Users,DC=test,DC=local&quot; bindpw=&quot;qwe123&quot; #user password  #\u0424\u0438\u043b\u044c\u0442\u0440 \u043f\u043e\u0438\u0441\u043a\u0430 - \u043a\u0442\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 mail filter=&quot;(memberof=cn=mail,cn=users,dc=test,dc=local)&quot; #\u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0449\u0435\u043c (\u043b\u043e\u0433\u0438\u043d, \u043f\u043e\u0447\u0442\u0443 \u0438 \u043f\u043e\u043b\u0435 \u0441 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0439 \u0441 \u043b\u043e\u0433\u0438\u043d\u043e\u043c \u043f\u043e\u0447\u0442\u043e\u0439 \u0434\u043b\u044f \u0430\u043b\u0438\u0430\u0441\u0430 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438) fields=&quot;sAMAccountName mail description displayName givenName cn sn department title&quot; #\u043a\u043e\u043d\u0435\u0446 \u0431\u043b\u043e\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445  #\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443  #\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 #\u0417\u0430\u043f\u0438\u0441\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043b\u043e\u0433 function err_log() { if [ $1 -eq 0 ]; then \t\t#echo -n &quot;$(tput hpa $(tput cols))$(tput cub 6)[OK]&quot; \t\t#echo \t\techo $2&quot; [Ok]&quot;  &gt;&gt; $log \telse \t\t#echo -n &quot;$(tput hpa $(tput cols))$(tput cub 6) [FAIL]&quot; \t\t#echo \t\techo  $2&quot; [Fail]&quot; &gt;&gt; $log \tfi }  #\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 function if_path () { \t#\u0415\u0441\u043b\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0433\u043e \tif [ ! -d $1 ]; then \t#\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \techo &quot;\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 $1...&quot; &gt;&gt; $log \tmkdir -p $1 \terr_log $? &quot;\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 $1&quot; \t else \techo &quot;\u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 $1 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442&quot; &gt;&gt; $log\t fi }  #\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 AD function searchusersAD() { \techo &quot;\u0417\u0430\u043f\u0438\u0441\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u0438\u0437 AD...&quot; &gt;&gt; $log \t$ldapsearch -x -o ldif-wrap=no -H $ldap_server -D $binddn -w $bindpw -b $basedn $filter $fields |  \tgrep sAMAccountName |  \tegrep -v '^#|^$' |  \tawk '{print $2}' | \tsort &gt; $usname.ad \techo &quot;Found (\u041d\u0430\u0439\u0434\u0435\u043d\u043e) &quot;`cat $usname.ad | wc -l`&quot; Group in AD (\u0433\u0440\u0443\u043f\u043f \u0432 AD)&quot; &gt;&gt; $log }  function alluserattrzimbra() { \t#\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \t$zmprov -l gaa -v $domain &gt; $usname.gaa \t#\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0444\u0430\u0439\u043b\u044b \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \tcd $zim_us \t#\u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u0444\u0430\u0439\u043b\u044b, \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \tcsplit $usname.gaa --prefix='user.' --suffix-format='%03d.zim' --elide-empty-files -s \/&quot;# name&quot;\/ '{*}'  \t#\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u043f\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c. \u0438\u043c\u044f \u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f zimbra \u0432 \u0444\u0430\u0439\u043b\u0435 \tfor i in $( ls $zim_us ) \tdo \t\tnam=`grep &quot;# name&quot; $zim_us\/$i | awk '{ print $3}' | sed 's\/@.*\/\/g'` \t\tmv -f $zim_us\/$i $zim_us\/$nam \tdone \tcd $path }  #\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 zimbra  function searchuserzimbra() { \techo &quot;\u0417\u0430\u043f\u0438\u0441\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 zimbra...&quot; &gt;&gt; $log \tls $zim_us | sort &gt; $usname.tem \t#\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b \u0438\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u0444\u0430\u0439\u043b $path\/system.acc \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \tdiff -u -i $usname.tem $path\/system.acc  | sed 1,3d | grep ^- | cut -c 2- | sort &gt; $usname.zim \t#rm -f $usname.tem \techo &quot;Found (\u041d\u0430\u0439\u0434\u0435\u043d\u043e) &quot;`cat $usname.zim | wc -l`&quot; Group in Zimbra (\u0433\u0440\u0443\u043f\u043f \u0432 Zimbra)&quot; &gt;&gt; $log \t }  #\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 function diffuserlist() { \tdiff -u -i $usname.zim $usname.ad | sed 1,3d | sed '\/@.*\/d' &gt; $usname.diff }  #\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 function adduser() { #\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\t adddif=`grep ^+ $usname.diff | sed '1!d'` \tif [ -n $adddif ]; \tthen \t\tfor addus in $( grep ^+ $usname.diff | cut -c 2- ) \t\tdo \t\t\t# \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432 zimbra (\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c - \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c, \u043d\u0435\u0442 - \u0441\u043e\u0437\u0434\u0430\u0435\u043c)                         ifclos=`grep &quot;zimbraAccountStatus:&quot; $zim_us\/$addus | awk '{print $2}' | cut -c -1` \t\t\techo &quot;c=&quot;$ifclos&quot;!&quot; \t\t\tif [ $ifclos = &quot;c&quot; ]; \t\t\tthen \t\t\t\techo &quot;ma $addus@$domain zimbraAccountStatus active&quot; &gt;&gt; $zmcmdfile \t\t\t\techo &quot;\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c $addus \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d&quot; &gt;&gt; $tmp_dir\/send.txt \t\t\t\tif [ $addus != &quot;&quot; ]; \t\t\t\tthen \t\t\t\t\tsync_one_user $addus \t\t\t\tfi \t\t\telse \t\t\t\t#echo $addus&quot;-2&quot; \t\t\t\techo &quot;ca $addus@$domain&quot; &gt;&gt; $zmcmdfile \t\t\t\techo &quot;\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c $addus \u0441\u043e\u0437\u0434\u0430\u043d&quot; &gt;&gt; $tmp_dir\/send.txt \t\t\t\tif [ $addus != &quot;&quot; ]; \t\t\t\tthen \t\t\t\t\tsync_one_user $addus \t\t\t\tfi \t\t\tfi \t\tdone \t\t \tfi }  #\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c function blockuser() { \tdeldif==`grep ^- $usname.diff | sed '1!d'` \tif [ -n $deldif ]; \tthen \t\tfor delus in $( grep ^- $usname.diff | cut -c 2- ) \t\tdo \t\t\t#zimbraAccountStatus closed \t\t\tif [ $delus != &quot;&quot; ]; \t\t\tthen \t\t\t\tifclos=`grep &quot;zimbraAccountStatus:&quot; $zim_us\/$delus | awk '{print $2}'` \t\t\t\tif [ &quot;$ifclos&quot; != &quot;closed&quot; ]; \t\t\t\tthen \t\t\t\t\techo &quot;user closed - $delus&quot; \t\t\t\t\techo &quot;ma $delus@$domain zimbraAccountStatus closed&quot; &gt;&gt; $zmcmdfile \t\t\t\t\techo &quot;\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c $delus \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d! \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u0435\u0433\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e!&quot; &gt;&gt; $tmp_dir\/send.txt \t\t\t\t\techo $delus &gt;&gt; $path\/close.1 \t\t\t\t\tcat $path\/close.1 | sort &gt; $path\/close.diff \t\t\t\t\techo &quot;$delus&quot;  \t\t\t\tfi \t\t\tfi \t\tdone \tfi }  #\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 function ifattr() { \tif1char=`echo $2 | cut -c -1` \tif [[ -n $2 && $if1char != &quot;&quot; ]]; \t#if [ $2 != &quot;&quot; ]; \tthen  \t    #echo $2 \t    echo -n &quot; $1 \\&quot;$2\\&quot;&quot;  &gt;&gt; $zmcmdfile \tfi }  #\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f function sync_one_user() { \techo &quot;\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f $1...&quot; &gt;&gt; $log \t$ldapsearch -x -o ldif-wrap=no -H $ldap_server -D $binddn -w $bindpw -b $basedn &quot;(sAMAccountName=$1)&quot; $fields &gt; $userfil\/$1.ad \t \t#\u0421\u043e\u0437\u0434\u0430\u0435\u043c\u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \techo -n  &quot;ma &quot;$1 &gt;&gt; $zmcmdfile \t \t#samacc=`grep &quot;sAMAccountName:&quot; $userfil\/$1 | awk '{print $2}'`   \t\t \tdescription=`grep &quot;description:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}'` \t#echo $description \tifattr &quot;description&quot; &quot;$description&quot; \t\t \tdisplayName=`grep &quot;displayName:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}' | base64 -d` \tifattr &quot;displayName&quot; &quot;$displayName&quot; \t \tgivenName=`grep &quot;givenName:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}' | base64 -d` \tifattr &quot;givenName&quot; &quot;$givenName&quot; \t \tcn=`grep &quot;cn:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}'` \tifattr &quot;cn&quot; &quot;$cn&quot; \t \tsn=`grep &quot;sn:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}' | base64 -d` \tifattr &quot;sn&quot; &quot;$sn&quot; \t \tdepartment=`grep &quot;department:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}' | base64 -d` \tifattr &quot;company&quot; &quot;$department&quot; \t \ttitle=`grep &quot;title:&quot; $userfil\/$1.ad | awk '{split ($0, a, &quot;: &quot;); print a[2]}' | base64 -d` \tifattr &quot;title&quot; &quot;$title&quot; \t \t#\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 \techo &gt;&gt; $zmcmdfile \t#\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043b\u0438\u0430\u0441 \tmailnew=`grep &quot;mail:&quot; $userfil\/$1.ad | awk '{print $2}'` \tif [ &quot;$mailnew&quot; != &quot;&quot; ]; \tthen  \t# [ -n $mailnew ]  \t#    echo $2 \t\t#\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u043b\u0438\u0430\u0441\u0430 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \t\t#${1,,} - \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0432\u0441\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443 \t\tuseralias=`grep &quot;zimbraMailAlias:&quot; $zim_us\/${1,,} | awk '{print $2}'` \t    if [ $useralias != $mailnew ]; \t\tthen \t\t\techo &quot;aaa \\&quot;$1@$domain\\&quot; \\&quot;$mailnew\\&quot;&quot;  &gt;&gt; $zmcmdfile \t\tfi \tfi \t#ifattr &quot;mail&quot; $mailnew #\techo $mailnew \techo &quot;\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f $1 &quot; &gt;&gt; $tmp_dir\/send.txt  \t #\techo &quot;\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c $1 - $atrruser&quot; \t \t#echo &quot;Found (\u041d\u0430\u0439\u0434\u0435\u043d\u043e) &quot;`cat $usname.ad | wc -l`&quot; Group in AD (\u0433\u0440\u0443\u043f\u043f \u0432 AD)&quot; &gt;&gt; $log }   #\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 date +%F-%H-%M #2.\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432 #\u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 if_path $path #\u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 if_path $tmp_dir #\u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 if_path $log_dir #\u041a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0433\u0440\u0443\u043f\u043f if_path $userfil #\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u0438\u043c\u0431\u0440\u0430 if_path $zim_us  #\u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 zmprov :&gt; $zmcmdfile # \u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0442\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 :&gt; $tmp_dir\/send.txt #3.\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0433\u0440\u0443\u043f\u043f \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u0438\u0437 AD  searchusersAD  #4.\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432 zimbra \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 alluserattrzimbra #\u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043b\u0438\u0448\u043d\u0438\u0445 (\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445) searchuserzimbra  #5.\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043e\u0431\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0433\u0440\u0443\u043f\u043f \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 diffuserlist #\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 blockuser #\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u043b\u0438 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 adduser  #tckb \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &quot;all&quot; \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435, \u0442\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 mail AD if [[ -n $1 && $1 = &quot;all&quot; ]]; then \tfor us in $(cat $usname.ad ); \tdo \t#\techo $us \t\tsync_one_user $us \tdone fi # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 zmprov \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 $zmprov -f $zmcmdfile # \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043b\u043e\u0433 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438  cat $zmcmdfile &gt;&gt; $log #\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0438\u0441\u044c\u043c\u043e \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0443 (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c) if [ -s $tmp_dir\/send.txt ]; then \t$mutt  -s &quot;\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 $timestamp&quot; admins@test.ru -a $log &lt; $tmp_dir\/send.txt fi  #\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 rm -R -f $tmp_dir  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2>5. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0448\u0443\u0441\u0442\u0440\u044b\u0439, \u0443\u0442\u0438\u043b\u0438\u0442\u0430 zmprov \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u0440\u0430\u0437\u0430, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<h2>6. \u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0438\u0434\u0435\u0438 \u0438 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<p>  1. <a href=\"https:\/\/habr.com\/ru\/post\/443166\/\">\u0421\u044b\u0441\u043e\u0435\u0432\u0430 \u0410\u043d\u0434\u0440\u0435\u044f<\/a> <br \/>  2. <a href=\"http:\/\/www.ossportal.ru\/technologies\/zimbra\/blogs\/1060\"> DruGoeDeLo<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/495688\/\"> https:\/\/habr.com\/ru\/post\/495688\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/495688\/\">\n<h2>1. \u041f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440 zimbra \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435 \u0432 Active Directory (AD). \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 AD, \u0442\u043e \u043e\u043d \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0441\u044f, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0435, \u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0410 \u0432\u043e\u0442 \u043f\u043e\u0442\u043e\u043c, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 zimbra.<\/p>\n<p>  \u0427\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 powershell (\u0437\u0430\u0447\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c ldapsearch) \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u044b zmprov, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0438\u0434\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301281","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301281"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301281\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}