go-ldap / ldap

Basic LDAP v3 functionality for the GO programming language.
Other
2.22k stars 353 forks source link

Question: How can I filter by objectGUID against Active Directory #428

Closed crobby closed 1 year ago

crobby commented 1 year ago

I'm aiming to issue a search against Active Directory and filtering by the objectGUID attribute.

My search is successful using ldapsearch from the command line (relevant part of query below)

ldapsearch ...... 'cn=Users,dc=qa,dc=home,dc=space' '(&(objectClass=person)(objectGUID=\95\3d\82\a0\3d\47\a5\49\83\30\29\3e\38\6d\fc\e1))'

But when issuing the query through this library, I'm not getting any results.
It seems like dealing with GUID is already a bit special since it has to be decoded to be readable and then re-encoded to use it in the search, so it's very possible I'm not using a correctly encoded search string. I'm hoping someone can shed some light on this for me. Thanks

crobby commented 1 year ago

Answering my own question in case anyone else ever runs into this. Our code was setting the scope to base object (whereas ldapsearch was defaulting to another value), which would not include the user we're filtering for. In order to have the filter work as desired, I changed the scope and that allowed me to get the results I wanted.