createtimestamp

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
 
J

Jerold Schulman

If you have a Windows XP domain member, see tip 7368 in the 'Tips & Tricks' at
http://www.jsiinc.com

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


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
J

Joe Richards [MVP]

Well other than having an inefficient query it should work.

At least the query worked on my environment fine using adfind (get it on the
free win32 tools page of www.joeware.net)...

[Thu 05/27/2004 12:25:31.10]
F:\DEV\Perl\PwdRst>adfind -gc -b -f
"&(objectclass=user)(whenCreated>=20030501000000.0Z)(whenCreated<=20030531235959.0Z)"
-dn

AdFind V01.15.00cpp Joe Richards ([email protected]) April 2004

Using server: 2k3dc01.joe.com


0 Objects returned

[Thu 05/27/2004 12:26:17.89]
F:\DEV\Perl\PwdRst>


If I set to a time frame where I know I did something I get output...


[Thu 05/27/2004 12:26:17.89]
F:\DEV\Perl\PwdRst>adfind -gc -b -f
"&(objectclass=user)(whenCreated>=20040501000000.0Z)(whenCreated<=20040531235959.0Z)"
-dn

AdFind V01.15.00cpp Joe Richards ([email protected]) April 2004

Using server: 2k3dc01.joe.com

dn:CN=atestuser1,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser2,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser3,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser4,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser5,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser6,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser7,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser8,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser9,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=atestuser10,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=btestuser1,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=btestuser2,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
dn:CN=btestuser3,OU=TestUsers2OU,OU=TestOU,DC=joe,DC=com
<SNIP>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top