' ------------------------------------------------------------------------- ' From the book Inside Active Directory, ISBN 0-201-61621-1 ' Copyright (C) 2002 by Addison-Wesley ' Script by Sakari Kouti (see http://www.kouti.com) ' You have a royalty-free right to use, modify, reproduce and distribute ' this script (and/or any modified version) in any way you find useful, ' provided that you agree that Addison-Wesley or Sakari Kouti has no ' warranty, obligations or liability for the script. If you modify ' the script, you must retain this copyright notice. ' ------------------------------------------------------------------------- Option Explicit Const E_ADS_PROPERTY_NOT_FOUND = &H8000500D Dim objDSE, objUser, varPropValue, arrPropValues, i Dim strLoginHours, strByte On Error Resume Next Set objDSE = GetObject("LDAP://rootDSE") Set objUser = GetObject("LDAP://CN=Guest,CN=Users," & _ objDSE.Get("defaultNamingContext")) WScript.Echo vbCrLf & "Properties for " & objUser.Name & vbCrLf WScript.Echo "AccountExpirationDate : " & _ objUser.AccountExpirationDate WScript.Echo "BadLoginCount : " & objUser.BadLoginCount WScript.Echo "Department : " & objUser.Department WScript.Echo "Description : " & objUser.Description WScript.Echo "Division : " & objUser.Division WScript.Echo "EmailAddress : " & objUser.EmailAddress WScript.Echo "EmployeeID : " & objUser.EmployeeID WScript.Echo "FaxNumber : " & objUser.FaxNumber WScript.Echo "FirstName : " & objUser.FirstName WScript.Echo "FullName : " & objUser.FullName WScript.Echo "HomeDirectory : " & objUser.HomeDirectory WScript.Echo "HomePage : " & objUser.HomePage WScript.Echo "Languages : " & objUser.Languages WScript.Echo "LastFailedLogin : " & objUser.LastFailedLogin WScript.Echo "LastLogin : " & objUser.LastLogin WScript.Echo "LastLogoff : " & objUser.LastLogoff WScript.Echo "LastName : " & objUser.LastName WScript.Echo "LoginScript : " & objUser.LoginScript WScript.Echo "Manager : " & objUser.Manager WScript.Echo "MaxStorage : " & objUser.MaxStorage WScript.Echo "NamePrefix : " & objUser.NamePrefix WScript.Echo "NameSuffix : " & objUser.NameSuffix WScript.Echo "OfficeLocations : " & objUser.OfficeLocations WScript.Echo "OtherName : " & objUser.OtherName WScript.Echo "PasswordLastChanged : " & _ objUser.PasswordLastChanged WScript.Echo "Picture : " & objUser.Picture WScript.Echo "PostalCodes : " & objUser.PostalCodes WScript.Echo "Profile : " & objUser.Profile WScript.Echo "TelephoneHome : " & objUser.TelephoneHome WScript.Echo "TelephoneMobile : " & objUser.TelephoneMobile WScript.Echo "TelephoneNumber : " & objUser.TelephoneNumber WScript.Echo "TelephonePager : " & objUser.TelephonePager WScript.Echo "Title : " & objUser.Title WScript.Echo "AccountDisabled : " & objUser.AccountDisabled WScript.Echo "IsAccountLocked : " & objUser.IsAccountLocked WScript.Echo "PasswordRequired : " & objUser.PasswordRequired WScript.Echo "Login Workstations:" Err = 0 arrPropValues = objUser.LoginWorkstations If Err = E_ADS_PROPERTY_NOT_FOUND Then WScript.Echo "All allowed" Else For Each varPropValue In arrPropValues WScript.Echo varPropValue Next End If WScript.Echo "Postal Addresses:" Err = 0 arrPropValues = objUser.PostalAddresses If Err = E_ADS_PROPERTY_NOT_FOUND Then WScript.Echo "" Else If VarType(arrPropValues) = vbString Then WScript.Echo arrPropValues Else For Each varPropValue In arrPropValues WScript.Echo varPropValue Next End If End If WScript.Echo "See Also:" Err = 0 arrPropValues = objUser.SeeAlso If VarType(arrPropValues) = vbEmpty Then WScript.Echo "" Else If VarType(arrPropValues) = vbString Then WScript.Echo arrPropValues Else For Each varPropValue In arrPropValues WScript.Echo varPropValue Next End If End If WScript.Echo "Login Hours:" Err = 0 arrPropValues = objUser.LoginHours If Err = E_ADS_PROPERTY_NOT_FOUND Then WScript.Echo "All times allowed" Else strLoginHours = "" 'We need to use the "B" versions of Len, Asc and Mid For i = 1 To LenB(arrPropValues) strByte = Hex(AscB(MidB(arrPropValues, i, 1))) 'The following insures two characters for every byte If Len(strByte) = 1 Then strByte = "0" & strByte strLoginHours = strLoginHours & " " & strByte Next WScript.Echo strLoginHours End If