0

同じ実行でGrantGenericReadオブジェクトを作成するときに機能する関数があります。$ouUnixGroups実行できるADからオブジェクトを取得する方法をGrantGenericRead見つけようとしていますが、私が知っているすべての方法(adsi、.Pathを使用したルックアップ)を試してみると、いくつかのプロパティにアクセスできないようです設定するオブジェクト。私が間違っていることを誰かに教えてもらいたいです。

このコードは、すべて同時に実行すると機能します。

function CreateADGroup([string] $server, [string] $name, [string] $container, [string] $gtype)
{
    $objClass = "group";
    $strCn = GetCn -name $name -objClass $objClass;
    $objDsGroup  = CreateDsObject -server $server -container $container -name $name -objClass $objClass 
    [Void] $objDsGroup.Put("sAMAccountName", $name)
    if ($gtype -eq "global")
    {
        # Global Distribution Group 
        [Void] $objDsGroup.Put("groupType", 0x80000002)
    }
    elseif ($gtype -eq "dlg")
    {
        # Domain Local Distribution Group  
        [Void] $objDsGroup.Put("groupType", 0x80000004)
    }
    elseif ($gtype -eq "uni")
    {
        # Universal Security Group 
        [Void] $objDsGroup.Put("groupType", 0x80000008)
    }
    else
    {
        Write-Host("Invalid group type {0}" -f $gtype)
    }
    [Void]$objDsGroup.SetInfo()
    return $objDsGroup
}

function CreateDsObject([string] $server, [string] $container, [string] $name, [string] $objClass)
{
$strConatinerPath = GetLdapPath -server $server -dn $container
$objContainer = [adsi] $strConatinerPath
$strChildCn = GetCn -name $name -objClass $objClass
$strChildDn = "{0},{1}" -f $strChildCn, $container
$strChildPath = GetLdapPath -server $server -dn $strChildDn
$objChildEntry = $objContainer.Create($objClass, $strChildCn)
[Void]$objChildEntry.SetInfo()
    return $objChildEntry
}

function GrantGenericRead($dsTrustee, $dsResources)
{
    $strSid = GetSid -dsObj $dsTrustee
    $objSid = New-Object Security.Principal.SecurityIdentifier($strSid)
    $ace = New-Object DirectoryServices.ActiveDirectoryAccessRule($objSid, $AD_RIGHT::GenericRead, $AC_TYPE::Allow)
    [Void] $dsResources.psbase.ObjectSecurity.AddAccessRule($ace)
    [Void] $dsResources.psbase.CommitChanges()
}

function GetSid($dsObj)
{
    $dn = $dsObj.distinguishedName.Value
    $binary = $dsObj.psbase.Properties["objectSid"].Value
    $sid = New-Object Security.Principal.SecurityIdentifier($binary, 0)
    return $sid.ToString()
}

$adminContainerDn = "OU=Zone Administration,{0}" -f   $adminContainer.Get("distinguishedName") #returns OU=Zone Administration,OU=asdfasdf,DC=baldur,DC=vm
$ouUnixGroups   = CreateDsObject -server $server -container $ouDN -name $strOuUnixGroups   -objClass "OrganizationalUnit"
$joinOps = CreateADGroup -server $server -name "Join Operators" -container $adminContainerDn -gtype "global"

GrantGenericRead -dsTrustee $joinOps -dsResources $ouUnixGroups

私が達成しようとしているのは、それらを作成しないスクリプトから変更できるようにする$joinOpsこと$ouUnixGroupsです。それらにアクセスするにはどうすればよいですか? 私はsidを取得できますが、ここで本当に重要なものが欠けていない限り、それは役に立たないようです.

GrantGenericRead -dsTrustee $joinOps -dsResources [adsi]$ouUnixGroups.Path

http://pastebin.com/uF3nrDuwに投稿したインストーラー スクリプトからこれらの行の一部を抜き出しています。あなた

4

1 に答える 1

1

あなたはただ試すことができます:

GrantGenericRead -dsTrustee [adsi]"cn=Agroup,ou=AnOU,dc=dompn,dc=domp0" -dsResources [adsi]"ou=theUnixOU,ou=AnOtherOU,dc=dompn,dc=domp0"
于 2012-04-05T07:15:20.157 に答える