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?
In this case, you need to go one level deeper - back into the bowels of DirectoryEntry
- by grabbing it from the user principal:
using (DirectoryEntry de = myUser.GetUnderlyingObject() as DirectoryEntry) { if (de != null) { // Go for those attributes and do what you need to do... var mobile = de.Properties["mobile"].Value as string; var info = de.Properties["info"].Value as string; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With