Velichkoff
Velichkoff

Reputation: 56

Can I add Active Directory properties to be loaded in UserPrincipal?

Using the DirectorySearcher we can specify which properties can be loaded when searching in the AD.

    DirectorySearcher dsLookForDomain = new DirectorySearcher(deBase);
    dsLookForDomain.PropertiesToLoad.Add("msDS-PrincipalName"); 

I'm interested in loading msDS-PrincipalName property. Is this possible?

Upvotes: 1

Views: 238

Answers (1)

Velichkoff
Velichkoff

Reputation: 56

I'm not sure if this is going to help anynone but I found an alternative to the msDS-PrincipalName.

    userPrincipal.Sid.Translate(typeof (NTAccount)).ToString()

This will return the same thing the property mentioned above does which is: DOMAIN\Username

Upvotes: 1

Related Questions