Question

VBScript Get Active Directory User Information

Asked by: ivanoviola

Hi Experts,

I have made some changes to the following script. I am having troubles adding support for nested groups. The script only shows the groups the user is a member of in AD. Can some help me add support for nested groups as well?

Thanks

' Get Active Directory User Information
' Version 2003
' Created May 2003 by Ralph Montgomery - Firsthealth of the Carolinas (rmonty@myself.com)
' May be freely distributed to give back to the scripting community, please acknowledge
' the work where you can. I would appreciate it. Many items here were culled from MSDN, newsgroups
' the Windows 2000 Scripting Guide from MS and just many hours of work. If you recognize a routine
' that I have not acknowledged, please let me know and I will fix it for ya.
' Revision history:
'    Initial rollout after debugging and documentation 06-11-2003
'    09/21/03 Added HTML display alternative
'         Added display of last logged in workstation from SMS
'    11/11/03 fixed password expiry info so display correctly
'
' Caveats: The Terminal Service information can only be pulled by a WinXp workstation with the
'    Active Directory Users and Computers MMC console from a Server 2003 CD. Sorry, MS wants it
'    that way I guess. Otherwise it will always be no.
'
' Usage: ADUser <CR>
 
'Must do: Either add your SMS site server and SMS site Name under the Const or
'     remark out the calling line: FindMachineByUser(strGetUserName)
 
' Constants
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_UF_PASSWD_NOTREQD = &h00020
Const ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = &h0080
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Const ADS_UF_PASSWORD_EXPIRED = &h80000
Const ADS_UF_PASSWD_CANT_CHANGE = &h0040
Const CHANGE_PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}"
Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const SEC_IN_MIN = 60
Const SEC_IN_DAY = 86400
Const MIN_IN_DAY = 1440
Const ADS_SCOPE_SUBTREE = 2
 
'Must do: Either add your SMS site server and SMS site Name under this Const or
'     remark out the calling line: FindMachineByUser(strGetUserName)
Const cSMSmachine = "sms-ss-mrh" ' name of system where SMS lives
Const cSMSsite = "FHC" ' name of SMS site
 
'*********************Initialize the variable farm in one spot*******************************************
Public strGetUserName
Dim objUserName, objUserDomain, objGroup, objUser, strGroupList, WshShell, strMessage, strTitle, dtStart
Dim objDomain, strDomain, strUserName, strOS, strVer, strSortedGroups, arrMemberOf, strUserList, strCheckName
Dim strMsgNoUser, strUserMail, strExchange, sQ, strNoDomain, blnIsActive, strCN, strOU, strRootDSE
 
Dim objChangePwdTrue, objChangePwd, objUserProfile, objNet, strIsAccountLocked, strMailNickname, strRetry
Dim objPwdExpiresTrue, objFlags, oPwdExpire , dtmPwdLastChanged, strUserName2, strValueList, major, minor, ver
Dim objAcctDisabled, intPwdExpired, objPwdExpiredTrue, strTSProfile, strDisplayDelegates
 
Dim strGivenName, strInitials, strSn, strDisplayName, strPhysDelOfficeName, strTelephoneNumber, strGetUserNam
Dim strMail, strWwwHomePage, intUAC, intBadPwd,    strNetworkAddress, strAllowDialin, dtmLastLogin, strLogonName
Dim strWhenCreated,    strWhenChanged,    strPwdExpires, strValue, strUserMustChgPwd, strPwdNeverExpires, strPwdLastChanged
Dim strPwdExpired, strPwdAge, strAccountDisabled, strDisplayDescription, strDisplayOtherTelephone, strDisplayUrl
Dim strOtherTelephone, strUrl, strPwdCanChange, strPwdMinLength, strDisplayDepartment, strAccountExpires
 
Dim strTSHomeDir, strTSHomeDrive, strTSProfilePath, strTSConnectPrinters, strTSConnectDrives, strTSDefaultToMainPrinter
Dim strTSInitialProgram, strTSWorkingDir, strTSEnableRemoteControl, strTSBrokenConnAction, strTSMaxConnectTime
Dim strTSMaxDisconnectionTime, strTSMaxIdleTime, strTSReconnectionAction, strTSAllowLogon
 
Dim intMaxPwdAge, intMaxPwdAgeSeconds, intMinPwdAgeSeconds, intLockOutObservationWindowSeconds, blnChangePwdEnabled
Dim intLockoutDurationSeconds, intUserFlags,intMinPwdLength, intPwdHistoryLength, intPwdProperties, intLockoutThreshold
Dim    intMaxPwdAgeDays, intMinPwdAgeDays, intLockOutObservationWindowMinutes, intLockoutDurationMinutes
 
Dim strProfilePath, strScriptPath, strHomeDirectory, strHomeDrive, blnMsNPAllowDialin, strVPNAllow, strDLList, strSortedDLList
Dim ldapconnectstring, Ouser, strSearch, strDN, dtmNextFailedLogin, dtmLastFailedLogin, strPwdRequired
Dim arrDC(), intSize, strLastLoggedInWorkstation, objDocument, strPwdBGColor, strAcctBGColor, strLoginsBGColor, strMsgDisplay
Dim strPwdExpBGColor, strDelegateCount
Dim strMostRecentIP
 
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNet = WScript.CreateObject("WScript.Network")' create network object for vars
Set objRootDSE = GetObject("LDAP://rootDSE")' bind to the rootDSE for portability
 
strADsConfPath = "LDAP://" & objRootDSE.Get("configurationNamingContext")' bind to configuration to get Domain Controllers later
strRootDSE = objRootDSE.Get("defaultNamingContext")' bind to the defaultContext for portability
strVer = "Ver 2003"' vanity
sQ = Chr(34)
strDomain = UCase(objNet.UserDomain)' pull user domain from environment variable
strUserName = UCase(objNet.UserName)' pull user name from environment variable
strOS = WshShell.ExpandEnvironmentStrings("%OS%")' pull OS from environment variable to use for other subs...
intSize = 0
strDelegateCount = 0
 
'SysTest() ' sub routine to check for Script Version/ADSI installed
GetUserName()' sub routine to get input for userID (sAMAccountName)
 
' this section added by John Ciccantelli
While strDN=""
  CheckForUser()' sub routine to check for user Existance & bind to if found
  If strDN = "" Then
    ReCheckUser()
  End If
Wend
' end of section added by John C.
GetUserAccount(strDN)
GetLastLogon()' sub routine to get absolute last login date from all Domain Controllers dynamically
' You must remark this next line out if NOT using SMS!!!!!!
' FindMachineByUser(strGetUserName) ' sub routine to query SMS for the last workstation logged into - remark out if not using SMS!
 
'strMsgDisplay = "To Display/Print Account information in" & vbCrLf & " Internet Explorer, press Yes, else press No"
'rtn = MsgBox(strMsgDisplay,vbYesNo,"Use HTML display output?")
'If rtn = 7 Then
'DisplayUser()' sub routine to Display gathered user Information in a popup box
'Elseif rtn = 6 Then
DisplayUserIE()' sub routine to Display gathered user Information in an Internet Explorer Window
'Else
'WScript.quit
'End if
 
'********************* Initial and only dialog box necessary *****************************
'********************* Looks for the sAMAccountName to bind to *****************************
Sub GetUserName()
  strMessage = "Enter the User Login ID to search." & vbCrLf & vbCrLf
  ' "Default is: " & strUserName & vbCrLf & vbCrLf
  strMessage = strMessage & "You may also search for a user by first or last name. "
  strMessage = strMessage & "(Searching will take a little bit longer)" & vbCrLf & vbCrLf & "or click Cancel to quit"
  strTitle = "USER Login ID"
  
  'get resource domain name, domain default via input box
  strGetUserName= UCase(InputBox(strMessage, strTitle, strUserName))
  
  ' Evaluate the user input.
  If strGetUserName = "" Then
    Cancelled()
  ElseIf Len(strGetUserName) < 1 Then
    strMessage = "Input name less than 1 character! Please Input at least 1!"
    strGetUserName= UCase(InputBox(strMessage, strTitle, strUserName))
  Else
    strGetUserName = strGetUserName
  End If
  
End Sub 'GetUserName
 
'********************* 'Attempt to bind to the sAMAccount Name provided search if not***************************
Sub CheckForUser()
  Set objConnection = CreateObject("ADODB.Connection")
  objConnection.Provider = ("ADsDSOObject")
  objConnection.Open
  
  Set objCommand = CreateObject("ADODB.Command")
  
  objCommand.ActiveConnection = objConnection
  
  objCommand.CommandText = _
  "<LDAP://" & strRootDSE & ">;(&(objectCategory=User)" & _
  "(samAccountName=" & strGetUserName & "));distinguishedName,sAMAccountName,name;subtree"
  
  Set objRecordSet = objCommand.Execute
  
  If objRecordset.RecordCount = 0 Then
    dtStart = TimeValue(Now())
    strMessage = "Login ID: " & strGetUserName & " not found: " & vbCrLf & "This may take a few seconds. . ."
    WshShell.Popup strMessage,2,"Searching . . ."
    strMessage = ""
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  Else
    strDN = objRecordset.Fields("distinguishedName")
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  End If
  
End Sub ' CheckForUser
 
Sub Check4User()
  Set objConnection = CreateObject("ADODB.Connection")
  objConnection.Provider = ("ADsDSOObject")
  objConnection.Open
  
  Set objCommand = CreateObject("ADODB.Command")
  
  objCommand.ActiveConnection = objConnection
  
  objCommand.CommandText = _
  "<LDAP://" & strRootDSE & ">;(&(anr=" & strGetUserName & ")(|(objectCategory=organizationalPerson)(objectCategory=group)));ADsPath,name,distinguishedName,displayName,objectCategory;subtree"
  
  objCommand.Properties("Page Size") = 64
  objCommand.Properties("Timeout") = 30 'seconds
  
  Set objRecordSet = objCommand.Execute
  
  If objRecordset.RecordCount <> 1 Then
    dtStart = TimeValue(Now())
    strMessage = "Name not found: " & strGetUserName & vbCrLf & "This may take a few seconds. . ."
    WshShell.Popup strMessage,2,"Searching . . ."
    strMessage = ""
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  Else
    strDN = objRecordset.Fields("distinguishedName")
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  End If
  
End Sub ' Check4User
 
'********************* Recheck for user - uses Display name as the search key *****************************
Sub ReCheckUser()
  
  ldapconnectstring = "<LDAP://" & strRootDSE & ">"
  Set objConnection = CreateObject("ADODB.Connection")
  objConnection.Provider = "ADsDSOObject"
  objConnection.Open
  
  'strSearch = ldapconnectstring & ";(&(objectCategory=User)(CN=" & strGetUserName & "*));adspath;subtree"
  strSearch = ldapconnectstring & ";(&(anr=" & strGetUserName & ")(|(objectCategory=organizationalPerson)(objectCategory=group)));ADsPath,name,distinguishedName,displayName,objectCategory;subtree"
  Set objRecordSet = objConnection.Execute(strSearch)
  
  Do While Not objRecordset.EOF
    Set oUser = GetObject(objRecordSet("adspath"))
    strUserList = (strUserList & " " & oUser.givenName & " " & ouser.SN) & " - " & Mid(Replace(oUser.Name, "\,",","), 4) & vbCrLf
    If Err < 0 Then
      MsgBox "Error Occurred"
    End If
    objRecordSet.MoveNext
  Loop
  
  strMsgNoUser = "Your search found the following User Login IDs: " & vbCrLf & vbCrLf & strUserList & vbCrLf & _
  "Search completed in " & Second(TimeValue(Now()) - dtStart) & " second(s) or less." & vbCrLf & vbCrLf & _
  "Enter the User Login ID below, or cancel to exit"
  
  strRetry = InputBox(strMsgNoUser,"Search Reults . . .", strGetUserName)
  strUserList = ""
  strMsgNoUser = ""
  If strRetry = "" Then
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
    Cancelled()
  Else
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
    strGetUserName = strRetry
  End If
  strGetUserName = strRetry
End Sub ' ReCheckUser
 
