{"id":136,"date":"2010-04-29T16:07:33","date_gmt":"2010-04-29T14:07:33","guid":{"rendered":"http:\/\/www.maxx.net.ua\/?p=136"},"modified":"2010-04-29T16:07:33","modified_gmt":"2010-04-29T14:07:33","slug":"%d1%81%d0%b8%d0%bd%d1%85%d1%80%d0%be%d0%bd%d0%b8%d0%b7%d0%b0%d1%86%d0%b8%d1%8f-%d0%b3%d1%80%d1%83%d0%bf%d0%bf-%d0%b2-active-directory","status":"publish","type":"post","link":"https:\/\/www.maxx.net.ua\/?p=136","title":{"rendered":"\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u0440\u0443\u043f\u043f \u0432 Active Directory"},"content":{"rendered":"<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c 2 \u0433\u0440\u0443\u043f\u043f\u044b \u0432 Active Directiory \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u043e\u043c, \u0447\u0442\u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0434\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u043b\u043e \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b. \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438 \u0442\u0443\u0442 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f <a href=\"http:\/\/www.quest.com\/powershell\/activeroles-server.aspx\" target=\"_blank\">ActiveRoles Management Shell for Active Directory<\/a> \u043e\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 <strong>Quest Software<\/strong>. \u0410 \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c:<\/p>\n<p>Add-PSSnapin Quest.ActiveRoles.ADManagement<br \/>\n$in = (get-qadgroup &#8216;tstgroupin&#8217;).dn<br \/>\n$out = (get-qadgroup &#8216;tstgroupout&#8217;).dn<br \/>\n$ingroupmembers = get-qadgroupmember $in<br \/>\n$outgroupmembers = get-qadgroupmember $out<br \/>\n$rez = compare-object $ingroupmembers $outgroupmembers<br \/>\nforeach($item in $rez){<br \/>\n    if ($item.SideIndicator -eq &#8220;&lt;=&#8221;){<br \/>\n      $usrdn = (get-qaduser $item.InputObject).dn<br \/>\n      if ($userdn -ne $null){add-qadgroupmember $out -Member $usrdn}<br \/>\n    }<br \/>\n    if ($item.SideIndicator -eq &#8220;=&gt;&#8221;){<br \/>\n        $usrdn = (get-qaduser $item.InputObject).dn<br \/>\n        if ($userdn -ne $null){remove-qadgroupmember $out -Member $usrdn}<br \/>\n    } \ufffd<br \/>\n}<\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0433\u0440\u0443\u043f\u043f\u044b tstgroupout \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0441\u043e\u0441\u0442\u0430\u0432\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0433\u0440\u0443\u043f\u043f\u044b tstgroupin. \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0445, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 (\u0445\u043e\u0442\u044c \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435) \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0430 \u0432 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434 &#8220;\u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0445&#8221; \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u0448\u043d\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0430 \u0432 \u0433\u0440\u0443\u043f\u043f\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e\u0439.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 <strong>Quest Software. <\/strong>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>function get-groupdn ($SAMName)<br \/>\n{<br \/>\n        $root = [ADSI]&#8221;<br \/>\n        $searcher = new-object System.DirectoryServices.DirectorySearcher($root)<br \/>\n        $searcher.filter = &#8220;(&amp;(objectClass=group)(sAMAccountName= $SAMName))&#8221;<br \/>\n        $user = $searcher.findall(<br \/>\n        if ($user.count -gt 1)<br \/>\n        {<br \/>\n            $count = 0<br \/>\n            foreach($i in $user)<br \/>\n            {<br \/>\n                  write-host $count &#8220;: &#8221; $i.path<br \/>\n                  $count = $count + 1<br \/>\n            }<br \/>\n            $selection = Read-Host &#8220;Please select item: &#8221;<br \/>\n            return $user[$selection].path<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            return $user[0].path<br \/>\n        }<br \/>\n}<\/p>\n<p>function get-userdn ($SAMName)<br \/>\n{<br \/>\n        $root = [ADSI]&#8221;<br \/>\n        $searcher = new-object     System.DirectoryServices.DirectorySearcher($root)<br \/>\n        $searcher.filter = &#8220;(&amp;(objectClass=user)(sAMAccountName= $SAMName))&#8221;<br \/>\n        $user = $searcher.findall(<br \/>\n        if ($user.count -gt 1)<br \/>\n        {<br \/>\n            $count = 0<br \/>\n            foreach($i in $user)<br \/>\n            {<br \/>\n                  write-host $count &#8220;: &#8221; $i.path<br \/>\n                  $count = $count + 1<br \/>\n            }<br \/>\n            $selection = Read-Host &#8220;Please select item: &#8221;<br \/>\n            return $user[$selection].path<br \/>\n        }<br \/>\n         else<br \/>\n        {<br \/>\n            return $user[0].path<br \/>\n        }<br \/>\n}<\/p>\n<p>$ingroup = get-groupdn &#8216;tstgroupin&#8217;<br \/>\n$outgroup = get-groupdn &#8216;tstgroupout&#8217;<br \/>\nif ($ingroup -ne $null){<br \/>\n    $GroupLDAPin = [adsi]$ingroup<br \/>\n}<br \/>\nif ($outgroup -ne $null){<br \/>\n    $GroupLDAPout = [adsi]$outgroup<br \/>\n}<br \/>\nif (($GroupLDAPout -ne $null) -and ($GroupLDAPin -ne $null)){<br \/>\n    $rez = compare-object $GroupLDAPin.member $GroupLDAPout.member<br \/>\n    foreach($item in $rez){<br \/>\n    if ($item.SideIndicator -eq &#8220;&lt;=&#8221;){<br \/>\n        write-host &#8220;LDAP:\/\/&#8221; + [string]$item.InputObject<br \/>\n        $GroupLDAPout.Add(&#8220;LDAP:\/\/&#8221;+$item.InputObject)<br \/>\n    }<br \/>\n    if ($item.SideIndicator -eq &#8220;=&gt;&#8221;){<br \/>\n        write-host &#8220;LDAP:\/\/&#8221; + [string]$item.InputObject<br \/>\n        $GroupLDAPout.Remove(&#8220;LDAP:\/\/&#8221;+$item.InputObject)<br \/>\n    }<br \/>\n    }<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c 2 \u0433\u0440\u0443\u043f\u043f\u044b \u0432 Active Directiory \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u043e\u043c, \u0447\u0442\u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0434\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u043b\u043e \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b. \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438 \u0442\u0443\u0442 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f ActiveRoles Management Shell for Active Directory \u043e\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Quest Software. \u0410 \u0437\u0430\u0442\u0435\u043c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,12],"tags":[],"_links":{"self":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/136"}],"collection":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=136"}],"version-history":[{"count":0,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/136\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.maxx.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}