-------------------------------------------------
Set objRootDSE = GetObject("LDAP://RootDSE")
If Err.Number = 0 Then
strNamingContext = objRootDSE.Get("defaultNamingContext")
WScript.Echo("Connected to:...... " & strNamingContext)
Else
WScript.Echo("Unable to connect to Active Directory." & vbCrLf &
"Exiting Script." & vbCrLf)
objShell.Popup line, 10, vbTab & "Logon Script", 48
objLogFile.Close
Wscript.Quit
End If
Set objADSysInfo = CreateObject("ADSystemInfo")
strUserDN = objADSysInfo.username
WScript.Echo("DN:................ " & strUserDN)
' Bind to user object
Set objUser = Getobject("LDAP://" & strUserDN)
WScript.Echo "UserID:............ " & objUser.Get("name")
WScript.Echo "First name:........ " & objUser.Get("givenName")
WScript.Echo "Initials:.......... " & objUser.Get("initials")
WScript.Echo "Last name:......... " & objUser.Get("sn")
WScript.Echo "Display name:...... " & objUser.Get("displayName")
WScript.Echo "Description:....... " & objUser.Get("description")
WScript.Echo "Office:............ " &
objUser.Get("physicalDeliveryOfficeName")
WScript.Echo "Telephone number:.. " & objUser.Get("telephoneNumber")
WScript.Echo "E-Mail:............ " & objUser.Get("mail")
-------------------------------------------------
If you get any errors about information not found in the cache just
delete/comment out the line that is giving the error. Some companies
don't store information in all of the fields.
-= j@ckle =-
If you want to specify the username, I will have to modify. Don't have
time right now...I post modified code later today.