FancyPrairie
Programmer
We have just implemented AD and I have written a routine (in vba) that retrieves all of the users. For several reasons, we need to dump the information to a SQL table. This SQL table will not only be populated via AD but will also update AD with info. Consequently, to do a lookup, I need to use the objectGUID. But I don't know how to query AD by the objectGUID. My understanding is that objectGUID is a 16 byte array. I have attempted to convert the objectGUID to a string and search that way, but with no luck. Here's an example of my query which returns 0 records.
Note that objectGUID returns the following values:
202, 194, 223, 192, 158, 46, 91, 74, 129, 163, 225, 249, 165, 161, 234, 195
Some code I got off the internet converted this array to this string: {192223194202-46158-7491-163129-225249165161234195}
What am I doing wrong?
Note that objectGUID returns the following values:
202, 194, 223, 192, 158, 46, 91, 74, 129, 163, 225, 249, 165, 161, 234, 195
Some code I got off the internet converted this array to this string: {192223194202-46158-7491-163129-225249165161234195}
What am I doing wrong?
Code:
Dim objConnection As Object
Dim objCommand As Object
Dim objRecordSet As Object
On Error GoTo ErrHandler
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 2000
objCommand.CommandText = "SELECT displayName, distinguishedName, sAMAccountName, Department, Company, TelephoneNumber,L,Mail,Manager,objectGUID FROM 'LDAP://ou=MyCompany Users," & RootDSE & "' Where objectCategory='User' and displayName='*' and GUID = '{192223194202-46158-7491-163129-225249165161234195}'"
Set objRecordSet = objCommand.Execute