How to find user name in AD?

How to find user name in AD?

Post by Bjn Johans » Sat, 04 Oct 2003 17:14:45

Hi all,

Perhaps this is not a pure ADSI question, but I think that you ADSI pros can
help me out anyway.

We have a web based application on our intranet. In order to give our users
correct privileges our developers would like it to look into AD for
username. But all they can find is the common name which is not acceptable.

Any suggestions?

If you have any questions, plz post them here and I'll relay them to our

Thanks! :)


How to find user name in AD?

Post by Wei.Huan » Sat, 04 Oct 2003 22:39:51

if I am not wrong, username attribute in AD is sAMAccountname

this should resolve your problem.


How to find user name in AD?

Post by maxv » Sun, 05 Oct 2003 00:01:19

Wei is correct.

The CN is the display name for the user. The user logins in with their SamAccountName. So, if you have the SamAccountName you can locate the user in a
couple of ways:

1. Do an LDAP query searching for the matching SamAccoutName
2. Build WinNT ADsPath for the user,then use IADsNameTranslate to convert the WInNT path to its LDAP path.

Max Vaughn [MS]
Microsoft Developer Support

Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.