我使用
查询特定域中的所有安全组PrincipalSearchResult<Principal> results = ps.FindAll();
其中 ps 是 PrincipalSearcher。
然后我需要迭代结果(首先将其转换为 GroupPrincipal)并在注释字段中找到包含特定字符串的结果。
但是 AD 中的 Notes 字段显然不是 GroupPrincipal 类中的公共(public)字段,doh。 我做错了什么?
更新: 我已经放弃了这个。似乎无法访问那个讨厌的 Notes 字段。
最佳答案
您可以这样访问目录条目的“注释”字段:
// Get the underlying directory entry from the principal
System.DirectoryServices.DirectoryEntry UnderlyingDirectoryObject =
PrincipalInstance.GetUnderlyingObject() as System.DirectoryServices.DirectoryEntry;
// Read the content of the 'notes' property (It's actually called info in the AD schema)
string NotesPropertyContent = UnderlyingDirectoryObject.Properties["info"].Value;
// Set the content of the 'notes' field (It's actually called info in the AD schema)
UnderlyingDirectoryObject.Properties["info"].Value = "Some Text"
// Commit changes to the directory entry
UserDirectoryEntry.CommitChanges();
进行了一些搜索 - 我假设 notes 属性确实被称为“notes”,ADSIEdit 来拯救!
关于c# - 如何访问 GroupPrincipal 对象上的备注字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/323817/