'------------------------------------------------------------------------------'
' Compares the sAMAccountName attribute to the name attribute and displays '
' mismatches. '
'------------------------------------------------------------------------------
'
Option Explicit
Dim defaultNamingContext
Dim AdQuery
Dim AdsPath, sAMAccountName, cn
Dim AdConn, AdComm, AdRS
defaultNamingContext = GetObject("LDAP://RootDSE").Get("defaultNamingContext")
AdQuery = "SELECT cn, sAMAccountName " & _
"FROM 'LDAP://" & defaultNamingContext & "' " & _
"WHERE objectCategory='group'"
Set AdConn = CreateObject("ADODB.Connection")
AdConn.Provider = "ADsDSOObject"
AdConn.Open "Active Directory Provider"
Set AdComm = CreateObject("ADODB.Command")
AdComm.ActiveConnection = AdConn
AdComm.Properties("SearchScope") = 2
AdComm.Properties("Page Size") = 1000
AdComm.CommandText = AdQuery
Set AdRS = AdComm.Execute
WScript.Echo "sAMAccountName,cn"
With AdRs
While Not .EOF
sAMAccountName = .Fields("sAMAccountName")
cn = .Fields("cn")
If UCase(sAMAccountName) <> UCase(cn) then
WScript.Echo sAMAccountName & "," & cn
End If
.MoveNext
Wend
End With
Set AdRs = Nothing
Set AdComm = Nothing
Set AdConn = Nothing
Saturday, March 24, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment