Thursday, November 27, 2008

Reading Account Page Information for a User Account

Returns basic account information for the MyerKen Active Directory user account.

On Error Resume Next
Set objUser = GetObject _
  ("LDAP://cn=Myerken,ou=Management,dc=NA,dc=fabrikam,dc=com")
 
strUserPrincipalName = objUser.Get("userPrincipalName")
strSAMAccountName = objUser.Get("sAMAccountName")
strUserWorkstations = objUser.Get("userWorkstations")
 
Set objDomain = GetObject("LDAP://dc=NA,dc=fabrikam,dc=com")
strDC = objDomain.Get("dc")
 
WScript.echo "User Principal Name: " & strUserPrincipalName
WScript.echo "SAM Account Name: " & strSAMAccountName
WScript.echo "User Workstations: " & strUserWorkstations
WScript.echo "dc: " & strDC

This is a VB Script, this can be used by saving the file in .vbs file