C# 如何访问GroupPrincipal对象上的notes字段

C# 如何访问GroupPrincipal对象上的notes字段,c#,active-directory,C#,Active Directory,我使用查询特定域中的所有安全组 PrincipalSearchResult<Principal> results = ps.FindAll(); 其中ps是一个主要的研究者 然后,我需要首先迭代将其转换为GroupPrincipal的结果,并在notes字段中找到包含特定字符串的结果 但是AD中的Notes字段显然不是GroupPrincipal类doh中的公共字段。 我做错了什么 更新: 我已经放弃了这一点。似乎没有办法访问那个讨厌的Notes字段。我一次又一次地回到这个挑战,但

我使用查询特定域中的所有安全组

PrincipalSearchResult<Principal> results = ps.FindAll();
其中ps是一个主要的研究者

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

但是AD中的Notes字段显然不是GroupPrincipal类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来拯救它

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

// 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来拯救它

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

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

我能够更改该字段

entryToUpdate.Properties[info].Clear; entryToUpdate.Properties[info]。在此处添加所需的文本


所以,感谢布拉德:

我能够改变这个领域

entryToUpdate.Properties[info].Clear; entryToUpdate.Properties[info]。在此处添加所需的文本

因此,感谢布拉德:

请尝试阅读此文章,以便更多地了解此处的问题/答案。你的贡献并没有回答这个问题。这更多的是一个评论,一旦你提高了你的声誉,你就可以添加它:请尝试阅读这篇文章,以便对这里的问题/答案有更多的了解。你的贡献并没有回答这个问题。这更多的是一种评论,一旦你提高了声誉,你可以添加: