Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting user's full name from AD using username

Status
Not open for further replies.

Vachaun22

Programmer
Oct 7, 2003
171
US
I'm having an issue getting the user's full name from AD using the logon name. I found this thread


but it's erroring out giving me the Object not found on server error.

I checked the ldap string passed to GetObject and it is:

LDAP://CN=username,CN=Users,DC=domain,DC=local

where username = my username and domain = the domain name. It seems correct, but I get this:

Error: There is no such object on the server.

Which doesn't make sense. Could someone give me any suggestions? Thanks in advance.
 
Is the account you're trying located in the Users OU?
LDAP://CN=username,CN=Users,DC=domain,DC=local

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Doh....

No, the account isn't in the Users OU. So that will completely backfire for me anyway because I won't know what OU the account exists in.

Back to square one now I guess.

I have a function that queries AD with the command:

Code:
"SELECT distinguishedName FROM 'LDAP://dc=domain,dc=local' " & _
        	"WHERE objectCategory='user' " & _
                "AND sAMAccountName='" & strUserName & "'"

Would the object returned here contain the full name?
 
You might try this

"SELECT cn, distinguishedName FROM 'LDAP://dc=domain,dc=local' " & _
"WHERE objectClass='user' " & _
"AND sAMAccountName='" & strUserName & "'"

and then just echo out the value for the "cn" field

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top