djhawthorn
Technical User
I need to search Active Directory to find an object (if it exists) by its GUID. I have the following code:
But it doesn't work - it always returns 0 objects, even though the object with that GUID exists.
I must be doing something wrong - ideas? Solutions? Any help greatly appreciated!
MCSE NT4/W2K
Code:
'GUID of object: {D5E43637-B3CE-4E80-A276-F70F82B7CF3C}
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://dc=retra3000,dc=com>"
strFilter = "(&(objectGuid=\D5\E4\36\37\B3\CE\4E\80\A2\76\F7\0F\82\B7\CF\3C))"
strAttributes = "displayName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
WScript.Echo objRecordSet.RecordCount & " objects found."
objConnection.Close
But it doesn't work - it always returns 0 objects, even though the object with that GUID exists.
I must be doing something wrong - ideas? Solutions? Any help greatly appreciated!
![[auto] [auto] [auto]](/data/assets/smilies/auto.gif)