Q

Finding the creation date of objects

I want to make a script where the filter is the creation date of the User.

Where can I find the creation date of an object, like Users? I want to make a script where the filter is the creation date of the User. I hope you can help me.
Here is a snippet of a VBScript:
strContainer = "users"
strName = "phinsberg"


dim strname
On Error Resume Next
'***********************************************
'* Connect to an object *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
 Set objItem = GetObject("LDAP://" & _
 objRootDSE.Get("defaultNamingContext"))
Else
 Set objItem = GetObject("LDAP://cn=" & strName & "," & strContainer & "," & _
 objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'* End connect to an object *
'***********************************************
WScript.Echo VbCrLf & "** General Properties Page**"
WScript.Echo "** (Single-Valued Attributes) **"
strname = objItem.Get("name")
WScript.Echo "name: " & strname

WScript.Echo VbCrLf & "** Object Properties Page**"
WScript.Echo "** (Single-Valued Attributes) **"
strwhenCreated = str(objItem.Get("whencreated"))
WScript.Echo "whenCreated: " & strwhenCreated
strwhenChanged = objItem.Get("whenChanged")
WScript.Echo "whenChanged: " & strwhenChanged
The rather odd thing is the unusual inconsistency with actually retrieving the dates at times. This script is looking for the OU=users and the object=phinsberg. You can use the same process iteratively to retrieve multiple users. Like I said though, the problem is the seemingly inconsistent behavior of retrieving the date attributes. You can view the information on a user account from the ADSIEdit MMC, but the ADSI script engine sometimes has a problem.

Additional Expert Help: Be sure to check our Answer FAQ for more expert advice. For faster answers, visit ITKnowledge...

Exchange.

This was first published in December 2004

Dig Deeper

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close