'********************* 'Get Selected User Account Information *****************************
Sub GetUserAccount(strDN)
  On Error Resume Next
  If InStr(1,strDN,"/") Then strDN=Replace(strDN,"/","\/")
  Set objDomainNT = GetObject("WinNT://" & strDomain & "")    ' Use NT Provider for Domain Policy items
  Set objUser = GetObject("LDAP://" & strDN & "")                ' LDAP for User Info
  Set objAdS = GetObject("LDAP://" & strRootDSE & "")            ' LDAP for AD domain items
  
  With objDomainNT
    intMaxPwdAge =                             .Get("MaxPasswordAge")    'get NT value for MaxPasswordAge
    intMaxPwdAge =                             (intMaxPwdAge/SEC_IN_DAY) ' maximum password age in days
    intMaxPwdAgeSeconds =                     .Get("MaxPasswordAge")
    intMinPwdAgeSeconds =                     .Get("MinPasswordAge")
    intLockOutObservationWindowSeconds =     .Get("LockoutObservationInterval")
    intLockoutDurationSeconds =             .Get("AutoUnlockInterval")
  End With 'objDomainNT
  
  
  
  With objAdS
    intMinPwdLength =                         .Get("minPwdLength")
    intPwdHistoryLength =                     .Get("pwdHistoryLength")
    intPwdProperties =                         .Get("pwdProperties")
    intLockoutThreshold =                     .Get("lockoutThreshold")
    
    intMaxPwdAgeDays =                         ((intMaxPwdAgeSeconds/SEC_IN_MIN)/MIN_IN_DAY) & " days"
    intMinPwdAgeDays =                         ((intMinPwdAgeSeconds/SEC_IN_MIN)/MIN_IN_DAY) & " days"
    intLockOutObservationWindowMinutes =     (intLockOutObservationWindowSeconds/SEC_IN_MIN) & " minutes"
    
    If intLockoutDurationSeconds <> -1 Then
      intLockoutDurationMinutes =         (intLockOutDurationSeconds/SEC_IN_MIN) & " minutes"
    Else
      intLockoutDurationMinutes =         "Administrator must manually unlock locked accounts"
    End If
  End With ' objAdS
  
  With objUser
    '.GetInfo
    strGivenName =                 .Get("givenName")
    'MsgBox(strDN & VbCrLf & strGivenName)
    strInitials =                 .Get("initials")
    strSn =                     .Get("sn")
    strDisplayName =             .Get("displayName")
    strPhysDelOfficeName =         .Get("physicalDeliveryOfficeName")
    strTelephoneNumber =         .Get("telephoneNumber")
    strMail =                     .Get("mail")
    strWwwHomePage =             .Get("wWWHomePage")
    strAccountExpires =         .Get("accountExpires")
    strLogonName =                 .Get("sAMAccountName")
    strWhenCreated =             .Get("whenCreated")
    strWhenCreated = DateValue(strWhenCreated) & " at " & TimeValue(strWhenCreated - GREENWHICH_MEAN_TIME)
    strWhenChanged =             .Get("whenChanged")
    strWhenChanged = DateValue(strWhenChanged) & " at " & TimeValue(strWhenChanged - GREENWHICH_MEAN_TIME)
    strHomeDrive =                 .Get("homeDrive") & "\"
    strUserMail =                 .Get("mail")
    
    Set dtmGetLockout =         .Get("lockoutTime")
    
    If dtmGetLockout.HighPart = 0 And dtmGetLockout.LowPart = 0 Then
      strIsAccountLocked = "No"
      strAcctBGColor = "#00CC00"
    Else
      strIsAccountLocked = "Yes"
      strAcctBGColor = "#FF0000"
    End If
    
    strMailNickname =             .Get("mailNickname")
    If strMailNickname = "" Then
      strExchange = "No"
    Else
      strExchange = "Yes"
    End If
    
    strScriptPath =             .Get("scriptPath")
    If strScriptPath = "" Then
      strScriptPath = "No logon script defined"
    Else
      strScriptPath = strScriptPath
    End If
    
    strProfilePath =             .Get("profilePath")
    If strProfilePath = "" Then
      strProfilePath = "No profile path specified"
    Else
      strProfilePath = strProfilePath
    End If
    
    strHomeDirectory =             .Get("homeDirectory")
    If strHomeDirectory = "" Then
      strHomeDirectory = "No Home Directory specified"
    Else
      strHomeDirectory = strHomeDirectory
    End If
    
    blnMsNPAllowDialin =         .Get("msNPAllowDialin")
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
      strVPNAllow = "Control access through Remote Access Policy"
      Err.Clear
    Else
      If blnMsNPAllowDialin = True Then
        strVPNAllow = "Yes"
      Else
        strVPNAllow = "No"
      End If
    End If
    
    intUAC =                     .Get("userAccountControl")
    If intUAC And ADS_UF_DONT_EXPIRE_PASSWD Then
      strPwdExpires = "Password does not expire"
      strPwdNeverExpires = "Yes"
      strPwdExpBGColor = "#FF0000"'set the HTML view to Red
    Else
      dtmPwdLastChanged =         .PasswordLastChanged
      strPwdNeverExpires = "No"            
      strPwdExpires = DateValue(dtmPwdLastChanged + intMaxPwdAge) & " at " & TimeValue(dtmPwdLastChanged)
      strPwdExpBGColor = "#00CC00"'set the HTML view to Green
    End If
    
    dtmPwdLastChanged =         .PasswordLastChanged
    If dtmPwdLastChanged = "" Then
      strPwdAge = "" & vbTab
      strPwdLastChanged = "No record available"
      strPwdExpired = "Unknown"
      strPwdBGColor = "#FF0000" ' set the HTML view to Red
    Else
      strPwdLastChanged = DateValue(dtmPwdLastChanged) & " at " & TimeValue(dtmPwdLastChanged)
      strPwdAge = Int(Now - dtmPwdLastChanged) & " days"
      If intMaxPwdAgeDays >= strPwdAge Then
        strPwdExpired = "No"
        strPwdBGColor = "#00CC00"'set the HTML view to Green
      Else
        strPwdExpired = "Yes"
        strPwdBGColor = "#FF0000" ' set the HTML view to Red
        strPwdExpBGColor = "#FF0000"'set the HTML view to Red
      End If
      
    End If
    
    Set objSD =                 .Get("nTSecurityDescriptor")
    Set objDACL =             objSD.DiscretionaryAcl
    
    For Each Ace In objDACL
      If ((Ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And (LCase(Ace.ObjectType) = CHANGE_PASSWORD_GUID)) Then
        blnChangePwdEnabled = True
      End If
    Next
    
    If blnChangePwdEnabled Then
      strPwdCanChange = "No"
    Else
      strPwdCanChange = "Yes"
    End If
    
    'Terminal Services Info
    strTSHomeDir =                 .TerminalServicesHomeDirectory
    strTSHomeDrive =             .TerminalServicesHomeDrive
    strTSInitialProgram =         .TerminalServicesInitialProgram
    strTSWorkingDir =             .TerminalServicesWorkDirectory
    strTSBrokenConnAction =     .BrokenConnectionAction
    strTSMaxConnectTime =        .MaxConnectionTime
    strTSMaxDisconnectionTime = .MaxDisconnectionTime
    strTSMaxIdleTime =             .MaxIdleTime
    strTSReconnectionAction =     .ReconnectionAction
    strTSProfilePath =             .TerminalServicesProfilePath
    If strTSProfilePath = "" Then
      strTSProfilePath = "No profile path specified"
    Else
      strTSProfilePath = strTSProfilePath
    End If
    
    strTSAllowLogon =             .allowLogon
    If strTSAllowLogon = 1 Then
      strTSAllowLogon = "Yes"
    Else
      strTSAllowLogon = "No"
    End If
    
    strTSConnectPrinters =         .ConnectClientPrintersAtLogon
    If strTSConnectPrinters = 1 Then
      strTSConnectPrinters = "Yes"
    Else
      strTSConnectPrinters = "No"
    End If
    
    strTSConnectDrives =         .ConnectClientDrivesAtLogon
    If strTSConnectDrives = 1 Then
      strTSConnectDrives = "Yes"
    Else
      strTSConnectDrives = "No"
    End If
    
    strTSDefaultToMainPrinter = .DefaultToMainPrinter
    If strTSDefaultToMainPrinter = 1 Then
      strTSDefaultToMainPrinter = "Yes"
    Else
      strTSDefaultToMainPrinter = "No"
    End If
    
    strTSEnableRemoteControl =     .EnableRemoteControl
    If strTSEnableRemoteControl = 1 Then
      strTSEnableRemoteControl = "Yes"
    Else
      strTSEnableRemoteControl = "No"
    End If
    
    strDescription =             .GetEx("description")
    strDepartment =             .GetEx("department")
    strOtherTelephone =         .GetEx("otherTelephone")
    strUrl =                     .GetEx("url")
    arrMemberOf =                 .GetEx("memberOf")
    strDelegates =                .GetEx("publicDelegates")
    
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
      strGroupList = "The memberOf attribute is not set."
    Else
      For Each Group In arrMemberOf
        Group = Mid(Group,4)
        intLeft = InStr(Group,",")
        Group = Left(Group, intLeft) & " "
        strGroupList = strGroupList + Group
      Next 'arrMemberOf
      strGroupList = strGroupList
      
      ' Convert strgrouplist to Array
      arrGroupList = Split(strGroupList,",")
      'Sort the durn thing
      Quicksort arrGroupList, LBound(arrGroupList), UBound(arrGroupList)
      ' Now concatenate arrGroupList into a variable for display
      strSortedGroups = Join(arrGroupList, ", ")
      strSortedGroups = Mid(strSortedGroups, 4) ' cause the sort function is funky...
    End If
    
    For Each strValue In strDepartment
      strDisplayDepartment = strDisplayDepartment & strValue
    Next ' strDepartment Value
    
    For Each strValue In strDescription
      strDisplayDescription = strDisplayDescription & strValue
    Next ' strDecription Value
    
    For Each strValue In strOtherTelephone
      strDisplayOtherTelephone = strDisplayOtherTelephone & strValue
    Next ' strOtherTelephone Value
    
    For Each strValue In strUrl
      strDisplayUrl = strDisplayUrl & strValue
    Next ' strUrl value
    
    For Each strValue In strDelegates
      strDelegateCount = strDelegateCount + 1
      strValue = Mid(strValue,4)
      intLeft = InStr(strValue,",")
      strValue = Left(strValue, intLeft) & " "
      strValue = Replace(strValueList,"\,","")
      strValueList = strValueList & strValue
    Next ' strDelegate Value
    strDisplayDelegates = strValueList
    
    ' create dictionary for user account information
    Set objHash = CreateObject("Scripting.Dictionary")
    objHash.Add "ADS_UF_PASSWD_NOTREQD", &h00020
    objHash.Add "ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED", &h0080
    
    If intUAC And ADS_UF_ACCOUNTDISABLE Then
      strAccountDisabled = "Yes"
      strAcctBGColor = "#FF0000" ' set the HTML view to Red
    Else
      strAccountDisabled = "No"
      strAcctBGColor = "#00CC00" ' set the HTML view to Green
    End If
    
    For Each Key In objHash.Keys
      
      If objHash(Key) = ADS_UF_PASSWD_NOTREQD And intUAC Then
        strPwdRequired = "Yes"
      Else
        strPwdRequired = "No"
      End If
      
    Next 'objHash.keys
    
  End With ' objUser
  
End Sub 'GetUserAccount
 
' ******************Sorts the items in the array (between the two values you pass in)*********************
Sub Quicksort(strValues(), ByVal min, ByVal max)
  
  Dim strMediumValue, high, low, i
  
  'If the list has only 1 item, it's sorted.
  If min >= max Then Exit Sub
  
  ' Pick a dividing item randomly.
  i = min + Int(Rnd(max - min + 1))
  strMediumValue = strValues(i)
  
  ' Swap the dividing item to the front of the list.
  strValues(i) = strValues(min)
  
  ' Separate the list into sublists.
  low = min
  high = max
  Do
    ' Look down from high for a value < strMediumValue.
    Do While strValues(high) >= strMediumValue
      high = high - 1
      If high <= low Then Exit Do
    Loop
    
    If high <= low Then
      'The list is separated.
      strValues(low) = strMediumValue
      Exit Do
    End If
    
    'Swap the low and high strValues.
    strValues(low) = strValues(high)
    
    'Look up from low for a value >= strMediumValue.
    low = low + 1
    Do While strValues(low) < strMediumValue
      low = low + 1
      If low >= high Then Exit Do
    Loop
    
    If low >= high Then
      'The list is separated.
      low = high
      strValues(high) = strMediumValue
      Exit Do
    End If
    
    'Swap the low and high strValues.
    strValues(high) = strValues(low)
  Loop 'Loop until the list is separated.
  
  'Recursively sort the sublists.
  Quicksort strValues, min, low - 1
  Quicksort strValues, low + 1, max
  
End Sub 'Quicksort
 
'********************* If user selects cancel at any dialog box *****************************
Sub Cancelled()
  strMessage = "Cancelled by user: " & strUserName
  strTitle = "Operation Cancelled"
  MsgBox strMessage,vbOKOnly,strTitle
  WScript.quit
End Sub 'Cancelled
 
'********************* 'Test for minimum system software needed to run *****************************
Sub SysTest()    
  On Error Resume Next
  ' Alan Kaplan for VISN 6 - many thanks for the SysTest routines
  ' akaplan@msdinc.com www.msdinc.com
  ' WSH version tested
  Major = (ScriptEngineMinorVersion())
  Minor = (ScriptEngineMinorVersion())/10
  Ver = major + minor
  'Need version 5.5
  If Err.number Or ver = 5.6 Then
    strMessage = "You must load Version 5.5 (or later) of Windows Script Host" & vbCrLf &_
    vbCrLf & "Located at: \\filer-mrh\software\wmi\scr56en.exe" & vbCrLf
    WScript.Quit
  End If
  
  'Test for ADSI
  Err.clear
  key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\version"
  key2 = WshShell.RegRead (key)
  If Err <> 0 Then
    If strOS = "Windows_NT" Then
      strMessage = "ADSI 5.2 must be installed on local workstation to continue" & vbCrLf &_
      vbCrLf & "Located at: \\filer-mrh\software\wmi\adsi5.2.exe" & vbCrLf
      
      WshShell.Popup strMessage,0,"Workstation Setup Error",vbCritical
      WScript.Quit
    Else ' Must be Windows 9x
      strMessage = "You appear to be running Windows 9x. If this is true, then" & vbCrLf
      strMessage = strMessage & "ADSI 5.2 AND WMI must be installed on local workstation to continue" & vbCrLf &_
      vbCrLf & "Located at: \\filer-mrh\software\wmi\adsi5.2.exe and dsclient.exe" & vbCrLf
      WshShell.Popup strMessage,0,"Workstation Setup Error",vbCritical
      WScript.Quit
    End If
  End If
  
End Sub 'SysTest
 
'********************* Get the absolute last login/failed login date from Domain Controllers*********************************
Sub GetLastLogon()
  On Error Resume Next
  Set objConnection = CreateObject("ADODB.Connection")
  Set objCommand = CreateObject("ADODB.Command")
  objConnection.Provider = "ADsDSOObject"
  objConnection.Open "Active Directory Provider"
  Set objCommand.ActiveConnection = objConnection
  objCommand.CommandText = _
  "SELECT distinguishedName FROM " _
  & "'" & "" & strADsConfPath & "" & "'" _
  & "WHERE objectClass='nTDSDSA'"
  objCommand.Properties("Page Size") = 1000
  objCommand.Properties("Timeout") = 30
  objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  objCommand.Properties("Cache Results") = False
  Set objRecordSet = objCommand.Execute
  objRecordSet.MoveFirst
  
  Do Until objRecordSet.EOF
    strDCLeft = Mid(objRecordSet.Fields("distinguishedName").Value,21)
    strDCRight = InStr(strDCLeft,",")
    strDC = Left(strDCLeft,(strDCRight -1))
    ReDim Preserve arrDC(intSize)
    arrDC(intSize) = strDC
    intSize = intSize + 1
    objRecordSet.MoveNext
  Loop ' objRecordSet
  
  For Each strDC In arrDC
    Set objUser = GetObject("LDAP://" & strDC & "/" & strDN & "")
    
    With objUser
      dtmLastFailedLogin =         .LastFailedLogin
      If dtmNextFailedLogin > dtmLastFailedLogin Then
        dtmLastFailedLogin = dtmNextFailedLogin
      Else
        dtmLastFailedLogin = dtmLastFailedLogin
      End If
      
      intBadPwd =                 .Get("badPwdCount")
      If intNextBadPwd > intBadPwd Then
        intBadPwd = intNextBadPwd
      Else
        intBadPwd = intBadPwd
      End If
      
      If intBadPwd = 0 Then
        strLoginsBGColor = "#00CC00" ' set the HTML view to Green
      Else
        strLoginsBGColor = "#FF0000" ' set the HTML view to Red
      End If
      
      dtmLastLogin =                .LastLogin
      If dtmNextLogin > dtmLastLogin Then
        dtmLastLogin = dtmNextLogin
      Else
        dtmLastLogin = dtmLastLogin
      End If
    End With ' objUser
    dtmNextLogin = dtmLastLogin
    dtmNextFailedLogin = dtmLastFailedLogin
    intNextBadPwd = intBadPwd
  Next ' arrDC
  
  Set objectRecordSet = Nothing
  objConnection.close
  Set objConnection = Nothing
  
End Sub 'GetDomainControllers
 
 
 
'********************* Get the last logged in workstation name from SMS*********************************
 
Function FindMachineByUser(strGetUserName)
  On Error Resume Next
  
  Dim WinMgmt, SystemSet, strTime
  Dim objEnumerator, instance, strQuery
  Dim intMostRecentTime
  Dim i
  
  i=0
  FindMachineByUser = ""
  intMostRecentTime=""
  WinMgmt = "winmgmts:{impersonationLevel=impersonate}" & "!//" & cSMSmachine & "\root\sms\site_" & cSMSsite
  
  If Err <> 0 Then
    strLastLoggedInWorkstation = "Information Not available"
  Else
    
    Set SystemSet = GetObject(winmgmt)
    
    strQuery = _
    "SELECT Name, IPAddresses, AgentTime " & _
    "from sms_r_system where LastLogonUserName = '" & strGetUserName & "'"
    
    Set objEnumerator = SystemSet.ExecQuery(strQuery)
    For Each instance In objEnumerator
      strTime = instance.AgentTime(0)
      If strTime > intMostRecentTime Then
        intMostRecentTime=strTime
        If instance.IPAddresses(0) = "0.0.0.0" Then
          strMostRecentIP = instance.IPAddresses(1)
        Else
          strMostRecentIP = instance.IPAddresses(0)
        End If
        FindMachineByUser = instance.Name(0)
      End If
    Next
    If FindMachineByUser = "" Then
      strLastLoggedInWorkstation = "Information Not available"
    Else
      strLastLoggedInWorkstation = FindMachineByUser
    End If
  End If
End Function ' Get last logged in workstation from SMS
 
'********************************Create Internet Explorer Window to display the text in***************************
 
 
'*******************Kills the script if the IE Window is closed********************************
Sub IE_Quit()
  WScript.Quit
End Sub 'IE_Quit
 
 
'********************* Display USer Information in a Popup box*********************************
Sub DisplayUser()
  
  ' Set strMessage box variables to null
  strMessage =""
  ' Get rid of that annoying escape character for display purposes
  strDN = Replace(strDN,"\,",",")
  
  'popup user information: each line broken up for better reading
  strMessage = strMessage & "Logon Name: " & strLogonName & vbTab & "Display Name: " & strDisplayName & vbCrLf & _
  "Description: " & strDisplayDescription & vbCrLf & _
  "Department: " & strDisplayDepartment & vbTab & vbTab & "Telephone: " & strTelephoneNumber & vbCrLf & vbCrLf & _
  "Account Created: " & strWhenCreated & " GMT (-5 hours)" & vbTab & "Account changed: " & strWhenChanged & " GMT (-5 hours)" & vbCrLf & _
  "Distinguished Name: " & strDN & vbCrLf & _
  "Last logged in Workstation: " & strLastLoggedInWorkstation & vbTab & vbTab & "Last IPAddress: " & strMostRecentIP & vbCrLf & vbCrLf
  
  strMessage = strMessage & "Account Locked Out: " & strIsAccountLocked & vbTab & _
  "Account Disabled: " & strAccountDisabled & vbCrLf & _
  "Bad Logins: " & intBadPwd & vbTab & vbTab & "Attempts Left: " & (intLockoutThreshold - intBadPwd) & vbTab & "Max Attempts: " & intLockoutThreshold & vbCrLf & _
  "Last failed login: " & vbTab & vbTab & dtmLastFailedLogin & vbCrLf & _
  "Last Successful login: " & vbTab & dtmLastLogin & vbCrLf & vbCrLf
  
  strMessage = strMessage & "Password Last Changed: " & vbTab & strPwdLastChanged & vbCrLf & _
  "Password Expires: " & vbTab & vbTab& strPwdExpires & vbTab & vbCrLf & _
  "Password Age: " & strPwdAge & vbTab & "Password Expired: " & strPwdExpired & vbCrLf & vbCrLf
  
  strMessage = strMessage & "User can change Pwd: " & strPwdCanChange & vbTab & "Password Never Expires: " & _
  strPwdNeverExpires & vbCrLf & "Password Min Length: " & intMinPwdLength & vbTab & _
  "Passwords Kept In History: " & intPwdHistoryLength & " password(s)" & vbCrLf & _
  "Lockout Time: " & intLockoutDurationMinutes & vbTab & "AutoUnlock: " & intLockOutObservationWindowMinutes & vbCrLf & vbCrLf
  
  strMessage = strMessage & "Home Directory: " & strHomeDirectory & vbTab & vbTab & "Home Drive: " & strHomeDrive & vbCrLf & _
  "Roaming Profile Path: " & strProfilePath & vbCrLf & "Logon Script: " & strScriptPath & vbCrLf & vbCrLf
  
  strMessage = strMessage & "TS Profile Path: " & strTSProfilePath & vbCrLf & _
  "Allow TS Logon: " & strTSAllowLogon & vbTab & "Enable Remote Control: " & strTSEnableRemoteControl & vbCrLf & _
  "Connect Client Drives: " & strTSConnectDrives & vbTab & "Auto Create Printers: " & strTSConnectPrinters & vbCrLf & vbCrLf
  
  If strExchange = "Yes" Then    
    strMessage = strMessage & "Exchange Account: " & strExchange & vbTab & "External email address: " & strUserMail & vbCrLf & _
    "Exchange Alias: " & strMailNickname & vbTab & "Assigned Delegates: " & strDisplayDelegates & vbCrLf & _    
    "Allow VPN Access: " & strVPNAllow & vbCrLf & vbCrLf
    
  Else
    strMessage = strMessage & "Exchange Account: " & strExchange & vbTab & "Allow VPN Access: " & strVPNAllow & vbCrLf & vbCrLf
    
  End If
  
  strMessage = strMessage & "Group Membership: (Includes Distribution List Membership)" & vbCrLf & vbCrLf & _
  strSortedGroups
  
  ' Display User Information!
  strTitleMessage = " User Info for: " & strDisplayName & " in " & strDomain & " " & strVer
  WshShell.Popup strMessage,0,strTitleMessage
  
End Sub ' Display User
 
'********************* Display USer Information in a IE Window *********************************
Sub DisplayUserIE()
  Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
  objExplorer.Navigate "about:" & strDisplayName
  objExplorer.ToolBar = 0
  objExplorer.StatusBar = 0
  objExplorer.Width = 800
  objExplorer.Height = 600
  objExplorer.Left = 0
  objExplorer.Top = 0
  objExplorer.Visible = 1
  variable = "0"
  
  Set objDocument = objExplorer.Document
  
  objDocument.Open
  
  ' Set strPercent variable
  strPercent = "%"
  sQ = Chr(34)
  strBGColor = "#00CC00"
  ' Get rid of that annoying escape character for display purposes
  strDN = Replace(strDN,"\,",",")
  ' pre-defined HTML code- only have to change it ONCE to fix all
  
  sHTMLC1 = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1a = "<tr><td width=65" & strPercent & " style=" & sQ & "height:10px;" & sQ & " colspan=4>"
  sHTMLC1b = "<tr><td width=65" & strPercent & " bgcolor=" & sQ & strBGColor & sQ & " align=" & sQ & "right" & sQ & " colspan=4><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1c = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strPwdBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1d = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strAcctBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1e = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strLoginsBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1Close= "</strong></font></td>"
  sHTMLC2 = "<td width=20" & strPercent & "><font face=" & sQ & "Verdana" & sQ & " size=2"& sQ & ">"
  sHTMLC2a = "<td colspan=4><font face=" & sQ & "Verdana" & sQ & " size=2"& ">"
  sHTMLC2Close= "</strong></font></td>"
  sHTMLC3 = "<td width=15" & strPercent & " bgcolor=" & sQ & strBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3b = "<td width=15" & strPercent & " bgcolor=" & sQ & strPwdBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3c = "<td width=15" & strPercent & " bgcolor=" & sQ & strAcctBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3d = "<td width=15" & strPercent & " bgcolor=" & sQ & strPwdExpBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3e = "<td width=15" & strPercent & " bgcolor=" & sQ & strLoginsBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3Close= "</strong></font></td>"
  sHTMLC4 = "<td><font face=" & sQ & "Verdana" & sQ & " size=2" & sQ & ">"
  sHTMLC4Close= "</strong></font></td>"
  
  'Display user information in HTML: each line broken up for better reading
  'objDocument.WriteLn "<marquee width=85" & strPercent & ">Active Directory Information for " & strDisplayName & ".</marquee>"
  objDocument.WriteLn "<html><head><meta name=" & sQ & "GENERATOR" & sQ & "content=" & sQ & "Ralph Montgomery, rmonty@myself.com" & sQ & "><title>Active Directory Information for: " & strDisplayName & "</title></head><body>"
  
  objDocument.WriteLn "<script language=" & sQ & "JavaScript1.2" & sQ & ">"
  objDocument.WriteLn "top.window.moveTo(0,0);"
  objDocument.Writeln "if (document.all) {"
  objDocument.WriteLn "top.window.resizeTo(screen.availWidth,screen.availHeight);"
  objDocument.WriteLn "}"
  objDocument.WriteLn "else if (document.layers||document.getElementById) {"
  objDocument.WriteLn "if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){"
  objDocument.WriteLn    "top.window.outerHeight = screen.availHeight;"
  objDocument.WriteLn "top.window.outerWidth = screen.availWidth;"
  objDocument.WriteLn "}"
  objDocument.WriteLn "}"
  objDocument.WriteLn "</script>"
  
  objDocument.WriteLn "<Table border =0 Width = 65" & strPercent & "><Caption><strong>User Information for: </strong>" & strDisplayName & "</Caption>"
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Distinguished Name:" & sHTMLC1Close & sHTMLC2a & strDN & sHTMLC2Close
  objDocument.WriteLn sHTMLC1 & "Acct Created:" & sHTMLC1Close & sHTMLC2a & strWhenCreated & " GMT" & sHTMLC2Close
  objDocument.WriteLn sHTMLC1 & "Acct changed:" & sHTMLC1Close & sHTMLC2a & strWhenChanged & " GMT" & sHTMLC2Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Logon Name: " & sHTMLC1Close & sHTMLC2 & strLogonName & sHTMLC2Close & sHTMLC3 & "Description: " & sHTMLC3Close & sHTMLC4 & strDisplayDescription & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Department: " & sHTMLC1Close & sHTMLC2 & strDisplayDepartment & sHTMLC2Close & sHTMLC3 & "Telephone: " & sHTMLC3Close & sHTMLC4 & strTelephoneNumber & sHTMLC4Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1d & "Acct Locked:" & sHTMLC1Close & sHTMLC2 & strIsAccountLocked & sHTMLC2Close & sHTMLC3c & "Account Disabled:" & stHTMLC3Close & sHTMLC4 & strAccountDisabled & sHTMLC4Close
  objDocument.WriteLn sHTMLC1e & "Bad Logins:" & sHTMLC1Close & sHTMLC2 & intBadPwd & sHTMLC2Close & sHTMLC3e & "Max/Attempts Left:" & sHTML3Close & sHTMLC4 & intLockoutThreshold & "/" & (intLockoutThreshold - intBadPwd) & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Last failed login:" & sHTMLC1Close & sHTMLC2 & dtmLastFailedLogin & sHTMLC2Close & sHTMLC3 & "Last Successful login:" & sHTMLC3Close & sHTMLC4 & dtmLastLogin & sHTMLC4Close
  
  'objDocument.WriteLn sHTMLC1 & "Last Workstation:" & sHTMLC1Close & sHTMLC2 & strLastLoggedInWorkstation & sHTMLC2Close &sHTMLC3 & "Last IP Address:" & sHTMLc3Close & sHTMLC4 & strMostRecentIP & sHTMLC4Close
  'objDocument.WriteLn sHTMLC1 & "Last Workstation:" & sHTMLC1Close & sHTMLC2 & strLastLoggedInWorkstation & sHTMLC2Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Pwd Changed:" & sHTMLC1Close & sHTMLC2 & strPwdLastChanged & sHTMLC2Close & sHTMLC3 & "Pwd Age:" & sHTMLC3Close & sHTMLC4 & strPwdAge & sHTML4Close
  objDocument.WriteLn sHTMLC1 & "User change Pwd:" & sHTMLC1Close & sHTMLC2 & strPwdCanChange & sHTMLC2Close & sHTMLC3 & "Pwd Never Expires:" & sHTMLC3Close & sHTMLC4 & strPwdNeverExpires & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Min Pwd Length:" & sHTMLC1Close & sHTMLC2 & intMinPwdLength & sHTMLC2Close & sHTMLC3 & "Min Pwd History:" & sHTMLC3Close & sHTMLC4 & intPwdHistoryLength & " pwd(s)" & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Lockout Time:" & sHTMLC1Close & sHTMLC2 & intLockoutDurationMinutes & sHTMLC2Close & sHTMLC3 & "AutoUnlock:" & sHTMLC3Close & sHTMLC4 & intLockOutObservationWindowMinutes & sHTMLC4Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Home Directory:" & sHTMLC1Close & sHTMLC2 & strHomeDirectory & sHTMLC2Close & sHTMLC3 & "Home Drive:" & sHTMLC3Close & sHTMLC4 & strHomeDrive & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Roaming Profile:" & sHTMLC1Close & sHTMLC2 & strProfilePath & sHTMLC2Close & sHTMLC3 & "Logon Script:" & sHTMLC3Close & sHTMLC4 & strScriptPath & sHTMLC4Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Allow TS Logon:" & sHTMLC1Close & sHTMLC2 & strTSAllowLogon & sHTMLC2Close & sHTMLC3 & "Remote Control:" & sHTML3Close & sHTMLC4 & strTSEnableRemoteControl & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Connect Client Drives: " & sHTMLC1Close & sHTMLC2 & strTSConnectDrives & sHTMLC2Close & sHTMLC3 & "Auto Create Printers:" & sHTML3Close & sHTMLC4 & strTSConnectPrinters & sHTMLC4Close
  'objDocument.WriteLn sHTMLC1 & "TS Profile:" & sHTMLC1Close & sHTMLC2a & strTSProfilePath & sHTMLC2Close    
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  If strExchange = "Yes" Then    
    objDocument.WriteLn sHTMLC1 & "Exchange Account: " & sHTMLC1Close & sHTMLC2 & strExchange & sHTMLC2Close & sHTMLC3 & "Allow VPN Access:"& sHTMLC3Close & sHTMLC4 & strVPNAllow & sHTMLC4Close
    objDocument.WriteLn sHTMLC1 & "Exchange Alias:" & sHTMLC1Close & sHTMLC2 & strMailNickname & sHTMLC2Close & sHTMLC3 & "Assigned Delegates:" & sHTMLC3Close & sHTMLC4 & strDisplayDelegates & sHTMLC4Close    
    objDocument.WriteLn sHTMLC1 & "Ext email address:" & sHTMLC1Close & sHTMLC2 & strUserMail & sHTMLC2Close
    
  Else
    objDocument.WriteLn sHTMLC1 & "Exchange Account:" & sHTMLC1Close & sHTMLC2 & strExchange & sHTMLC2Close & sHTMLC3 & "Allow VPN Access:"& sHTMLC3Close & sHTMLC4 & strVPNAllow & sHTMLC4Close
    
  End If
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  objDocument.WriteLn sHTMLC1 & "Group Membership: " & sHTMLC1Close & sHTMLC2a & strSortedGroups & sHTMLC2Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn "</table></body></html>"
  
End Sub ' Display User in IE Window

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887:
888:
889:
890:
891:
892:
893:
894:
895:
896:
897:
898:
899:
900:
901:
902:
903:
904:
905:
906:
907:
908:
909:
910:
911:
912:
913:
914:
915:
916:
917:
918:
919:
920:
921:
922:
923:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-03-11 at 11:51:03ID24221136
Topic

VB Script

Participating Experts
2
Points
500
Comments
7

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Script to list members of every group.
    Hi, I'm no script expert but have occasionally knocked up a simple script in my dim and distant past however memory is failing me on this one... We need to list the members of every group in AD for a report. I have a list of all groups in a text file (more than 1000!). I...
  2. I need Active Directory Group Member Report
    I need a free utility or dos based script that will report all of my active directory groups in the entire domain including their members. I have found some things online, but where I am running into trouble is with nested groups. I need it to handle nested groups.
  3. enumerate all users in AD universal group INCLUDING NEST…
    Hi, Simple one (I hope), I need to count all user accounts that are members of 1 AD universal group INCLUDING nested members eg The group has dozens of nested groups, which again have nested groups. I can't get my head around the nested issue. Someone must have come across ...
  4. LIst nested users of Active Directory group
    I would like a vbscript that gives me all the nested members of a group. Dsget get's me all the members but also lists the groups, and that I can't use to pipe to another dsget to get certain user information (I would need firstname, lastname, login and email address only). ...
  5. VBscript to list all mail enabled active directory groups with …
    I am looking for a vbscript that will list all active directory groups that are mail enabled with the members of each group. You would think this would be easy to find, but I've been googling for a couple days and havent found exactly what I need. Thanks
  6. VBscript map drives based on AD groups. How to add su…
    Hi Experts, I've put together the following vbscript which maps network drives based on AD groups. How do I add code to include support for nested AD groups? Example: Sub CommonDriveMapping The staff and faculty groups are both members of the FacStaff group. I would like ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Chris-DentPosted on 2009-03-12 at 04:28:05ID: 23866984


Damn that's an enormous script. I haven't thoroughly tested this within the context of the main script, but I have inserted a function to recursively drift through group membership (I have tested that part).

The function is called from GetUserAccount like this:

      ' *** Ammended Group Search ***

      ' Dictionary for loop prevention if we bump into circular nesting
      Dim objTemp : Set objTemp = CreateObject("Scripting.Dictionary")

      strGroupList = GetAllGroups(arrMemberOf, objTemp, "")

      Set objTemp = Nothing

      ' *** End ***

The Dictionary is used, as commented, to prevent infinite loops if for some reason we bump into circular group nesting.

As you see that makes a call to a function called GetAllGroups. That looks like this:


Function GetAllGroups(arrGroups, objTemp, strGroupList)

  Dim strGroupDN
  For Each strGroupDN in arrGroups

    ' Make sure we haven't looked at this group before.
    If Not objTemp.Exists(strGroupDN) Then

      ' Connect to the group
      Dim objGroup : Set objGroup = GetObject("LDAP://" & strGroupDN)
      strGroupList = strGroupList & objGroup.get("name") & ","

      On Error Resume Next
      ' Check the "memberOf" for this group
      strGroupList = GetAllGroups(objGroup.GetEx("memberOf"), objTemp, strGroupList)
      On Error Goto 0
      Set objGroup = Nothing
    End If
  Next

  ' Return the combined Group List
  GetAllGroups = strGroupList
End Function


That's where we do the work, note that it includes a call-back to itself which is where it performs the recursive search.

HTH

Chris

' Get Active Directory User Information
' Version 2003
' Created May 2003 by Ralph Montgomery - Firsthealth of the Carolinas (rmonty@myself.com)
' May be freely distributed to give back to the scripting community, please acknowledge
' the work where you can. I would appreciate it. Many items here were culled from MSDN, newsgroups
' the Windows 2000 Scripting Guide from MS and just many hours of work. If you recognize a routine
' that I have not acknowledged, please let me know and I will fix it for ya.
' Revision history:
'    Initial rollout after debugging and documentation 06-11-2003
'    09/21/03 Added HTML display alternative
'         Added display of last logged in workstation from SMS
'    11/11/03 fixed password expiry info so display correctly
'
' Caveats: The Terminal Service information can only be pulled by a WinXp workstation with the
'    Active Directory Users and Computers MMC console from a Server 2003 CD. Sorry, MS wants it
'    that way I guess. Otherwise it will always be no.
'
' Usage: ADUser <CR>
 
'Must do: Either add your SMS site server and SMS site Name under the Const or
'     remark out the calling line: FindMachineByUser(strGetUserName)
 
' Constants
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_UF_PASSWD_NOTREQD = &h00020
Const ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = &h0080
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Const ADS_UF_PASSWORD_EXPIRED = &h80000
Const ADS_UF_PASSWD_CANT_CHANGE = &h0040
Const CHANGE_PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}"
Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const SEC_IN_MIN = 60
Const SEC_IN_DAY = 86400
Const MIN_IN_DAY = 1440
Const ADS_SCOPE_SUBTREE = 2
 
