Getting display name from domain \ alias combo

Sorry for not knowing the correct way to phrase this question.

Given the domain name and alias like CONTOSO \ steveh, how can I get a friendly display name for this alias? For example, does an Outlook email sent to CONTOSO \ steveh appear as "Steve Holt"?

+2


source to share


2 answers


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 check if it works for the domain as I am working on a standalone machine, but it should get you started.

+6


source


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



0


source







All Articles