我使用查询特定域中的所有安全组
PrincipalSearchResultresults = ps.FindAll();
其中ps是PrincipalSearcher.
然后我需要迭代结果(首先将其转换为GroupPrincipal)并在notes字段中找到包含特定字符串的结果.
但AD中的Notes字段显然不是GroupPrincipal类中的公共字段,doh.我究竟做错了什么 ?
更新:我放弃了这个.似乎没有办法访问那个讨厌的Notes字段.
您可以访问目录条目的"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();
采取了一点点狩猎 - 我曾经认为音符属性确实被称为'音符',ADSIEdit来救援!