B
Billy
Hello,
I'm looking to extract all our users and the dates that
they were created into an excel spreadsheet. I've tried
running ldap queries like "(&(objectclass=user)
(whenCreated>=20030501000000.0Z)(whenCreated<=2003053123
5959.0Z))", but they come back with errors. I'm able to
run a vbs script where I can hard code the user and it
returns the data "strNTName = "TestUser"
' User RootDSE to retrieve the DNS domain name.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
' User ADO to find the user object and
' return "createTimeStamp"
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strQuery = "<LDAP://" & strDNSDomain _
& ">;(sAMAccountName=" _
& strNTName & ");createTimeStamp;subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = 2
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
dtmCreate = objRecordSet.Fields("createTimeStamp")
MsgBox "User " & strNTName & " created: " & dtmCreate
objRecordSet.MoveNext
Loop
"
The problem is, I need to do this for about 1000 users and
don't have the time or patience to do this individually.
Any ideas.
Thanks,
Billy
I'm looking to extract all our users and the dates that
they were created into an excel spreadsheet. I've tried
running ldap queries like "(&(objectclass=user)
(whenCreated>=20030501000000.0Z)(whenCreated<=2003053123
5959.0Z))", but they come back with errors. I'm able to
run a vbs script where I can hard code the user and it
returns the data "strNTName = "TestUser"
' User RootDSE to retrieve the DNS domain name.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
' User ADO to find the user object and
' return "createTimeStamp"
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strQuery = "<LDAP://" & strDNSDomain _
& ">;(sAMAccountName=" _
& strNTName & ");createTimeStamp;subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = 2
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
dtmCreate = objRecordSet.Fields("createTimeStamp")
MsgBox "User " & strNTName & " created: " & dtmCreate
objRecordSet.MoveNext
Loop
"
The problem is, I need to do this for about 1000 users and
don't have the time or patience to do this individually.
Any ideas.
Thanks,
Billy