首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何访问GroupPrincipal对象上的注释字段

如何访问GroupPrincipal对象上的注释字段
EN

Stack Overflow用户
提问于 2008-11-27 13:52:35
回答 4查看 3.1K关注 0票数 1

我使用以下命令查询特定域中的所有安全组

代码语言:javascript
复制
PrincipalSearchResult<Principal> results = ps.FindAll();

其中ps是PrincipalSearcher。

然后,我需要迭代结果(首先将其转换为GroupPrincipal ),并在注释字段中找到包含特定字符串的注释。

但是,来自AD的Notes字段显然不是GroupPrincipal类doh中的公共字段。我做错了什么?

更新:我已经放弃了这一点。似乎没有办法访问那个讨厌的备注字段。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2009-04-25 17:56:46

我一次又一次地回到这个挑战,但现在我终于放弃了。看起来这个属性确实是无法访问的。

票数 1
EN

Stack Overflow用户

发布于 2009-12-31 11:13:28

您可以访问目录条目的“备注”字段,如下所示:

代码语言:javascript
复制
// 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来救我吧!

票数 7
EN

Stack Overflow用户

发布于 2012-04-10 20:41:10

对于使用"info“属性的任何人:请注意,如果使用空字符串或空值,将抛出异常。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/323817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档