Mondyak Mondyak - 1 month ago 16
C# Question

How to get Active Directory Attributes not represented by the UserPrincipal class

What I mean is that right now I am using System.DirectoryServices.AccountManagement and if I use UserPrincipal class I only see the Name, Middle Name, etc

so in my codes it like

UserPrincipal myUser = new UserPrincipal(pc);
myUser.Name = "aaaaaa";
myUser.SamAccountName = "aaaaaaa";
.
.
.
.
myUser.Save();


How would I see the attribute like mobile or info?

Answer

The proper way of doing it is by using PrincipalExtensions where you Extend the Principal you are after and use the methods ExtensionSet and ExtensionGet as explained here http://anyrest.wordpress.com/2010/10/14/how-to-use-ad-attributes-not-represented-in-userprincipal-groupprincipal-and-computerprincipal/