{"id":299553,"date":"2020-03-02T15:00:23","date_gmt":"2020-03-02T15:00:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299553"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299553","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u0451\u043c WEB \u0430\u0434\u0440\u0435\u0441\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a PHP + LDAP"},"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\/490690\/\">\u0422\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0443 (\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e) \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u0431\u044b\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 \u043e\u0444\u0438\u0441\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0412\u0441\u0435 \u043e\u0444\u0438\u0441\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0435\u0442\u044c \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u043c\u0435\u043d\u043e\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0444\u0438\u0441 \u0431\u044b\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u0432 Active Directory (\u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443 AD) \u043a\u0430\u043a Organization Unit (OU), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0437\u0430\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438.<\/p>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0438\u0437 AD, \u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0440\u0443\u0442\u0438\u043d\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0433\u0440\u0430\u043b \u0440\u043e\u043b\u044c \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u0438 \u0433\u043e\u043b\u043e\u0432\u043e\u0439.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u043e\u043c\u0435\u043d\u0430 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0443\u043c \u044d\u0442\u043e PHP \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 ldap, \u0438\u0445 \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0411\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u043b\u044e\u0441\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PHP \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0435\u0433\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u2014 \u043b\u044e\u0431\u043e\u0439 \u0445\u043e\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u043d\u0435\u0441\u0442\u0438, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u043a\u043e\u0434, \u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u044f\u0441\u044c.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c. \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0434\u043e\u043c\u0435\u043d\u0443:<\/p>\n<pre><code class=\"php\">$srv =&quot;SERVER&quot;; $srv_domain =&quot;DOMAIN.COM&quot;; $srv_login =&quot;USERNAME@&quot;.$srv_domain;  $srv_password =&quot;PASSWORD&quot;; <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c OU \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 $_GET[&#8216;place&#8217;]. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <i><a href=\"https:\/\/server\/index.php?place=\">server\/index.php?place=<\/a><b>first<\/b><\/i>, \u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <b>$place<\/b> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <b>first<\/b>.<\/p>\n<pre><code class=\"php\">$place = (@$_GET['place']); $doscript=true; switch($place){  case &quot;first&quot; : \t$dn =&quot;OU=ou1,OU=DOMAIN,dc=DOMAIN,dc=COM&quot;;\t\t\t \tbreak; case &quot;second&quot;: \t$dn =&quot;OU=ou2,OU=DOMAIN,dc=DOMAIN,dc=COM&quot;;\t\t\t \tbreak; \t\/\/\u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. default: \t$doscript=false;  \tbreak; } if (!$doscript) include &quot;main_table.html&quot;; <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <b>$doscript<\/b> \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u043b\u0438 \u043c\u044b OU, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u00abswitch-case\u00bb, \u0442\u043e $doscript=false, \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u00abmain_table.html\u00bb (\u043e \u043d\u0435\u0439 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435).<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 OU, \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c: \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430:<\/p>\n<pre><code class=\"php\">else if ($doscript) { {echo &quot; &lt;!DOCTYPE html&gt;  &lt;html xmlns='http:\/\/www.w3.org\/1999\/xhtml'&gt; &lt;head&gt; &lt;link rel='shortcut icon' href='ico.png'&gt; &lt;meta charset='windows-1251\/ '&gt; <\/code><\/pre>\n<p>  \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0438\u043b\u0438 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0432\u0438\u0434\u0430 (\u0434\u0430, \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u043a css-\u0444\u0430\u0439\u043b, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 IE \u043d\u0435 \u0445\u043e\u0442\u044f\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 \u0441\u043a\u0440\u0438\u043f\u0442):<\/p>\n<pre><code class=\"php\">&lt;style&gt; \t*{text-align: center; font-family:tahoma; font-size:14px;} \ta{text-decoration: none; color: #000;} \ta:hover{text-decoration: underline; color: #0059FF;} \t#bold{text-decoration: none; font-weight: 600;font-size:20px;} \t#table,tr,td{border-style:solid;border-width:1px;\tborder-collapse:collapse;padding:5px; height:22px;border-color:#7d7d7d;} \t\/* \u041d\u0435\u0447\u0435\u0442\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 *\/#table tbody tr:nth-child(odd){background: #fff;} \t\/* \u0427\u0435\u0442\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 *\/   #table tbody tr:nth-child(even){background: #F7F7F7;}\t \t#noborder{border-width: 0 px; border-style: none;}\t \t#sp30px{text-indent: 30px;text-align: justify;} \t#smallsize{font-family:tahoma; text-indent: 5px; text-align:left; font-size:12px;} \t#top {background: #ffffff; \t\ttext-align: center; \t\tleft:0; \t\ttop:0px; \t\ttable-layout: fixed; \t\tborder-style:solid; \t\tborder-width:0px; \t\tborder-collapse:collapse; \t\tpadding:0px; \t\theight:22px; \t\tborder: 0px; \t\tz-index: 99999; \t\tdisplay:block; \t\twidth:80px; \t\topacity: 0.6; \t\tfilter: alpha(Opacity=60); \t\theight:100%; \t\tposition:fixed;} \t#top:hover{background: #afafaf;opacity: 100;filter: alpha(Opacity=100);text-decoration: none;color: #000000;} \t.smalltext{padding-top: 1px; \t\tpadding-bottom: 1px; \t\ttext-align: bottom; \t\tfont-family:tahoma; \t\tcolor: #a0a0a0; \t\tline-height: 7px; \t\tfont-size: 10px;} \t.smalltext:hover{color: #0000ff;}\t\t \t.transition-rotate {position: relative; \t\tz-index: 2; \t\tmargin: 0 auto; \t\tpadding: 5px; \t\ttext-align: center; \t\tmax-width: 500px; \t\tcursor: pointer; \t\ttransition: 0.1s linear;} \t.transition-rotate:hover {-webkit-transform: rotate(-2deg);\ttransform: rotate(-2deg);} \t#lineheight{ \t\ttext-align: left; \t\tline-height: 1px; \t\ttext-decoration: none; \t\tfont-weight: 600; \t\tfont-size:20px;} &lt;\/style&gt; <\/code><\/pre>\n<p>  \u0421\u043e \u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u043f\u043e\u043a\u043e\u043d\u0447\u0435\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0438\u0448\u0435\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0432\u043a\u043b\u0430\u0434\u043a\u0438 \u0438 \u0440\u0438\u0441\u0443\u0435\u043c \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443:<\/p>\n<pre><code class=\"php\">&lt;title&gt;Adressbook of &laquo;YourMegaCompanyName&raquo;&lt;\/title&gt;\t &lt;\/head&gt; &lt;body style='background-color:#ffffff;'&gt;&quot;; } echo &quot; &lt;table id='top'&gt;&lt;tr&gt;&lt;td id='top'&gt; &lt;a href='index.php?place=main' id='top' &gt; &lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;img src='back_to_main.png' alt='' border='0' width='75' height='60'\/&gt; &lt;p&gt;\u041d\u0430 \u0433\u043b\u0430\u0432\u043d\u0443\u044e&lt;\/p&gt;&lt;\/a&gt; &lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt; &quot;; <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u043e AD, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 OU:<\/p>\n<pre><code class=\"php\">$filter =&quot;(&(objectcategory=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))&quot;; \/\/\u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043a\u0440\u043e\u043c\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445. $filter2 =&quot;(objectCategory=OrganizationalUnit)&quot;; \/\/ \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e OU $ds=ldap_connect($srv);    if ($ds) {      $r=ldap_bind($ds,$srv_login,$srv_password);;      \tldap_set_option($ds,LDAP_OPT_REFERRALS, 0); \tldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3); \t$sr=ldap_search($ds,$dn ,$filter );        ldap_sort($ds,$sr, &quot;givenname&quot;);     $info = ldap_get_entries($ds, $sr);      $sr2=ldap_search($ds,$dn ,$filter2 );        $placeinfo = ldap_get_entries($ds, $sr2);  $PlaceName = $placeinfo[0][&quot;l&quot;][0];  \t\t\t\/\/ name of place $PlaceAddres = $placeinfo[0][&quot;street&quot;][0];\t\t\/\/ address of place $PlaceMail = $placeinfo[0][&quot;description&quot;][0]; \t\/\/ mail of place $PlacePhone = $placeinfo[0][&quot;st&quot;][0]; \t\t\/\/ phone of plase <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043e\u0444\u043e\u0440\u043c\u043b\u044f\u0435\u043c \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"php\">echo&quot;&lt;table align='center' height = '80'&gt; \t&lt;td id='noborder' &gt;&lt;div id='lineheight'&gt;&quot;. $PlaceName .&quot;&lt;\/div&gt;&lt;\/td&gt;&lt;\/tr&gt; \t&lt;tr&gt;&lt;td id='noborder' &gt;&quot;. $PlaceAddres .&quot;&lt;\/td&gt;&lt;\/tr&gt;     &lt;\/table&gt; &lt;table align='center' id='table'&gt; \t&lt;tr&gt;&lt;td width='35' bgcolor = #f0f0e4&gt;  \u2116 &lt;\/td&gt; \t&lt;td width='300' bgcolor = #f0f0e4&gt; Name &lt;\/td&gt; \t&lt;td width='250' bgcolor = #f0f0e4&gt; E-mail &lt;\/td&gt; \t&lt;td width='60' bgcolor = #f0f0e4&gt; Phone &lt;\/td&gt; \t&lt;td width='150' bgcolor = #f0f0e4&gt; Mobile &lt;\/td&gt;&lt;\/tr&gt; \t&lt;tr&gt;&lt;td&gt;&lt;\/td&gt;&lt;td&gt; \u0414\u0430\u043d\u043d\u044b\u0435 OU &lt;\/td&gt;&lt;td&gt;&quot;; echo &quot;&lt;div class='transition-rotate'&gt;&lt;a href=mailto:&quot; . $PlaceMail .&quot;&gt;&quot; . $PlaceMail .&quot; &lt;\/a&gt;&lt;\/div&gt;&quot;; echo &quot;&lt;\/td&gt;&lt;td width='150'&gt; &quot; . $PlacePhone .&quot; &lt;\/td&gt;&lt;td&gt; - &lt;\/td&gt;&lt;\/tr&gt;&quot;; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u044b\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435) \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u00abhide\u00bb \u0432 \u043f\u043e\u043b\u0435 \u00ab\u043a\u043e\u043c\u043d\u0430\u0442\u0430\u00bb \u0432 \u0440\u0435\u043a\u0432\u0438\u0437\u0438\u0442\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 AD, \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0435:<\/p>\n<pre><code class=\"php\">for ($i=0; $i&lt;$info[&quot;count&quot;];$i++) {  $UserHide = $info[$i][&quot;physicaldeliveryofficename&quot;][0]; if ($UserHide != 'hide') { $UserName = $info[$i][&quot;cn&quot;][0];                \/\/\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f $UserPosition = $info[$i][&quot;title&quot;][0]; \t\t\/\/ \u0414\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u044c $UserMail = $info[$i][&quot;mail&quot;][0];\t\t\t\/\/mail if (!$UserMail)) $UserMail = &quot;-&quot;;                  \/\/\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u044f\u0449\u0438\u043a\u0435 \u0432 AD, \u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0447\u0435\u0440\u043a $UserIpPhone = $info[$i][&quot;ipphone&quot;][0];\t\t\/\/ip phone \tif (!$UserIpPhone) $UserIpPhone = &quot;-&quot;;    \/\/\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u044f\u0449\u0438\u043a\u0435 \u0432 AD, \u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0447\u0435\u0440\u043a $UserMobile = $info[$i][&quot;mobile&quot;][0];\t\t\/\/mobile \tif (!$UserMobile) $UserMobile = &quot;-&quot;;     \/\/\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u044f\u0449\u0438\u043a\u0435 \u0432 AD, \u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0447\u0435\u0440\u043a <\/code><\/pre>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430, \u0442\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435 (\u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e):<br \/>  <b>\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0438\u043c\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <u>\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u043c\u0438 <\/u>\u0431\u0443\u043a\u0432\u0430\u043c\u0438<\/b>, \u0438\u043d\u0430\u0447\u0435 \u043d\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u0418 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code class=\"php\">    echo &quot;&lt;tr&gt; \t&lt;td&gt;&quot;. $n+=1 .&quot;&lt;\/td&gt; \t&lt;td&gt; &quot;. $UserName .&quot;&lt;br&gt; &lt;div class='smalltext'&gt;&quot;. $UserPosition .&quot;&lt;\/div&gt;&lt;\/td&gt;&lt;td&gt;&quot;; \/\/\t\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u0441\u0442\u044c  \tif ($UserMail !='-') echo &quot;&lt;div class='transition-rotate'&gt;&lt;a href=mailto:'$UserMail'&gt;$UserMail  &lt;\/a&gt;&lt;\/div&gt;&quot;;    \/\/ \u0435\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c e-mail \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u043f\u0438\u0441\u044c\u043c\u0430 \telse echo &quot;-&quot;; \/\/\u0435\u0441\u043b\u0438 \u043d\u0435\u0442 e-mail - \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0447\u0435\u0440\u043a.  \techo &quot;&lt;td&gt; &quot;. $UserIpPhone .&quot; &lt;\/td&gt;  \t&lt;td&gt; &quot;. $UserMobile .&quot; &lt;\/td&gt;&lt;\/tr&gt;&quot;; \t} } echo &quot;&lt;\/table&gt;&quot;; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e ldap, \u0438\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443:<\/p>\n<pre><code class=\"php\">ldap_close($ds);  }  else echo &quot;&lt;h4&gt;Unable to connect to LDAP server&lt;\/h4&gt;&quot;;  echo '&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;\/body&gt;&lt;\/html&gt;';} <\/code><\/pre>\n<p>  \u0424\u0430\u0439\u043b \u00abmain_table.html\u00bb \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u0443\u044e html \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">&lt;head&gt; &lt;link rel=&quot;shortcut icon&quot; href=&quot;ico.png&quot;\/&gt; &lt;meta charset=&quot;windows-1251&quot;\/&gt; &lt;title&gt;Adressbook of &laquo;YourMegaCompanyName&raquo;&lt;\/title&gt; &lt;\/head&gt; &lt;body style='background-color:#ffffff;'&gt; &lt;center&gt;&lt;a href=index.php&gt;&lt;IMG border=&quot;none&quot; src=&quot;logo.png&quot;\/&gt;&lt;\/a&gt;&lt;\/center&gt; &lt;center&gt;&lt;b&gt;Places and offices&lt;\/b&gt;&lt;\/center&gt; &lt;br&gt; &lt;table border=&quot;0&quot; width=&quot;450&quot; bgcolor=&quot;#dddddd&quot; align=&quot;center&quot; valign=&quot;middle&quot; CELLSPACING=&quot;0&quot;&gt;  &lt;tr id=&quot;space&quot;&gt;&lt;td&gt;&lt;\/td&gt;&lt;\/tr&gt; &lt;tr&gt;&lt;td align=&quot;left&quot; id=&quot;abz&quot;&gt;&lt;a href=&quot;index.php?place=ou1&quot;&gt;OU1&lt;\/a&gt;&lt;\/td&gt;&lt;\/tr&gt; &lt;tr id=&quot;space&quot;&gt;&lt;td&gt;&lt;\/td&gt;&lt;\/tr&gt; &lt;tr&gt;&lt;td align=&quot;left&quot; id=&quot;abz&quot;&gt;&lt;a href=&quot;index.php?place=ou2&quot;&gt;OU2&lt;\/a&gt;&lt;\/td&gt;&lt;\/tr&gt;  &lt;\/table&gt;&lt;\/body&gt;&lt;\/html&gt; <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0439 \u043a\u043e\u0434 \u2014 \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0434, \u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c! <\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0432\u0430\u043c \u0443\u0433\u043e\u0434\u043d\u043e (\u0443\u043b\u0443\u0447\u0448\u0430\u0442\u044c\/\u0443\u0445\u0443\u0434\u0448\u0430\u0442\u044c) \u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u043b\u044e\u0431\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. <\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p><\/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\/490690\/\"> https:\/\/habr.com\/ru\/post\/490690\/<\/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\/490690\/\">\u0422\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0443 (\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e) \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u0431\u044b\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 \u043e\u0444\u0438\u0441\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0412\u0441\u0435 \u043e\u0444\u0438\u0441\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0435\u0442\u044c \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u043c\u0435\u043d\u043e\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0444\u0438\u0441 \u0431\u044b\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u0432 Active Directory (\u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443 AD) \u043a\u0430\u043a Organization Unit (OU), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0437\u0430\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438.<\/p>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0438\u0437 AD, \u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0440\u0443\u0442\u0438\u043d\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0433\u0440\u0430\u043b \u0440\u043e\u043b\u044c \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438.  <\/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-299553","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299553","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=299553"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299553\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}