views:

170

answers:

2

Apologies for not knowing the right way to phrase this question.

Given a domain name and an alias, for example CONTOSO\steveh how can I get the friendly display name for that alias? For example, in Outlook email sent to CONTOSO\steveh appears as 'Steve Holt'?

A: 

You can query ActiveDirectory through LDAP I recommend taking a look at this question which has some basic information. You should be able to get a general direction from there.

Quintin Robinson
+3  A: 

If you are using .net 3.5, add references to System.DirectoryServices and System.DirectoryServices.AccountManagement and try this:

        PrincipalContext c = new PrincipalContext(ContextType.Domain,"CONTOSO");
        UserPrincipal principal = UserPrincipal.FindByIdentity(c,"steveh");
        Console.WriteLine(principal.DisplayName);

I can't verify if it works for a domain since I'm running on a standalone machine but it should help you get started.

Abhijeet Patel
It works fine for domains as well (just tried out your code sample).
Fredrik Mörk