Finding the creation date of objects

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.

    Requires Free Membership to View

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

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.