'Must do: Either add your SMS site server and SMS site Name under this Const or
'     remark out the calling line: FindMachineByUser(strGetUserName)
Const cSMSmachine = "sms-ss-mrh" ' name of system where SMS lives
Const cSMSsite = "FHC" ' name of SMS site
 
'*********************Initialize the variable farm in one spot*******************************************
Public strGetUserName
Dim objUserName, objUserDomain, objGroup, objUser, strGroupList, WshShell, strMessage, strTitle, dtStart
Dim objDomain, strDomain, strUserName, strOS, strVer, strSortedGroups, arrMemberOf, strUserList, strCheckName
Dim strMsgNoUser, strUserMail, strExchange, sQ, strNoDomain, blnIsActive, strCN, strOU, strRootDSE
 
Dim objChangePwdTrue, objChangePwd, objUserProfile, objNet, strIsAccountLocked, strMailNickname, strRetry
Dim objPwdExpiresTrue, objFlags, oPwdExpire , dtmPwdLastChanged, strUserName2, strValueList, major, minor, ver
Dim objAcctDisabled, intPwdExpired, objPwdExpiredTrue, strTSProfile, strDisplayDelegates
 
Dim strGivenName, strInitials, strSn, strDisplayName, strPhysDelOfficeName, strTelephoneNumber, strGetUserNam
Dim strMail, strWwwHomePage, intUAC, intBadPwd,    strNetworkAddress, strAllowDialin, dtmLastLogin, strLogonName
Dim strWhenCreated,    strWhenChanged,    strPwdExpires, strValue, strUserMustChgPwd, strPwdNeverExpires, strPwdLastChanged
Dim strPwdExpired, strPwdAge, strAccountDisabled, strDisplayDescription, strDisplayOtherTelephone, strDisplayUrl
Dim strOtherTelephone, strUrl, strPwdCanChange, strPwdMinLength, strDisplayDepartment, strAccountExpires
 
Dim strTSHomeDir, strTSHomeDrive, strTSProfilePath, strTSConnectPrinters, strTSConnectDrives, strTSDefaultToMainPrinter
Dim strTSInitialProgram, strTSWorkingDir, strTSEnableRemoteControl, strTSBrokenConnAction, strTSMaxConnectTime
Dim strTSMaxDisconnectionTime, strTSMaxIdleTime, strTSReconnectionAction, strTSAllowLogon
 
Dim intMaxPwdAge, intMaxPwdAgeSeconds, intMinPwdAgeSeconds, intLockOutObservationWindowSeconds, blnChangePwdEnabled
Dim intLockoutDurationSeconds, intUserFlags,intMinPwdLength, intPwdHistoryLength, intPwdProperties, intLockoutThreshold
Dim    intMaxPwdAgeDays, intMinPwdAgeDays, intLockOutObservationWindowMinutes, intLockoutDurationMinutes
 
Dim strProfilePath, strScriptPath, strHomeDirectory, strHomeDrive, blnMsNPAllowDialin, strVPNAllow, strDLList, strSortedDLList
Dim ldapconnectstring, Ouser, strSearch, strDN, dtmNextFailedLogin, dtmLastFailedLogin, strPwdRequired
Dim arrDC(), intSize, strLastLoggedInWorkstation, objDocument, strPwdBGColor, strAcctBGColor, strLoginsBGColor, strMsgDisplay
Dim strPwdExpBGColor, strDelegateCount
Dim strMostRecentIP
 
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNet = WScript.CreateObject("WScript.Network")' create network object for vars
Set objRootDSE = GetObject("LDAP://rootDSE")' bind to the rootDSE for portability
 
