Access the initialization field using DirectoryServices.AccountManagement

I am new to accessing Active Directory and I have been advised to use System.DirectoryServices.AccountManagement , but I can not find the initials variable any help?

+4
source share
1 answer

You can do one of the following things:

1) you can extend the normal UserPrincipal class to include additional elements that you often need. In fact, this would be the cleanest solution. See MSDN docs for extending a user principal, or answer this SO question for an example of how to extend a UserPrincipal class with additional properties

2) You could just "go down" into the depths of your base DirectoryEntry and grab the data from there:

  DirectoryEntry de = YourUserPrincipal.GetUnderlyingObject() as DirectoryEntry; if(de != null) { var initials = de.Properties["initials"]; if(initials != null && initials.Count > 0) { string theInitials = de.Properties["initials"][0].ToString(); } } 
+9
source

Source: https://habr.com/ru/post/1385868/


All Articles