如何以編程方式對 AD OU 條目設置“列出內容”和“列出對象”權限? (How can I programmatically set "List Content" and "List Object" permissions on AD OU entries?)


問題描述

如何以編程方式對 AD OU 條目設置“列出內容”和“列出對象”權限? (How can I programmatically set "List Content" and "List Object" permissions on AD OU entries?)

I'd like to set List Content and List Object options for an AD (Active Directory, Windows Server 2008 R2) OU for a particular user group using C# (.NET 4.0).

I managed to set the gPOptions and gPLinkproperties according to Microsoft, but I did not find an example of how to set List Content and List Object. Setting the other two properties works as shown below:

[...]

byte[] binaryForm = new byte[ groupPrincipal.Sid.BinaryLength ];
groupPrincipal.Sid.GetBinaryForm( binaryForm, 0 );
IdentityReference identityReference =
    new SecurityIdentifier( binaryForm, 0 );
PropertyAccessRule propertyAccessRule =
    new PropertyAccessRule(
        identityReference,
        AccessControlType.Allow,
        PropertyAccess.Read,
        new Guid( "...value provided by MSDN link..." ) );
...
// ouEntry is of type DirectoryEntry
ouEntry.ObjectSecurity.AddAccessRule( propertyAccessRule );
ouEntry.CommitChanges();

...
// Same for gPLink with the corresponding GUID

Please ask if you need any more information.

‑‑‑‑‑

參考解法

方法 1:

List content and List object have to be set somewhat differently:

...
ActiveDirectoryAccessRule activeDirectoryAccessRule =
    new ActiveDirectoryAccessRule(
        identityReference,
        ActiveDirectoryRights.ListChildren | ActiveDirectoryRights.ListObject,
        AccessControlType.Allow,
        ActiveDirectorySecurityInheritance.None );
...

This ActiveDirectoryAccessRule has to be added to the corresponding DirectoryEntry as in the question above.

(by GorgseneggerGorgsenegger)

參考文件

  1. How can I programmatically set "List Content" and "List Object" permissions on AD OU entries? (CC BY‑SA 3.0/4.0)

#permissions #active-directory #C#






相關問題

SharePoint/WSS:修改“創建者”字段? (SharePoint/WSS: Modify "created by" field?)

從 MS Access 訪問 .mdb 文件中的後端表 (Accessing backend tables in .mdb files from MS Access)

如何以編程方式對 AD OU 條目設置“列出內容”和“列出對象”權限? (How can I programmatically set "List Content" and "List Object" permissions on AD OU entries?)

嘗試使用 C# 設置註冊表權限時出現 NullReferenceException (NullReferenceException when trying to set registry permissions with C#)

可執行腳本在 Linux 機器上獲得權限被拒絕 (Executable script gets permission denied on Linux box)

iOS Facebook 令牌權限生日 (iOS Facebook token Permissions birthday)

如何使 644 個權限文件可從 PHP 寫入? (How do I make 644 permission files writable from PHP?)

Android 6.0 中的權限更改回調 (Permission changed callback in Android 6.0)

LINQ和數據庫權限 (LINQ and Database Permissions)

多個用戶可以訪問/更新 Market 中的單個 Android 應用程序嗎? (Can multiple users access/update a single Android app in the Market?)

運行具有權限的 Eclipse 應用程序或小程序 (Running Eclipse aplication or applet with permissions)

通過 AirWatch 卸載 Android APK (Uninstall Android APK via AirWatch)







留言討論