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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using user login name to find fullname in Active Directory

Status
Not open for further replies.

gargon1

IS-IT--Management
Jan 24, 2003
15
0
0
VI
Hi,
Can someone tell me how to retrieve a users fullname from Active Directory using their login name or samAccountName?
Am using vb script.
Thanks in advance.

Dalma
 
Set oNetwork = CreateObject("WScript.Network")
sDomain = oNetwork.UserDomain
sUser = oNetwork.UserName

If you're using NT, use

sADSPath= sDomain & "/" & sUser
Set oUser = GetObject("WinNT://" & sADSPath & ",user")
WScript.Echo oUser.FullName

If you're using Win2K, use

Set oRootDSE = GetObject("LDAP://RootDSE")
sDomain = oRootDSE.Get("defaultNamingContext")
Set oUser = GetObject("LDAP://CN=" & sUser & ",CN=Users," & sDomain)
WScript.Echo oUser.DisplayName Jon Hawkins
 
Where can i see all the available properties for both the nt4 version of ad and 2k??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top