Q. How can I create a list that includes all user profiles in a particular container and the date and time they were created?
September 7, 2004
A. I've created the following script, listusers.vbs, which passes the name of a Lightweight Directory Access Protocol (LDAP) container, then uses this name to generate a list all user profiles in the container and their creation date (GMT). You can download the script at Code. Save the script as listusers.vbs. Remember to modify it to include information specific to your installation.
'listusers.vbs' John Savill 19 August 2004Option ExplicitDim strLdapPath, objConnection, objChild, dtmCreate' Check that all required arguments have been passed.If Wscript.Arguments.Count required. For example:" & vbCrLf _ & "cscript listusers.vbs ou=testing,dc=demo,dc=test" Wscript.Quit(0)End IfstrLdapPath = Wscript.Arguments(0)Set objConnection = GetObject("LDAP://" & strLdapPath)objConnection.Filter = Array("user")For Each objChild In objConnection objChild.GetInfoEx Array("createTimeStamp"), 0 dtmCreate = objChild.Get("createTimeStamp") WScript.Echo objChild.Name & vbTab & dtmCreateNextWscript.Echo "Operation Completed"
I place the cscript command at the beginning of the call to the listusers.vbs file. Specifying cscript forces the script to run in the CScript (i.e., command window) environment. If you don't specify cscript, each user in the list will be displayed in a dialog box. In the sample code here, the passed LDAP container is an organizational unit (OU) called testing (ou=testing) in the demo.local domain (dc=demo,dc=local).
To run the script, at a command prompt enter
cscript listusers.vbs ou=testing,dc=demo,dc=local
You'll see output on screen that's similar to this:
Microsoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.CN=Barry Allen 6/2/2004 10:59:32 PMCN=Bruce Wayne 6/11/2004 6:30:40 PMCN=Clark Kent 6/2/2004 10:55:14 PMCN=DeleteMe 8/19/2004 4:02:04 PMOperation Completed
About the Author
You May Also Like