{
    "version": "https:\/\/jsonfeed.org\/version\/1.1",
    "title": "IT science: заметки с тегом php",
    "_rss_description": "IT science — статьи и инструкции из мира IT",
    "_rss_language": "ru",
    "_itunes_email": "",
    "_itunes_categories_xml": "",
    "_itunes_image": "",
    "_itunes_explicit": "",
    "home_page_url": "https:\/\/itscience.pro\/tags\/php\/",
    "feed_url": "https:\/\/itscience.pro\/tags\/php\/json\/",
    "icon": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154",
    "authors": [
        {
            "name": "IT science",
            "url": "https:\/\/itscience.pro\/",
            "avatar": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154"
        }
    ],
    "items": [
        {
            "id": "41",
            "url": "https:\/\/itscience.pro\/all\/massovaya-registraciya-graphisoft-id\/",
            "title": "массовая регистрация graphisoft id",
            "content_html": "<p>Встал вопрос получить сотрудникам Graphisoft id, но никакого функционала у производителя нет, чтобы сделать это массово.  Печаль.<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/izobrazhenie_2021-09-24_184451.png\" width=\"250\" height=\"237\" alt=\"\" \/>\n<\/div>\n<p>Итак, проанализировав механизм регистрации и добавления пользователя в состав компании получаем следующий алгоритм:<\/p>\n<ol start=\"1\">\n<li>регистрация пользователя на сайте graphisoft.com<\/li>\n<li>подтверждение регистрации в посте пользователя<\/li>\n<li>авторизация на сайте graphisoft.com под административной учетной записью<\/li>\n<li>отправка приглашения пользователю<\/li>\n<li>авторизация  на сайте graphisoft.com под пользовательской учетной записью<\/li>\n<li>подтверждение приглашения<\/li>\n<\/ol>\n<p>как родилось решение описано тут:<br \/>\n<a href=\"https:\/\/voronin.one\/all\/kak-nelzya-otnositsya-k-korporativnym-klientam\/\">1 часть, «как нельзя относиться к корпоративным клиентам»<\/a><br \/>\n<a href=\"https:\/\/voronin.one\/all\/analiz-poluchenie-ishodnyh-dannyh\/\">2 часть, «анализ, получение исходных данных»<\/a><br \/>\n<a href=\"https:\/\/voronin.one\/all\/kropotlivaya-rabota-i-dolgozhdanny-uspeh\/\">3 часть, «кропотливая работа и долгожданный успех»<\/a><\/p>\n<p>получилось неплохо, полностью автоматизированная система, работает следующим образом:<br \/>\nпри появлении нового сотрудника создается для него graphisoft id, добавляется в состав компании и на почту высылаются данные с логином и паролем, а так же инструкция по использованию последних;<br \/>\nпосле увольнения сотрудника или ухода в декрет — graphisoft id исключается из списка сотрудников компании.<\/p>\n<p>ниже сам код регистрации одно пользователя, как сделать это массово — я думаю разберетесь<\/p>\n<pre class=\"e2-text-code\"><code class=\"\">&lt;?php\n\n\/\/ данные регистрируемого сотрудника\n$fname = &#039;Иван&#039;;\n$sname = &#039;Петров&#039;;\n$email = &#039;user@domain.ru&#039;;\n$pasword = &#039;koo0ovo5Kamu&#039;;\n\n\/\/ данные администратора компании\n$admin_login = &#039;admin@domain.ru&#039;;\n$admin_password = &#039;P@5$w0rD&#039;;\n\n$header = &#039;&#039;;\n\nfunction get_url($url, $method, $ctype, $referer, $data) {\n\t$ch = curl_init();\n\tcurl_setopt($ch, CURLOPT_URL, $url);\n\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\tcurl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);\n\tif ($data!==&#039;&#039;) {\n\t\tif ($ctype == 1) {\n\t\t\tcurl_setopt($ch, CURLOPT_POST, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));\n\t\t} else if ($ctype == 2) {\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));\n\t\t} else if ($ctype == 3) {\n\t\t\tcurl_setopt($ch, CURLOPT_HEADER, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_POST, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));\n\t\t}\n\t}\n\tcurl_setopt($ch, CURLOPT_ENCODING, &#039;gzip, deflate&#039;);\n\t$headers = array();\n\t$headers[] = &#039;Connection: keep-alive&#039;;\n\t$headers[] = &#039;Sec-Ch-Ua: \\&quot; Not;A Brand\\&quot;;v=\\&quot;99\\&quot;, \\&quot;Opera\\&quot;;v=\\&quot;79\\&quot;, \\&quot;Chromium\\&quot;;v=\\&quot;93\\&quot;&#039;;\n\t$headers[] = &#039;Dnt: 1&#039;;\n\t$headers[] = &#039;Sec-Ch-Ua-Mobile: ?0&#039;;\n\t$headers[] = &#039;User-Agent: Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/93.0.4577.63 Safari\/537.36 OPR\/79.0.4143.22&#039;;\n\tif ($ctype == 1) {\n\t\t$headers[] = &#039;Content-Type: application\/json; charset=UTF-8&#039;;\n\t} else {\n\t\t$headers[] = &#039;Content-Type: application\/x-www-form-urlencoded; charset=UTF-8&#039;;\n\t}\n\t$headers[] = &#039;Accept: application\/json, text\/javascript, *\/*; q=0.01&#039;;\n\t$headers[] = &#039;X-Requested-With: XMLHttpRequest&#039;;\n\t$headers[] = &#039;Sec-Ch-Ua-Platform: \\&quot;Windows\\&quot;&#039;;\n\t$headers[] = &#039;Sec-Fetch-Site: same-origin&#039;;\n\t$headers[] = &#039;Sec-Fetch-Mode: cors&#039;;\n\t$headers[] = &#039;Sec-Fetch-Dest: empty&#039;;\n\t$headers[] = &#039;Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7&#039;;\n\t$headers[] = &#039;Origin: &#039;.$referer;\n\t$headers[] = &#039;Referer: &#039;.$referer;\n\tcurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n\tcurl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\tcurl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t$response = curl_exec($ch);\n\tglobal $header;\n\t$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n\t$header = substr($response, 0, $header_size);\n\treturn $response;\n\tif (curl_errno($ch)) {\n\t\techo &#039;Error:&#039; . curl_error($ch);\n\t}\n\tcurl_close($ch);\n}\n\n\/\/ удаляем старые куки\nif (file_exists(dirname(__FILE__).&#039;\/cookie.txt&#039;)) {\n   unlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n}\t\t\n\/\/ заходим на главную\nget_url(&#039;https:\/\/graphisoft.com\/ru&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\/\/ переходим на форму пользователя\nget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/Account\/ServiceLogin?Application=GRAPHISOFT&amp;ReturnUrl=https:\/\/graphisoft.com\/ru&#039;,&#039;GET&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;&#039;);\n\/\/ переходим на форму регистрации\nget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/#\/register\/3\/https%3a%2f%2fgraphisoft.com%2fru&#039;,&#039;GET&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;&#039;);\n\n\/\/проверяем e-mail\n$check_mail = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/CheckEmail\/&#039;,&#039;PUT&#039;,2,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,array(&quot;EmailAddress&quot; =&gt; $email));\nif ($check_mail == &#039;true&#039;) {\n\t$data = array(&#039;applicationName&#039; =&gt; null,\n\t\t\t\t  &#039;customDataObject&#039; =&gt; null,\n\t\t\t\t  &#039;redirectUrl&#039; =&gt; null,\n\t\t\t\t  &#039;emailHintLocalizationKey&#039; =&gt; null,\n\t\t\t\t  &#039;firstName&#039; =&gt; $fname,\n\t\t\t\t  &#039;lastName&#039; =&gt; $sname,\n\t\t\t\t  &#039;isValidated&#039; =&gt; true,\n\t\t\t\t  &#039;email&#039; =&gt; $email,\n\t\t\t\t  &#039;password&#039; =&gt; $pasword,\n\t\t\t\t  &#039;confirmPassword&#039; =&gt; $pasword,\n\t\t\t\t  &#039;isPrivacyPolicyAccepted&#039; =&gt; true,\n\t\t\t\t  &#039;companyName&#039; =&gt; &#039;ООО &quot;Рога и Копыта&quot;&#039;,\n\t\t\t\t  &#039;countryId&#039; =&gt; 186,\n\t\t\t\t  &#039;federated&#039; =&gt; false,\n\t\t\t\t  &#039;callbackUrl&#039; =&gt; &#039;https:\/\/graphisoft.com\/ru&#039;,\n\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t  &#039;errors&#039; =&gt; array());\n\n\t\/\/echo json_encode($data).&quot;\\n&quot;;\n\n\t$ecoded_json = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/CreateUser&#039;,&#039;POST&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\n\t$jsonObj = json_decode($ecoded_json);\n\n\tif ($jsonObj === null &amp;&amp; json_last_error() !== JSON_ERROR_NONE) {\n\t   echo &quot;у меня не получилось отправить регистрационную форму с данными...  извините\\n&quot;;\n\t} else {\n\t\t\/\/ удаляем старые куки\n\t\tunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t\tget_url($jsonObj-&gt;{&#039;VerificationURL&#039;}.$jsonObj-&gt;{&#039;VerificationCode&#039;},&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t$gsid_url = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/VerifyUser&#039;,&#039;PUT&#039;,2,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,array(&quot;code&quot; =&gt; $jsonObj-&gt;{&#039;VerificationCode&#039;}));\n\t\t$parts = parse_url($gsid_url);\n\t\tparse_str($parts[&#039;query&#039;], $query);\n\t\t$user_gsid = $query[&#039;gsid&#039;];\n\t\tif ($user_gsid !== &#039;&#039;) {\n\t\t\techo &quot;пользователь &quot;.$email.&quot; успешно зарегистрирован (Graphisoft sid: &quot;.$user_gsid.&quot;)\\n&quot;;\n\t\t\t\/\/ удаляем старые куки\n\t\t\tunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t\t\t\/\/ заходим на главную\n\t\t\tget_url(&#039;https:\/\/graphisoft.com\/ru&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t\t\/\/ авторизуемся под пользователем\n\t\t\t$data = array(&#039;email&#039; =&gt; $admin_login,\n\t\t\t\t\t\t  &#039;errors&#039; =&gt; array(),\n\t\t\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t\t\t  &#039;isNullo&#039; =&gt; false,\n\t\t\t\t\t\t  &#039;password&#039; =&gt; $admin_password);\t\t\t\n\t\t\t$json_response = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/Authenticate\/Login&#039;,&#039;POST&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\t$obj = json_decode($json_response);\n\t\t\t$companyGsId = $obj-&gt;{&#039;Company&#039;}-&gt;{&#039;GsId&#039;};\n\t\t\t\/\/ Загружаем список подключенных пользователей\n\t\t\tforeach ($obj-&gt;{&#039;Company&#039;}-&gt;{&#039;CompanyUsers&#039;} as $user) {\n\t\t\t\t$users_list[] = array(&quot;FirstName&quot; =&gt; $user-&gt;{&#039;FirstName&#039;},&quot;LastName&quot; =&gt; $user-&gt;{&#039;LastName&#039;},&quot;EmailAddress&quot; =&gt; $user-&gt;{&#039;EmailAddress&#039;},&quot;GsId&quot; =&gt; $user-&gt;{&#039;GsId&#039;});\n\t\t\t}\n\n\n\t\t\t$data = array(&#039;companyGsId&#039; =&gt; $companyGsId,\n\t\t\t\t\t\t  &#039;email&#039; =&gt; $email,\n\t\t\t\t\t\t  &#039;errors&#039; =&gt; array(),\n\t\t\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t\t\t  &#039;requestedGraphisoftUserId&#039; =&gt; $user_gsid);\n\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/SendInvitation&#039;,&#039;PUT&#039;,2,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\techo &quot;выслано приглашение присоединиться к компании\\n&quot;;\n\t\t\t\/\/ удаляем старые куки\n\t\t\tunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t\t\t\/\/ переходим на форму пользователя\n\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t\t\/\/ авторизуемся под пользователем\n\t\t\t$data = array(&#039;email&#039; =&gt; $email,\n\t\t\t\t\t\t  &#039;errors&#039; =&gt; array(),\n\t\t\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t\t\t  &#039;isNullo&#039; =&gt; false,\n\t\t\t\t\t\t  &#039;password&#039; =&gt; $pasword);\t\t\t\n\t\t\t$json_response = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/Authenticate\/Login&#039;,&#039;POST&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\t$obj = json_decode($json_response);\n\t\t\t$user_gsid = $obj-&gt;{&#039;GraphisoftUser&#039;}-&gt;{&#039;GsId&#039;};\n\t\t\tif ($user_gsid == &#039;&#039;) {\n\t\t\t\techo &quot;не смог зайти под пользователем в личный кабинет\\n&quot;;\n\t\t\t} else {\n\t\t\t\t$data = array(&#039;actionId&#039; =&gt; 2,\n\t\t\t\t\t\t\t  &#039;companyGsId&#039; =&gt; $companyGsId,\n\t\t\t\t\t\t\t  &#039;graphisoftUserGsId&#039; =&gt; $user_gsid,\n\t\t\t\t\t\t\t  &#039;reactionId&#039; =&gt; 1);\n\t\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/ProcessingPendingRequest&#039;,&#039;PUT&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\t\techo &quot;сотрудник подтвердил приглашение\\n&quot;;\n\t\t\t}\n\t\t} else {\n\t\t\techo &quot;у меня не получилось подтвердить регистрацию...  извините\\n&quot;;\n\t\t}\n\t}\n} else {\n\techo &quot;$email уже зарегистрирован в системе\\n&quot;;\n}\n\/\/ удаляем старые куки\nunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n?&gt;<\/code><\/pre>",
            "date_published": "2021-09-24T18:45:02+03:00",
            "date_modified": "2021-09-24T18:44:58+03:00",
            "tags": [
                "argicad",
                "graphisoft",
                "php",
                "автоматизация"
            ],
            "image": "https:\/\/itscience.pro\/pictures\/izobrazhenie_2021-09-24_184451.png",
            "_date_published_rfc2822": "Fri, 24 Sep 2021 18:45:02 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "41",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": [
                    "https:\/\/itscience.pro\/pictures\/izobrazhenie_2021-09-24_184451.png"
                ]
            }
        },
        {
            "id": "2",
            "url": "https:\/\/itscience.pro\/all\/skript-php-vozvraschaet-sid-polzovatelya-po-samaccountname\/",
            "title": "скрипт php, возвращает SID пользователя по sAMAccountName",
            "content_html": "<p>Очередная часть глобального проекта по смене домена в корпорации, по сути переезд из домена ActiveDirectory в домен Samba4.<\/p>\n<p>Сегодня мы публикуем вспомогательный скрипт, который возвращает SID пользователя используя sAMAccountName. Написан скрипт на php, состоит из двух частей — конфига и самого скрипта. Нам потребуются эти данные для миграции профилей пользователей на локальных машинах., но не будем забегать вперед.<\/p>\n<p>конфиг вынесен в отдельный файл, т. к. будет использоваться в других утилитах<\/p>\n<p><b>config.php<\/b><\/p>\n<pre class=\"e2-text-code\"><code class=\"\">&lt;?php\n  define(&#039;SOURCE_AD_SERVER&#039;, &#039;old_domain.loc&#039;);\n  define(&#039;SOURCE_AD_USER&#039;, &#039;user_name&#039;);\n  define(&#039;SOURCE_AD_PASSWORD&#039;, &#039;secret_password&#039;);\n  \n  define(&#039;TARGET_AD_SERVER&#039;, &#039;new_domain.loc&#039;);\n  define(&#039;TARGET_AD_USER&#039;, &#039;user_name&#039;);\n  define(&#039;TARGET_AD_PASSWORD&#039;, &#039;secret_password&#039;);\n?&gt;<\/code><\/pre><p>настроек минимум, указаны старый и новый домен, логины и пароли пользователей у которых есть права читать LDAP атрибуты, по сути рядовые пользователи домена.<\/p>\n<p>Мы будем подключаться к корню одного или другого домена, поэтому озаботьтесь, чтобы ваш DNS разрешал оба домена, т. е. ’old_domain.loc’ и ’new_domain.loc’ должны одновременно пинговаться на нашем сервере.<\/p>\n<p><b>get_data.php<\/b><\/p>\n<pre class=\"e2-text-code\"><code class=\"\">&lt;?php\n\ninclude(&quot;config.php&quot;);\n\nfunction SIDtoString($ADsid)\n{\n   $sid = &quot;S-&quot;;\n   \/\/$ADguid = $info[0][&#039;objectguid&#039;][0];\n   $sidinhex = str_split(bin2hex($ADsid), 2);\n   \/\/ Byte 0 = Revision Level\n   $sid = $sid.hexdec($sidinhex[0]).&quot;-&quot;;\n   \/\/ Byte 1-7 = 48 Bit Authority\n   $sid = $sid.hexdec($sidinhex[6].$sidinhex[5].$sidinhex[4].$sidinhex[3].$sidinhex[2].$sidinhex[1]);\n   \/\/ Byte 8 count of sub authorities - Get number of sub-authorities\n   $subauths = hexdec($sidinhex[7]);\n   \/\/Loop through Sub Authorities\n   for($i = 0; $i &lt; $subauths; $i++) {\n      $start = 8 + (4 * $i);\n      \/\/ X amount of 32Bit (4 Byte) Sub Authorities\n      $sid = $sid.&quot;-&quot;.hexdec($sidinhex[$start+3].$sidinhex[$start+2].$sidinhex[$start+1].$sidinhex[$start]);\n   }\n   return $sid;\n}\n\nif ((($_REQUEST[&#039;action&#039;] == &#039;get_sid&#039;) or ($_REQUEST[&#039;action&#039;] == &#039;get_bin_sid&#039;)) and ($_REQUEST[&#039;domain&#039;] != &#039;&#039;) and ($_REQUEST[&#039;samaccountname&#039;] != &#039;&#039;))\n{\n    if ($_REQUEST[&#039;domain&#039;] == &#039;new&#039;) {\n        $ldap_server = TARGET_AD_SERVER;\n        $ldap_user = TARGET_AD_USER;\n        $ldap_password = TARGET_AD_PASSWORD;\n    } elseif ($_REQUEST[&#039;domain&#039;] == &#039;old&#039;) {\n        $ldap_server = SOURCE_AD_SERVER;\n        $ldap_user = SOURCE_AD_USER;\n        $ldap_password = SOURCE_AD_PASSWORD;\n    }\n    $ldapconn = ldap_connect($ldap_server) or die(&quot;Could not connect to LDAP server.&quot;); \n    if($ldapconn) {\n        ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3) or die (&quot;Could not set ldap protocol&quot;);\n        ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); \n        ldap_set_option($ldapconn, LDAP_OPT_SIZELIMIT, 10000);\n        $source_ldapbind = ldap_bind($ldapconn, $ldap_user.&quot;@&quot;.$ldap_server, $ldap_password) or die (&quot;Error trying to bind: &quot;.ldap_error($ldapconn));\n        \n        $tree_pieces = explode(&quot;.&quot;, $ldap_server);\n        $ldaptree = &quot;DC=&quot;.$tree_pieces[0].&quot;,DC=&quot;.$tree_pieces[1];\n      \n        $attributes = array(&quot;cn&quot;, &quot;samaccountname&quot;, &quot;objectsid&quot;);\n       \n        $query = &quot;(samaccountname=&quot;.$_REQUEST[&#039;samaccountname&#039;].&quot;)&quot;;\n        \n        $result = ldap_search($ldapconn,$ldaptree, $query, $attributes) or die (&quot;Error in search query: &quot;.ldap_error($ldapconn));\n\t     $data = ldap_get_entries($ldapconn, $result);\n        \n        for ($i=0; $i&lt;$data[&quot;count&quot;]; $i++) {\n           if ($_REQUEST[&#039;action&#039;] == &#039;get_sid&#039;) {\n            echo SIDtoString($data[$i][&quot;objectsid&quot;][0]);\n            \/\/echo $i.&#039;. - &#039;.$data[$i][&quot;cn&quot;][0].&quot;&lt;\/br&gt;&quot;;\n           }\n           elseif ($_REQUEST[&#039;action&#039;] == &#039;get_bin_sid&#039;) {\n            echo wordwrap(bin2hex($data[$i][&quot;objectsid&quot;][0]), 2, &#039;,&#039;, true);\n           }\n        }\n\n        ldap_close($ldapconn);\n    }\n} else {\n    echo &#039;off&#039;;\n}\n?&gt;<\/code><\/pre><p>функция SIDtoString заимствована из интернета, остальное критикуйте =)<\/p>\n<p>работает следующим образом:<\/p>\n<blockquote>\n<p><a href=\"http:\/\/ip_server\/get_data.php?action=get_sid&domain=new&samaccountname=user_login\">http:\/\/ip_server\/get_data.php?action=get_sid&domain=new&samaccountname=user_login<\/a><\/p>\n<\/blockquote>\n<p>возвращает SID в виде строки, параметр «domain» может принимать значения «new» и «old»<\/p>\n<blockquote>\n<p>S-1-5-21-2225672442-1781935378-3171287829-1104<\/p>\n<\/blockquote>\n<blockquote>\n<p><a href=\"http:\/\/ip_server\/get_data.php?action=get_bin_sid&domain=new&samaccountname=user_login\">http:\/\/ip_server\/get_data.php?action=get_bin_sid&domain=new&samaccountname=user_login<\/a><\/p>\n<\/blockquote>\n<p>возвращает SID в виде hex строки (потребуется для добавления в реестр)<\/p>\n<blockquote>\n<p>01,05,00,00,00,00,00,05,15,00,00,00,f6,4b,a9,84,8e,0d,2f,6a,25,71,0f,bd,a2,04,00,00<\/p>\n<\/blockquote>\n",
            "date_published": "2019-04-03T11:28:13+03:00",
            "date_modified": "2019-04-03T11:39:06+03:00",
            "tags": [
                "ActiveDirectory",
                "hex",
                "ldap",
                "php",
                "sid"
            ],
            "_date_published_rfc2822": "Wed, 03 Apr 2019 11:28:13 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "2",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": []
            }
        }
    ],
    "_e2_version": 4171,
    "_e2_ua_string": "Aegea 11.4 (v4171)"
}