Re: createtimestamp

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Joe Richards [MVP] (humorexpress_at_hotmail.com)
Date: 05/27/04


Date: Thu, 27 May 2004 12:28:32 -0400

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 (joe@joeware.net) 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 (joe@joeware.net) 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>

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
anonymous@discussions.microsoft.com wrote:
> Comes back with "One or more input parameters are invalid"
> 
>>-----Original Message-----
>>What is the error you get for the first query?
>>
>>--
>>Joe Richards Microsoft MVP Windows Server Directory 
> 
> Services
> 
>>www.joeware.net
>>
>>
>>Billy wrote:
>>
>>>Hello,
>>>
>>>I'm looking to extract all our users and the dates that 
>>>they were created into an excel spread***.  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
>>>
>>
>>.
>>

Quantcast