I'm new to accessing Active Directory and I was advised to use System.DirectoryServices.AccountManagement
but I can't find the initials
variable any help ?
Asked
Active
Viewed 2,038 times
5

marc_s
- 732,580
- 175
- 1,330
- 1,459

Shehab Fawzy
- 7,148
- 1
- 25
- 18
1 Answers
11
You can do one of those things:
1) you can extend the normal UserPrincipal
class to include additional items that you frequently need. This would be the cleanest solution, really. See the MSDN docs on extending the user principal, or answer to this SO question for an example of how to extend the UserPrincipal
class with additional properties
2) You could just "reach down" into the depths of your underlying 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();
}
}
-
1thank you for the reply, I wish I could vote your answer up but I don't have enough reputation yet :( – Shehab Fawzy Dec 13 '11 at 06:59
-
@ShehabFawzy: thanks! That also gives you 2 extra reputation points :-) – marc_s Dec 13 '11 at 08:16