views:

50

answers:

2

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?

+1  A: 

In this case, you need to go one level deeper - back into the bowels of DirectoryEntry - by grabbing it from the user principal:

DirectoryEntry de = (myUser.GetUnderlyingObject() as DirectoryEntry);

if(de != null)
{
   // go for those attributes and do what you need to do
}
marc_s
Ill give it a try will let you know
Mondyak
This worked fine as a quick fix, but I am trying to avoid using Directory Entry. Thanks for the help
Mondyak
+2  A: 

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/

Raymund
+1 thanks for a very useful and helpful link!
marc_s