strADsConfPath = "LDAP://" & objRootDSE.Get("configurationNamingContext")' bind to configuration to get Domain Controllers later
strRootDSE = objRootDSE.Get("defaultNamingContext")' bind to the defaultContext for portability
strVer = "Ver 2003"' vanity
sQ = Chr(34)
strDomain = UCase(objNet.UserDomain)' pull user domain from environment variable
strUserName = UCase(objNet.UserName)' pull user name from environment variable
strOS = WshShell.ExpandEnvironmentStrings("%OS%")' pull OS from environment variable to use for other subs...
intSize = 0
strDelegateCount = 0
 
'SysTest() ' sub routine to check for Script Version/ADSI installed
GetUserName()' sub routine to get input for userID (sAMAccountName)
 
' this section added by John Ciccantelli
While strDN=""
  CheckForUser()' sub routine to check for user Existance & bind to if found
  If strDN = "" Then
    ReCheckUser()
  End If
Wend
' end of section added by John C.
GetUserAccount(strDN)
GetLastLogon()' sub routine to get absolute last login date from all Domain Controllers dynamically
' You must remark this next line out if NOT using SMS!!!!!!
' FindMachineByUser(strGetUserName) ' sub routine to query SMS for the last workstation logged into - remark out if not using SMS!
 
'strMsgDisplay = "To Display/Print Account information in" & vbCrLf & " Internet Explorer, press Yes, else press No"
'rtn = MsgBox(strMsgDisplay,vbYesNo,"Use HTML display output?")
'If rtn = 7 Then
'DisplayUser()' sub routine to Display gathered user Information in a popup box
'Elseif rtn = 6 Then
DisplayUserIE()' sub routine to Display gathered user Information in an Internet Explorer Window
'Else
'WScript.quit
'End if
 
'********************* Initial and only dialog box necessary *****************************
'********************* Looks for the sAMAccountName to bind to *****************************
Sub GetUserName()
  strMessage = "Enter the User Login ID to search." & vbCrLf & vbCrLf
  ' "Default is: " & strUserName & vbCrLf & vbCrLf
  strMessage = strMessage & "You may also search for a user by first or last name. "
  strMessage = strMessage & "(Searching will take a little bit longer)" & vbCrLf & vbCrLf & "or click Cancel to quit"
  strTitle = "USER Login ID"
  
  'get resource domain name, domain default via input box
  strGetUserName= UCase(InputBox(strMessage, strTitle, strUserName))
  
  ' Evaluate the user input.
  If strGetUserName = "" Then
    Cancelled()
  ElseIf Len(strGetUserName) < 1 Then
    strMessage = "Input name less than 1 character! Please Input at least 1!"
    strGetUserName= UCase(InputBox(strMessage, strTitle, strUserName))
  Else
    strGetUserName = strGetUserName
  End If
  
End Sub 'GetUserName
 
'********************* 'Attempt to bind to the sAMAccount Name provided search if not***************************
Sub CheckForUser()
  Set objConnection = CreateObject("ADODB.Connection")
  objConnection.Provider = ("ADsDSOObject")
  objConnection.Open
  
  Set objCommand = CreateObject("ADODB.Command")
  
  objCommand.ActiveConnection = objConnection
  
  objCommand.CommandText = _
  "<LDAP://" & strRootDSE & ">;(&(objectCategory=User)" & _
  "(samAccountName=" & strGetUserName & "));distinguishedName,sAMAccountName,name;subtree"
  
  Set objRecordSet = objCommand.Execute
  
  If objRecordset.RecordCount = 0 Then
    dtStart = TimeValue(Now())
    strMessage = "Login ID: " & strGetUserName & " not found: " & vbCrLf & "This may take a few seconds. . ."
    WshShell.Popup strMessage,2,"Searching . . ."
    strMessage = ""
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  Else
    strDN = objRecordset.Fields("distinguishedName")
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  End If
  
End Sub ' CheckForUser
 
Sub Check4User()
  Set objConnection = CreateObject("ADODB.Connection")
  objConnection.Provider = ("ADsDSOObject")
  objConnection.Open
  
  Set objCommand = CreateObject("ADODB.Command")
  
  objCommand.ActiveConnection = objConnection
  
  objCommand.CommandText = _
  "<LDAP://" & strRootDSE & ">;(&(anr=" & strGetUserName & ")(|(objectCategory=organizationalPerson)(objectCategory=group)));ADsPath,name,distinguishedName,displayName,objectCategory;subtree"
  
  objCommand.Properties("Page Size") = 64
  objCommand.Properties("Timeout") = 30 'seconds
  
  Set objRecordSet = objCommand.Execute
  
  If objRecordset.RecordCount <> 1 Then
    dtStart = TimeValue(Now())
    strMessage = "Name not found: " & strGetUserName & vbCrLf & "This may take a few seconds. . ."
    WshShell.Popup strMessage,2,"Searching . . ."
    strMessage = ""
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  Else
    strDN = objRecordset.Fields("distinguishedName")
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
  End If
  
End Sub ' Check4User
 
'********************* Recheck for user - uses Display name as the search key *****************************
Sub ReCheckUser()
  
  ldapconnectstring = "<LDAP://" & strRootDSE & ">"
  Set objConnection = CreateObject("ADODB.Connection")
  objConnection.Provider = "ADsDSOObject"
  objConnection.Open
  
  'strSearch = ldapconnectstring & ";(&(objectCategory=User)(CN=" & strGetUserName & "*));adspath;subtree"
  strSearch = ldapconnectstring & ";(&(anr=" & strGetUserName & ")(|(objectCategory=organizationalPerson)(objectCategory=group)));ADsPath,name,distinguishedName,displayName,objectCategory;subtree"
  Set objRecordSet = objConnection.Execute(strSearch)
  
  Do While Not objRecordset.EOF
    Set oUser = GetObject(objRecordSet("adspath"))
    strUserList = (strUserList & " " & oUser.givenName & " " & ouser.SN) & " - " & Mid(Replace(oUser.Name, "\,",","), 4) & vbCrLf
    If Err < 0 Then
      MsgBox "Error Occurred"
    End If
    objRecordSet.MoveNext
  Loop
  
  strMsgNoUser = "Your search found the following User Login IDs: " & vbCrLf & vbCrLf & strUserList & vbCrLf & _
  "Search completed in " & Second(TimeValue(Now()) - dtStart) & " second(s) or less." & vbCrLf & vbCrLf & _
  "Enter the User Login ID below, or cancel to exit"
  
  strRetry = InputBox(strMsgNoUser,"Search Reults . . .", strGetUserName)
  strUserList = ""
  strMsgNoUser = ""
  If strRetry = "" Then
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
    Cancelled()
  Else
    Set objectRecordSet = Nothing
    objConnection.close
    Set objConnection = Nothing
    strGetUserName = strRetry
  End If
  strGetUserName = strRetry
End Sub ' ReCheckUser
 
