我使用以下命令查询特定域中的所有安全组
PrincipalSearchResult<Principal> results = ps.FindAll();其中ps是PrincipalSearcher。
然后,我需要迭代结果(首先将其转换为GroupPrincipal ),并在注释字段中找到包含特定字符串的注释。
但是,来自AD的Notes字段显然不是GroupPrincipal类doh中的公共字段。我做错了什么?
更新:我已经放弃了这一点。似乎没有办法访问那个讨厌的备注字段。
发布于 2009-04-25 17:56:46
我一次又一次地回到这个挑战,但现在我终于放弃了。看起来这个属性确实是无法访问的。
发布于 2009-12-31 11:13:28
您可以访问目录条目的“备注”字段,如下所示:
// 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来救我吧!
发布于 2012-04-10 20:41:10
对于使用"info“属性的任何人:请注意,如果使用空字符串或空值,将抛出异常。
https://stackoverflow.com/questions/323817
复制相似问题