How to access the notes field on a GroupPrincipal object

后端 未结 4 491
无人共我
无人共我 2021-01-24 21:47

I query all security groups in a specific domain using

PrincipalSearchResult results = ps.FindAll();

where ps is a PrincipalS

相关标签:
4条回答
  • 2021-01-24 21:57

    You can access the 'notes' field of a directory entry as such:

    // 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();
    

    Took a little bit of hunting - I had assumed the notes property was indeed called 'notes', ADSIEdit to the rescue!

    0 讨论(0)
  • 2021-01-24 22:00

    i was able to change that field.

    entryToUpdate.Properties["info"].Clear(); entryToUpdate.Properties["info"].Add("some text you want here");

    So thanks Brad :)

    0 讨论(0)
  • 2021-01-24 22:14

    I have been returning to this challange over and over again, but now I have finally given up. It sure looks like that property is inaccessible.

    0 讨论(0)
  • 2021-01-24 22:16

    For anybody using the "info" attribute:note that it will throw an exception if using an empty string or null value.

    0 讨论(0)
提交回复
热议问题