'********************* 'Get Selected User Account Information *****************************
Sub GetUserAccount(strDN)
  On Error Resume Next
  If InStr(1,strDN,"/") Then strDN=Replace(strDN,"/","\/")
  Set objDomainNT = GetObject("WinNT://" & strDomain & "")    ' Use NT Provider for Domain Policy items
  Set objUser = GetObject("LDAP://" & strDN & "")                ' LDAP for User Info
  Set objAdS = GetObject("LDAP://" & strRootDSE & "")            ' LDAP for AD domain items
  
  With objDomainNT
    intMaxPwdAge =                             .Get("MaxPasswordAge")    'get NT value for MaxPasswordAge
    intMaxPwdAge =                             (intMaxPwdAge/SEC_IN_DAY) ' maximum password age in days
    intMaxPwdAgeSeconds =                     .Get("MaxPasswordAge")
    intMinPwdAgeSeconds =                     .Get("MinPasswordAge")
    intLockOutObservationWindowSeconds =     .Get("LockoutObservationInterval")
    intLockoutDurationSeconds =             .Get("AutoUnlockInterval")
  End With 'objDomainNT
  
  
  
  With objAdS
    intMinPwdLength =                         .Get("minPwdLength")
    intPwdHistoryLength =                     .Get("pwdHistoryLength")
    intPwdProperties =                         .Get("pwdProperties")
    intLockoutThreshold =                     .Get("lockoutThreshold")
    
    intMaxPwdAgeDays =                         ((intMaxPwdAgeSeconds/SEC_IN_MIN)/MIN_IN_DAY) & " days"
    intMinPwdAgeDays =                         ((intMinPwdAgeSeconds/SEC_IN_MIN)/MIN_IN_DAY) & " days"
    intLockOutObservationWindowMinutes =     (intLockOutObservationWindowSeconds/SEC_IN_MIN) & " minutes"
    
    If intLockoutDurationSeconds <> -1 Then
      intLockoutDurationMinutes =         (intLockOutDurationSeconds/SEC_IN_MIN) & " minutes"
    Else
      intLockoutDurationMinutes =         "Administrator must manually unlock locked accounts"
    End If
  End With ' objAdS
  
  With objUser
    '.GetInfo
    strGivenName =                 .Get("givenName")
    'MsgBox(strDN & VbCrLf & strGivenName)
    strInitials =                 .Get("initials")
    strSn =                     .Get("sn")
    strDisplayName =             .Get("displayName")
    strPhysDelOfficeName =         .Get("physicalDeliveryOfficeName")
    strTelephoneNumber =         .Get("telephoneNumber")
    strMail =                     .Get("mail")
    strWwwHomePage =             .Get("wWWHomePage")
    strAccountExpires =         .Get("accountExpires")
    strLogonName =                 .Get("sAMAccountName")
    strWhenCreated =             .Get("whenCreated")
    strWhenCreated = DateValue(strWhenCreated) & " at " & TimeValue(strWhenCreated - GREENWHICH_MEAN_TIME)
    strWhenChanged =             .Get("whenChanged")
    strWhenChanged = DateValue(strWhenChanged) & " at " & TimeValue(strWhenChanged - GREENWHICH_MEAN_TIME)
    strHomeDrive =                 .Get("homeDrive") & "\"
    strUserMail =                 .Get("mail")
    
    Set dtmGetLockout =         .Get("lockoutTime")
    
    If dtmGetLockout.HighPart = 0 And dtmGetLockout.LowPart = 0 Then
      strIsAccountLocked = "No"
      strAcctBGColor = "#00CC00"
    Else
      strIsAccountLocked = "Yes"
      strAcctBGColor = "#FF0000"
    End If
    
    strMailNickname =             .Get("mailNickname")
    If strMailNickname = "" Then
      strExchange = "No"
    Else
      strExchange = "Yes"
    End If
    
    strScriptPath =             .Get("scriptPath")
    If strScriptPath = "" Then
      strScriptPath = "No logon script defined"
    Else
      strScriptPath = strScriptPath
    End If
    
    strProfilePath =             .Get("profilePath")
    If strProfilePath = "" Then
      strProfilePath = "No profile path specified"
    Else
      strProfilePath = strProfilePath
    End If
    
    strHomeDirectory =             .Get("homeDirectory")
    If strHomeDirectory = "" Then
      strHomeDirectory = "No Home Directory specified"
    Else
      strHomeDirectory = strHomeDirectory
    End If
    
    blnMsNPAllowDialin =         .Get("msNPAllowDialin")
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
      strVPNAllow = "Control access through Remote Access Policy"
      Err.Clear
    Else
      If blnMsNPAllowDialin = True Then
        strVPNAllow = "Yes"
      Else
        strVPNAllow = "No"
      End If
    End If
    
    intUAC =                     .Get("userAccountControl")
    If intUAC And ADS_UF_DONT_EXPIRE_PASSWD Then
      strPwdExpires = "Password does not expire"
      strPwdNeverExpires = "Yes"
      strPwdExpBGColor = "#FF0000"'set the HTML view to Red
    Else
      dtmPwdLastChanged =         .PasswordLastChanged
      strPwdNeverExpires = "No"            
      strPwdExpires = DateValue(dtmPwdLastChanged + intMaxPwdAge) & " at " & TimeValue(dtmPwdLastChanged)
      strPwdExpBGColor = "#00CC00"'set the HTML view to Green
    End If
    
    dtmPwdLastChanged =         .PasswordLastChanged
    If dtmPwdLastChanged = "" Then
      strPwdAge = "" & vbTab
      strPwdLastChanged = "No record available"
      strPwdExpired = "Unknown"
      strPwdBGColor = "#FF0000" ' set the HTML view to Red
    Else
      strPwdLastChanged = DateValue(dtmPwdLastChanged) & " at " & TimeValue(dtmPwdLastChanged)
      strPwdAge = Int(Now - dtmPwdLastChanged) & " days"
      If intMaxPwdAgeDays >= strPwdAge Then
        strPwdExpired = "No"
        strPwdBGColor = "#00CC00"'set the HTML view to Green
      Else
        strPwdExpired = "Yes"
        strPwdBGColor = "#FF0000" ' set the HTML view to Red
        strPwdExpBGColor = "#FF0000"'set the HTML view to Red
      End If
      
    End If
    
    Set objSD =                 .Get("nTSecurityDescriptor")
    Set objDACL =             objSD.DiscretionaryAcl
    
    For Each Ace In objDACL
      If ((Ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And (LCase(Ace.ObjectType) = CHANGE_PASSWORD_GUID)) Then
        blnChangePwdEnabled = True
      End If
    Next
    
    If blnChangePwdEnabled Then
      strPwdCanChange = "No"
    Else
      strPwdCanChange = "Yes"
    End If
    
    'Terminal Services Info
    strTSHomeDir =                 .TerminalServicesHomeDirectory
    strTSHomeDrive =             .TerminalServicesHomeDrive
    strTSInitialProgram =         .TerminalServicesInitialProgram
    strTSWorkingDir =             .TerminalServicesWorkDirectory
    strTSBrokenConnAction =     .BrokenConnectionAction
    strTSMaxConnectTime =        .MaxConnectionTime
    strTSMaxDisconnectionTime = .MaxDisconnectionTime
    strTSMaxIdleTime =             .MaxIdleTime
    strTSReconnectionAction =     .ReconnectionAction
    strTSProfilePath =             .TerminalServicesProfilePath
    If strTSProfilePath = "" Then
      strTSProfilePath = "No profile path specified"
    Else
      strTSProfilePath = strTSProfilePath
    End If
    
    strTSAllowLogon =             .allowLogon
    If strTSAllowLogon = 1 Then
      strTSAllowLogon = "Yes"
    Else
      strTSAllowLogon = "No"
    End If
    
    strTSConnectPrinters =         .ConnectClientPrintersAtLogon
    If strTSConnectPrinters = 1 Then
      strTSConnectPrinters = "Yes"
    Else
      strTSConnectPrinters = "No"
    End If
    
    strTSConnectDrives =         .ConnectClientDrivesAtLogon
    If strTSConnectDrives = 1 Then
      strTSConnectDrives = "Yes"
    Else
      strTSConnectDrives = "No"
    End If
    
    strTSDefaultToMainPrinter = .DefaultToMainPrinter
    If strTSDefaultToMainPrinter = 1 Then
      strTSDefaultToMainPrinter = "Yes"
    Else
      strTSDefaultToMainPrinter = "No"
    End If
    
    strTSEnableRemoteControl =     .EnableRemoteControl
    If strTSEnableRemoteControl = 1 Then
      strTSEnableRemoteControl = "Yes"
    Else
      strTSEnableRemoteControl = "No"
    End If
    
    strDescription =             .GetEx("description")
    strDepartment =             .GetEx("department")
    strOtherTelephone =         .GetEx("otherTelephone")
    strUrl =                     .GetEx("url")
    arrMemberOf =                 .GetEx("memberOf")
    strDelegates =                .GetEx("publicDelegates")
    
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
      strGroupList = "The memberOf attribute is not set."
    Else
 
      ' *** Ammended Group Search ***
 
      ' Dictionary for loop prevention if we bump into circular nesting
      Dim objTemp : Set objTemp = CreateObject("Scripting.Dictionary")
 
      strGroupList = GetAllGroups(arrMemberOf, objTemp, "")
 
      Set objTemp = Nothing
 
      ' *** End ***
 
      ' Convert strgrouplist to Array
      arrGroupList = Split(strGroupList,",")
      'Sort the durn thing
      Quicksort arrGroupList, LBound(arrGroupList), UBound(arrGroupList)
      ' Now concatenate arrGroupList into a variable for display
      strSortedGroups = Join(arrGroupList, ", ")
      strSortedGroups = Mid(strSortedGroups, 4) ' cause the sort function is funky...
    End If
    
    For Each strValue In strDepartment
      strDisplayDepartment = strDisplayDepartment & strValue
    Next ' strDepartment Value
    
    For Each strValue In strDescription
      strDisplayDescription = strDisplayDescription & strValue
    Next ' strDecription Value
    
    For Each strValue In strOtherTelephone
      strDisplayOtherTelephone = strDisplayOtherTelephone & strValue
    Next ' strOtherTelephone Value
    
    For Each strValue In strUrl
      strDisplayUrl = strDisplayUrl & strValue
    Next ' strUrl value
    
    For Each strValue In strDelegates
      strDelegateCount = strDelegateCount + 1
      strValue = Mid(strValue,4)
      intLeft = InStr(strValue,",")
      strValue = Left(strValue, intLeft) & " "
      strValue = Replace(strValueList,"\,","")
      strValueList = strValueList & strValue
    Next ' strDelegate Value
    strDisplayDelegates = strValueList
    
    ' create dictionary for user account information
    Set objHash = CreateObject("Scripting.Dictionary")
    objHash.Add "ADS_UF_PASSWD_NOTREQD", &h00020
    objHash.Add "ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED", &h0080
    
    If intUAC And ADS_UF_ACCOUNTDISABLE Then
      strAccountDisabled = "Yes"
      strAcctBGColor = "#FF0000" ' set the HTML view to Red
    Else
      strAccountDisabled = "No"
      strAcctBGColor = "#00CC00" ' set the HTML view to Green
    End If
    
    For Each Key In objHash.Keys
      
      If objHash(Key) = ADS_UF_PASSWD_NOTREQD And intUAC Then
        strPwdRequired = "Yes"
      Else
        strPwdRequired = "No"
      End If
      
    Next 'objHash.keys
    
  End With ' objUser
  
End Sub 'GetUserAccount
 
Function GetAllGroups(arrGroups, objTemp, strGroupList)
 
  Dim strGroupDN
  For Each strGroupDN in arrGroups
 
    ' Make sure we haven't looked at this group before.
    If Not objTemp.Exists(strGroupDN) Then
 
      ' Connect to the group
      Dim objGroup : Set objGroup = GetObject("LDAP://" & strGroupDN)
      strGroupList = strGroupList & objGroup.get("name") & ","
 
      On Error Resume Next
      strGroupList = GetAllGroups(objGroup.GetEx("memberOf"), objTemp, strGroupList)
      On Error Goto 0
      Set objGroup = Nothing
    End If
  Next
 
  GetAllGroups = strGroupList
End Function
 
' ******************Sorts the items in the array (between the two values you pass in)*********************
Sub Quicksort(strValues(), ByVal min, ByVal max)
  
  Dim strMediumValue, high, low, i
  
  'If the list has only 1 item, it's sorted.
  If min >= max Then Exit Sub
  
  ' Pick a dividing item randomly.
  i = min + Int(Rnd(max - min + 1))
  strMediumValue = strValues(i)
  
  ' Swap the dividing item to the front of the list.
  strValues(i) = strValues(min)
  
  ' Separate the list into sublists.
  low = min
  high = max
  Do
    ' Look down from high for a value < strMediumValue.
    Do While strValues(high) >= strMediumValue
      high = high - 1
      If high <= low Then Exit Do
    Loop
    
    If high <= low Then
      'The list is separated.
      strValues(low) = strMediumValue
      Exit Do
    End If
    
    'Swap the low and high strValues.
    strValues(low) = strValues(high)
    
    'Look up from low for a value >= strMediumValue.
    low = low + 1
    Do While strValues(low) < strMediumValue
      low = low + 1
      If low >= high Then Exit Do
    Loop
    
    If low >= high Then
      'The list is separated.
      low = high
      strValues(high) = strMediumValue
      Exit Do
    End If
    
    'Swap the low and high strValues.
    strValues(high) = strValues(low)
  Loop 'Loop until the list is separated.
  
  'Recursively sort the sublists.
  Quicksort strValues, min, low - 1
  Quicksort strValues, low + 1, max
  
End Sub 'Quicksort
 
'********************* If user selects cancel at any dialog box *****************************
Sub Cancelled()
  strMessage = "Cancelled by user: " & strUserName
  strTitle = "Operation Cancelled"
  MsgBox strMessage,vbOKOnly,strTitle
  WScript.quit
End Sub 'Cancelled
 
'********************* 'Test for minimum system software needed to run *****************************
Sub SysTest()    
  On Error Resume Next
  ' Alan Kaplan for VISN 6 - many thanks for the SysTest routines
  ' akaplan@msdinc.com www.msdinc.com
  ' WSH version tested
  Major = (ScriptEngineMinorVersion())
  Minor = (ScriptEngineMinorVersion())/10
  Ver = major + minor
  'Need version 5.5
  If Err.number Or ver = 5.6 Then
    strMessage = "You must load Version 5.5 (or later) of Windows Script Host" & vbCrLf &_
    vbCrLf & "Located at: \\filer-mrh\software\wmi\scr56en.exe" & vbCrLf
    WScript.Quit
  End If
  
  'Test for ADSI
  Err.clear
  key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\version"
  key2 = WshShell.RegRead (key)
  If Err <> 0 Then
    If strOS = "Windows_NT" Then
      strMessage = "ADSI 5.2 must be installed on local workstation to continue" & vbCrLf &_
      vbCrLf & "Located at: \\filer-mrh\software\wmi\adsi5.2.exe" & vbCrLf
      
      WshShell.Popup strMessage,0,"Workstation Setup Error",vbCritical
      WScript.Quit
    Else ' Must be Windows 9x
      strMessage = "You appear to be running Windows 9x. If this is true, then" & vbCrLf
      strMessage = strMessage & "ADSI 5.2 AND WMI must be installed on local workstation to continue" & vbCrLf &_
      vbCrLf & "Located at: \\filer-mrh\software\wmi\adsi5.2.exe and dsclient.exe" & vbCrLf
      WshShell.Popup strMessage,0,"Workstation Setup Error",vbCritical
      WScript.Quit
    End If
  End If
  
End Sub 'SysTest
 
'********************* Get the absolute last login/failed login date from Domain Controllers*********************************
Sub GetLastLogon()
  On Error Resume Next
  Set objConnection = CreateObject("ADODB.Connection")
  Set objCommand = CreateObject("ADODB.Command")
  objConnection.Provider = "ADsDSOObject"
  objConnection.Open "Active Directory Provider"
  Set objCommand.ActiveConnection = objConnection
  objCommand.CommandText = _
  "SELECT distinguishedName FROM " _
  & "'" & "" & strADsConfPath & "" & "'" _
  & "WHERE objectClass='nTDSDSA'"
  objCommand.Properties("Page Size") = 1000
  objCommand.Properties("Timeout") = 30
  objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  objCommand.Properties("Cache Results") = False
  Set objRecordSet = objCommand.Execute
  objRecordSet.MoveFirst
  
  Do Until objRecordSet.EOF
    strDCLeft = Mid(objRecordSet.Fields("distinguishedName").Value,21)
    strDCRight = InStr(strDCLeft,",")
    strDC = Left(strDCLeft,(strDCRight -1))
    ReDim Preserve arrDC(intSize)
    arrDC(intSize) = strDC
    intSize = intSize + 1
    objRecordSet.MoveNext
  Loop ' objRecordSet
  
  For Each strDC In arrDC
    Set objUser = GetObject("LDAP://" & strDC & "/" & strDN & "")
    
    With objUser
      dtmLastFailedLogin =         .LastFailedLogin
      If dtmNextFailedLogin > dtmLastFailedLogin Then
        dtmLastFailedLogin = dtmNextFailedLogin
      Else
        dtmLastFailedLogin = dtmLastFailedLogin
      End If
      
      intBadPwd =                 .Get("badPwdCount")
      If intNextBadPwd > intBadPwd Then
        intBadPwd = intNextBadPwd
      Else
        intBadPwd = intBadPwd
      End If
      
      If intBadPwd = 0 Then
        strLoginsBGColor = "#00CC00" ' set the HTML view to Green
      Else
        strLoginsBGColor = "#FF0000" ' set the HTML view to Red
      End If
      
      dtmLastLogin =                .LastLogin
      If dtmNextLogin > dtmLastLogin Then
        dtmLastLogin = dtmNextLogin
      Else
        dtmLastLogin = dtmLastLogin
      End If
    End With ' objUser
    dtmNextLogin = dtmLastLogin
    dtmNextFailedLogin = dtmLastFailedLogin
    intNextBadPwd = intBadPwd
  Next ' arrDC
  
  Set objectRecordSet = Nothing
  objConnection.close
  Set objConnection = Nothing
  
End Sub 'GetDomainControllers
 
 
 
'********************* Get the last logged in workstation name from SMS*********************************
 
Function FindMachineByUser(strGetUserName)
  On Error Resume Next
  
  Dim WinMgmt, SystemSet, strTime
  Dim objEnumerator, instance, strQuery
  Dim intMostRecentTime
  Dim i
  
  i=0
  FindMachineByUser = ""
  intMostRecentTime=""
  WinMgmt = "winmgmts:{impersonationLevel=impersonate}" & "!//" & cSMSmachine & "\root\sms\site_" & cSMSsite
  
  If Err <> 0 Then
    strLastLoggedInWorkstation = "Information Not available"
  Else
    
    Set SystemSet = GetObject(winmgmt)
    
    strQuery = _
    "SELECT Name, IPAddresses, AgentTime " & _
    "from sms_r_system where LastLogonUserName = '" & strGetUserName & "'"
    
    Set objEnumerator = SystemSet.ExecQuery(strQuery)
    For Each instance In objEnumerator
      strTime = instance.AgentTime(0)
      If strTime > intMostRecentTime Then
        intMostRecentTime=strTime
        If instance.IPAddresses(0) = "0.0.0.0" Then
          strMostRecentIP = instance.IPAddresses(1)
        Else
          strMostRecentIP = instance.IPAddresses(0)
        End If
        FindMachineByUser = instance.Name(0)
      End If
    Next
    If FindMachineByUser = "" Then
      strLastLoggedInWorkstation = "Information Not available"
    Else
      strLastLoggedInWorkstation = FindMachineByUser
    End If
  End If
End Function ' Get last logged in workstation from SMS
 
'********************************Create Internet Explorer Window to display the text in***************************
 
 
'*******************Kills the script if the IE Window is closed********************************
Sub IE_Quit()
  WScript.Quit
End Sub 'IE_Quit
 
 
'********************* Display USer Information in a Popup box*********************************
Sub DisplayUser()
  
  ' Set strMessage box variables to null
  strMessage =""
  ' Get rid of that annoying escape character for display purposes
  strDN = Replace(strDN,"\,",",")
  
  'popup user information: each line broken up for better reading
  strMessage = strMessage & "Logon Name: " & strLogonName & vbTab & "Display Name: " & strDisplayName & vbCrLf & _
  "Description: " & strDisplayDescription & vbCrLf & _
  "Department: " & strDisplayDepartment & vbTab & vbTab & "Telephone: " & strTelephoneNumber & vbCrLf & vbCrLf & _
  "Account Created: " & strWhenCreated & " GMT (-5 hours)" & vbTab & "Account changed: " & strWhenChanged & " GMT (-5 hours)" & vbCrLf & _
  "Distinguished Name: " & strDN & vbCrLf & _
  "Last logged in Workstation: " & strLastLoggedInWorkstation & vbTab & vbTab & "Last IPAddress: " & strMostRecentIP & vbCrLf & vbCrLf
  
  strMessage = strMessage & "Account Locked Out: " & strIsAccountLocked & vbTab & _
  "Account Disabled: " & strAccountDisabled & vbCrLf & _
  "Bad Logins: " & intBadPwd & vbTab & vbTab & "Attempts Left: " & (intLockoutThreshold - intBadPwd) & vbTab & "Max Attempts: " & intLockoutThreshold & vbCrLf & _
  "Last failed login: " & vbTab & vbTab & dtmLastFailedLogin & vbCrLf & _
  "Last Successful login: " & vbTab & dtmLastLogin & vbCrLf & vbCrLf
  
  strMessage = strMessage & "Password Last Changed: " & vbTab & strPwdLastChanged & vbCrLf & _
  "Password Expires: " & vbTab & vbTab& strPwdExpires & vbTab & vbCrLf & _
  "Password Age: " & strPwdAge & vbTab & "Password Expired: " & strPwdExpired & vbCrLf & vbCrLf
  
  strMessage = strMessage & "User can change Pwd: " & strPwdCanChange & vbTab & "Password Never Expires: " & _
  strPwdNeverExpires & vbCrLf & "Password Min Length: " & intMinPwdLength & vbTab & _
  "Passwords Kept In History: " & intPwdHistoryLength & " password(s)" & vbCrLf & _
  "Lockout Time: " & intLockoutDurationMinutes & vbTab & "AutoUnlock: " & intLockOutObservationWindowMinutes & vbCrLf & vbCrLf
  
  strMessage = strMessage & "Home Directory: " & strHomeDirectory & vbTab & vbTab & "Home Drive: " & strHomeDrive & vbCrLf & _
  "Roaming Profile Path: " & strProfilePath & vbCrLf & "Logon Script: " & strScriptPath & vbCrLf & vbCrLf
  
  strMessage = strMessage & "TS Profile Path: " & strTSProfilePath & vbCrLf & _
  "Allow TS Logon: " & strTSAllowLogon & vbTab & "Enable Remote Control: " & strTSEnableRemoteControl & vbCrLf & _
  "Connect Client Drives: " & strTSConnectDrives & vbTab & "Auto Create Printers: " & strTSConnectPrinters & vbCrLf & vbCrLf
  
  If strExchange = "Yes" Then    
    strMessage = strMessage & "Exchange Account: " & strExchange & vbTab & "External email address: " & strUserMail & vbCrLf & _
    "Exchange Alias: " & strMailNickname & vbTab & "Assigned Delegates: " & strDisplayDelegates & vbCrLf & _    
    "Allow VPN Access: " & strVPNAllow & vbCrLf & vbCrLf
    
  Else
    strMessage = strMessage & "Exchange Account: " & strExchange & vbTab & "Allow VPN Access: " & strVPNAllow & vbCrLf & vbCrLf
    
  End If
  
  strMessage = strMessage & "Group Membership: (Includes Distribution List Membership)" & vbCrLf & vbCrLf & _
  strSortedGroups
  
  ' Display User Information!
  strTitleMessage = " User Info for: " & strDisplayName & " in " & strDomain & " " & strVer
  WshShell.Popup strMessage,0,strTitleMessage
  
End Sub ' Display User
 
'********************* Display USer Information in a IE Window *********************************
Sub DisplayUserIE()
  Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
  objExplorer.Navigate "about:" & strDisplayName
  objExplorer.ToolBar = 0
  objExplorer.StatusBar = 0
  objExplorer.Width = 800
  objExplorer.Height = 600
  objExplorer.Left = 0
  objExplorer.Top = 0
  objExplorer.Visible = 1
  variable = "0"
  
  Set objDocument = objExplorer.Document
  
  objDocument.Open
  
  ' Set strPercent variable
  strPercent = "%"
  sQ = Chr(34)
  strBGColor = "#00CC00"
  ' Get rid of that annoying escape character for display purposes
  strDN = Replace(strDN,"\,",",")
  ' pre-defined HTML code- only have to change it ONCE to fix all
  
  sHTMLC1 = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1a = "<tr><td width=65" & strPercent & " style=" & sQ & "height:10px;" & sQ & " colspan=4>"
  sHTMLC1b = "<tr><td width=65" & strPercent & " bgcolor=" & sQ & strBGColor & sQ & " align=" & sQ & "right" & sQ & " colspan=4><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1c = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strPwdBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1d = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strAcctBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1e = "<tr><td width=15" & strPercent & " bgcolor=" & sQ & strLoginsBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC1Close= "</strong></font></td>"
  sHTMLC2 = "<td width=20" & strPercent & "><font face=" & sQ & "Verdana" & sQ & " size=2"& sQ & ">"
  sHTMLC2a = "<td colspan=4><font face=" & sQ & "Verdana" & sQ & " size=2"& ">"
  sHTMLC2Close= "</strong></font></td>"
  sHTMLC3 = "<td width=15" & strPercent & " bgcolor=" & sQ & strBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3b = "<td width=15" & strPercent & " bgcolor=" & sQ & strPwdBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3c = "<td width=15" & strPercent & " bgcolor=" & sQ & strAcctBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3d = "<td width=15" & strPercent & " bgcolor=" & sQ & strPwdExpBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3e = "<td width=15" & strPercent & " bgcolor=" & sQ & strLoginsBGColor & sQ & " align=" & sQ & "right" & sQ & "><font face="& sQ & "Verdana" & sQ & "size=2 color="& sQ & "#FFFFFF"& sQ & "><strong>"
  sHTMLC3Close= "</strong></font></td>"
  sHTMLC4 = "<td><font face=" & sQ & "Verdana" & sQ & " size=2" & sQ & ">"
  sHTMLC4Close= "</strong></font></td>"
  
  'Display user information in HTML: each line broken up for better reading
  'objDocument.WriteLn "<marquee width=85" & strPercent & ">Active Directory Information for " & strDisplayName & ".</marquee>"
  objDocument.WriteLn "<html><head><meta name=" & sQ & "GENERATOR" & sQ & "content=" & sQ & "Ralph Montgomery, rmonty@myself.com" & sQ & "><title>Active Directory Information for: " & strDisplayName & "</title></head><body>"
  
  objDocument.WriteLn "<script language=" & sQ & "JavaScript1.2" & sQ & ">"
  objDocument.WriteLn "top.window.moveTo(0,0);"
  objDocument.Writeln "if (document.all) {"
  objDocument.WriteLn "top.window.resizeTo(screen.availWidth,screen.availHeight);"
  objDocument.WriteLn "}"
  objDocument.WriteLn "else if (document.layers||document.getElementById) {"
  objDocument.WriteLn "if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){"
  objDocument.WriteLn    "top.window.outerHeight = screen.availHeight;"
  objDocument.WriteLn "top.window.outerWidth = screen.availWidth;"
  objDocument.WriteLn "}"
  objDocument.WriteLn "}"
  objDocument.WriteLn "</script>"
  
  objDocument.WriteLn "<Table border =0 Width = 65" & strPercent & "><Caption><strong>User Information for: </strong>" & strDisplayName & "</Caption>"
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Distinguished Name:" & sHTMLC1Close & sHTMLC2a & strDN & sHTMLC2Close
  objDocument.WriteLn sHTMLC1 & "Acct Created:" & sHTMLC1Close & sHTMLC2a & strWhenCreated & " GMT" & sHTMLC2Close
  objDocument.WriteLn sHTMLC1 & "Acct changed:" & sHTMLC1Close & sHTMLC2a & strWhenChanged & " GMT" & sHTMLC2Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Logon Name: " & sHTMLC1Close & sHTMLC2 & strLogonName & sHTMLC2Close & sHTMLC3 & "Description: " & sHTMLC3Close & sHTMLC4 & strDisplayDescription & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Department: " & sHTMLC1Close & sHTMLC2 & strDisplayDepartment & sHTMLC2Close & sHTMLC3 & "Telephone: " & sHTMLC3Close & sHTMLC4 & strTelephoneNumber & sHTMLC4Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1d & "Acct Locked:" & sHTMLC1Close & sHTMLC2 & strIsAccountLocked & sHTMLC2Close & sHTMLC3c & "Account Disabled:" & stHTMLC3Close & sHTMLC4 & strAccountDisabled & sHTMLC4Close
  objDocument.WriteLn sHTMLC1e & "Bad Logins:" & sHTMLC1Close & sHTMLC2 & intBadPwd & sHTMLC2Close & sHTMLC3e & "Max/Attempts Left:" & sHTML3Close & sHTMLC4 & intLockoutThreshold & "/" & (intLockoutThreshold - intBadPwd) & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Last failed login:" & sHTMLC1Close & sHTMLC2 & dtmLastFailedLogin & sHTMLC2Close & sHTMLC3 & "Last Successful login:" & sHTMLC3Close & sHTMLC4 & dtmLastLogin & sHTMLC4Close
  
  'objDocument.WriteLn sHTMLC1 & "Last Workstation:" & sHTMLC1Close & sHTMLC2 & strLastLoggedInWorkstation & sHTMLC2Close &sHTMLC3 & "Last IP Address:" & sHTMLc3Close & sHTMLC4 & strMostRecentIP & sHTMLC4Close
  'objDocument.WriteLn sHTMLC1 & "Last Workstation:" & sHTMLC1Close & sHTMLC2 & strLastLoggedInWorkstation & sHTMLC2Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Pwd Changed:" & sHTMLC1Close & sHTMLC2 & strPwdLastChanged & sHTMLC2Close & sHTMLC3 & "Pwd Age:" & sHTMLC3Close & sHTMLC4 & strPwdAge & sHTML4Close
  objDocument.WriteLn sHTMLC1 & "User change Pwd:" & sHTMLC1Close & sHTMLC2 & strPwdCanChange & sHTMLC2Close & sHTMLC3 & "Pwd Never Expires:" & sHTMLC3Close & sHTMLC4 & strPwdNeverExpires & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Min Pwd Length:" & sHTMLC1Close & sHTMLC2 & intMinPwdLength & sHTMLC2Close & sHTMLC3 & "Min Pwd History:" & sHTMLC3Close & sHTMLC4 & intPwdHistoryLength & " pwd(s)" & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Lockout Time:" & sHTMLC1Close & sHTMLC2 & intLockoutDurationMinutes & sHTMLC2Close & sHTMLC3 & "AutoUnlock:" & sHTMLC3Close & sHTMLC4 & intLockOutObservationWindowMinutes & sHTMLC4Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Home Directory:" & sHTMLC1Close & sHTMLC2 & strHomeDirectory & sHTMLC2Close & sHTMLC3 & "Home Drive:" & sHTMLC3Close & sHTMLC4 & strHomeDrive & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Roaming Profile:" & sHTMLC1Close & sHTMLC2 & strProfilePath & sHTMLC2Close & sHTMLC3 & "Logon Script:" & sHTMLC3Close & sHTMLC4 & strScriptPath & sHTMLC4Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn sHTMLC1 & "Allow TS Logon:" & sHTMLC1Close & sHTMLC2 & strTSAllowLogon & sHTMLC2Close & sHTMLC3 & "Remote Control:" & sHTML3Close & sHTMLC4 & strTSEnableRemoteControl & sHTMLC4Close
  objDocument.WriteLn sHTMLC1 & "Connect Client Drives: " & sHTMLC1Close & sHTMLC2 & strTSConnectDrives & sHTMLC2Close & sHTMLC3 & "Auto Create Printers:" & sHTML3Close & sHTMLC4 & strTSConnectPrinters & sHTMLC4Close
  'objDocument.WriteLn sHTMLC1 & "TS Profile:" & sHTMLC1Close & sHTMLC2a & strTSProfilePath & sHTMLC2Close    
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  If strExchange = "Yes" Then    
    objDocument.WriteLn sHTMLC1 & "Exchange Account: " & sHTMLC1Close & sHTMLC2 & strExchange & sHTMLC2Close & sHTMLC3 & "Allow VPN Access:"& sHTMLC3Close & sHTMLC4 & strVPNAllow & sHTMLC4Close
    objDocument.WriteLn sHTMLC1 & "Exchange Alias:" & sHTMLC1Close & sHTMLC2 & strMailNickname & sHTMLC2Close & sHTMLC3 & "Assigned Delegates:" & sHTMLC3Close & sHTMLC4 & strDisplayDelegates & sHTMLC4Close    
    objDocument.WriteLn sHTMLC1 & "Ext email address:" & sHTMLC1Close & sHTMLC2 & strUserMail & sHTMLC2Close
    
  Else
    objDocument.WriteLn sHTMLC1 & "Exchange Account:" & sHTMLC1Close & sHTMLC2 & strExchange & sHTMLC2Close & sHTMLC3 & "Allow VPN Access:"& sHTMLC3Close & sHTMLC4 & strVPNAllow & sHTMLC4Close
    
  End If
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  objDocument.WriteLn sHTMLC1 & "Group Membership: " & sHTMLC1Close & sHTMLC2a & strSortedGroups & sHTMLC2Close
  objDocument.WriteLn sHTMLC1a & "<HR>" & sHTMLC1Close
  
  objDocument.WriteLn "</table></body></html>"
  
End Sub ' Display User in IE Window
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887:
888:
889:
890:
891:
892:
893:
894:
895:
896:
897:
898:
899:
900:
901:
902:
903:
904:
905:
906:
907:
908:
909:
910:
911:
912:
913:
914:
915:
916:
917:
918:
919:
920:
921:
922:
923:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:
934:
935:
936:
937:
938:
939:
940:
941:
942:
943:
944:
945:
946:
947:
948:
949:
950:
951:
952:
953:
954:
955:
956:
957:
958:
959:

Select allOpen in new window

 

by: ivanoviolaPosted on 2009-03-12 at 05:14:10ID: 31556927

Hi Chris,

Yeah, it is a long script! Thanks for the help. It worked great. The only thing was that the first letter of the first group was being cut-off. I added a comma in the following  section which fixed the problem.
 strGroupList = GetAllGroups(arrMemberOf, objTemp, ",")

 ' *** Ammended Group Search ***
 ' Dictionary for loop prevention if we bump into circular nesting
   Dim objTemp : Set objTemp = CreateObject("Scripting.Dictionary")
 
 strGroupList = GetAllGroups(arrMemberOf, objTemp, ",")
 
 Set objTemp = Nothing

 ' *** End ***

I appreciate the help!
Ivano

 

by: ivanoviolaPosted on 2009-03-12 at 09:47:33ID: 23870658

Chris,

One thing I just noticed, the script does not show primary groups. It shows groups and nested groups. Is there something we can do for that?

Ivano

 

by: Chris-DentPosted on 2009-03-12 at 09:58:02ID: 23870775


Yes... but it's a bit messy. The Primary Group isn't listed in memberOf, instead you have to interrogate PrimaryGroupID, then compare that value with PrimaryGroupToken on every group in the domain.

Most of the time that's easy because it's 513, which matches up to Domain Users. I take it you want it because that isn't the case within your Forest / Domain?

There is an alternative, the WinNT interface lists the Primary Group in the MemberOf Property. Just not quite as fun to work with the WinNT interface.

Chris

 

by: ivanoviolaPosted on 2009-03-12 at 11:04:33ID: 23871582

That's correct. I thought I would ask to see if you had a quick fix. It would be nice if the primary groups also appeared.

Ivano

 

by: ArifDJPosted on 2009-03-24 at 11:23:15ID: 23971466

Hi Expert,

I am new member and I would like to know solution how gather information for getting security setting, services and other standard setting for server 2000 and 2003 thru vbscript and generate to report.

Thanks,
Arif

 

by: Chris-DentPosted on 2009-03-25 at 03:11:28ID: 23977552


Hi Arif,

You need to create a new question for this request.

The only people likely to be watching this thread are Ivanoviola and I which limits your audience and therefore the help you can get.

Chris

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...