如何使用 PowerShell 设置或清除“经理可以更新成员资格列表”

如何使用 PowerShell 设置或清除“经理可以更新成员资格列表”

对于分发组,我可以设置参数经理可以更新会员名单使用 ADUC mmc,但我找不到如何使用 PowerShell 执行此操作。此外,即使是经理可以更新会员名单在 Get-QADGroup 的 PowerShell 列表中,在 ADUC 中设置了属性经理可以更新会员名单属性仍然设置为错误的

答案1

在 AD 2003 环境中,这是一个两步过程:

添加 QADPermission-身份-帐户-权限 WriteProperty-属性“成员”-ApplyTo‘ThisObjectOnly’

设置 QADGroup -ManagedBy

第一个命令将设置必要的权限并可正常运行,但如果 ADUC 中的“管理者”文件中尚未指定用户帐户,则该字段将保持空白,并且不会选中该框。第二个命令填充了此字段,当两个条件都满足时,将选中该框。

请记住,在没有 Active Roles Server 的 AD 环境中,Group 属性中的 ManagerCanUpdateMembershipList 字段仍将显示为 FALSE。该字段显然是 Active Roles Server 的专有字段。

答案2

下面是一些实现该功能的代码:

 <#
.Synopsis
   Sets manager property on AD group and grants change membership rights.
.DESCRIPTION
   Sets manager property on AD group and grants change membership rights.
   This is done by manipulating properties directly on the DirectoryEntry object
   obtained with ADSI. This sets the managedBy property and adds an ACE to the DACL
   allowing said manager to modify group membership.
.EXAMPLE
   Set-GroupManager -ManagerDN "CN=some manager,OU=All Users,DC=Initech,DC=com" -GroupDN "CN=TPS Reports Dir,OU=All Groups,DC=Initech,DC=com"
.EXAMPLE
   (Get-AdGroup -Filter {Name -like "sharehost - *"}).DistinguishedName | % {Set-GroupManager "CN=some manager,OU=All Users,DC=Initech,DC=com" $_}
#>
function Set-GroupManager {
    param (
        [Parameter(Mandatory=$true, ValueFromPipeline=$false, ValueFromPipelinebyPropertyName=$True, Position=0)]
        [string]$ManagerDN,
        [Parameter(Mandatory=$true, ValueFromPipeline=$false, ValueFromPipelinebyPropertyName=$True, Position=1)]
        [string]$GroupDN
        )
    
    try {
        Import-Module ActiveDirectory -NoClobber

        $mgr = [ADSI]"LDAP://$ManagerDN";
        $identityRef = (Get-ADUser -Filter {DistinguishedName -like $ManagerDN}).SID.Value
        $sid = New-Object System.Security.Principal.SecurityIdentifier ($identityRef);

        $adRule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule ($sid, [System.DirectoryServices.ActiveDirectoryRights]::WriteProperty, [System.Security.AccessControl.AccessControlType]::Allow, [Guid]"bf9679c0-0de6-11d0-a285-00aa003049e2");

        $grp = [ADSI]"LDAP://$GroupDN";

        $grp.InvokeSet("managedBy", @("$ManagerDN"));
        $grp.CommitChanges();

        # Taken from here: http://blogs.msdn.com/b/dsadsi/archive/2013/07/09/setting-active-directory-object-permissions-using-powershell-and-system-directoryservices.aspx
        [System.DirectoryServices.DirectoryEntryConfiguration]$SecOptions = $grp.get_Options();
        $SecOptions.SecurityMasks = [System.DirectoryServices.SecurityMasks]'Dacl'
                
        $grp.get_ObjectSecurity().AddAccessRule($adRule);
        $grp.CommitChanges();
    }
    catch {
        throw
    }
}

可以找到这里

答案3

您的问题引起了我的兴趣,我使用谷歌来寻找答案...我没有使用过 PoSh 的 Quest cmdlet 的经验。

New-QADGroup 的描述表明使用 ManagerCanUpdateMembershipList 参数需要连接到 ActiveRoles 服务器

相关内容