Created
October 31, 2012 17:39
-
-
Save Chaz6/3988566 to your computer and use it in GitHub Desktop.
List newly created objects in an Active Directory domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On Error Resume Next | |
Const ADS_SCOPE_SUBTREE = 2 | |
Dim strTimestamp | |
strTimestamp = "20120901000000.0Z" | |
set objRootDSE = GetObject("LDAP://RootDSE") | |
RootDN = objRootDSE.Get("defaultNamingContext")) | |
Set objConnection = CreateObject("ADODB.Connection") | |
Set objCommand = CreateObject("ADODB.Command") | |
objConnection.Provider = "ADsDSOObject" | |
objConnection.Open "Active Directory Provider" | |
Set objCommand.ActiveConnection = objConnection | |
objCommand.Properties("Page Size") = 1000 | |
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE | |
strQuery = "SELECT ADsPath FROM 'LDAP://RootDN & "' WHERE objectCategory='user' AND whenCreated>='" & strTimestamp & "'" | |
objCommand.CommandText = strQuery | |
Set objRecordSet = objCommand.Execute | |
objRecordSet.MoveFirst | |
Do Until objRecordSet.EOF | |
Wscript.Echo objRecordSet.Fields("ADsPath").Value | |
objRecordSet.MoveNext | |
Loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment