Ask the Expert

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: