ldap_search() by GUID in AD with Php

22 Views Asked by At

I am beginner (and sorry for my english). I develop a php API to interact with LDAP directories. I would search users by their objectGUID in my AD. I can't search for more than 2 characters...

I tried to apply this method found on phpdoc of ldap_search() :

ldap_search($ds,"dc=blahblah,dc=com", "(objectGUID=\\AE\\C3\\23\\35\\F7)");

but i don't how to replace AE, C3, ...

With $id = "4a3ef66a-ff9f-4e84-ad8d-dd3378e8df19";


I tried to start with a simple problem :

$filters = "(objectGUID=*\\4a*)"; //(objectGUID=*\4a*)

-> It works ! An user is found.


I tried with more :

$filters = "(objectGUID=*\\4a3e*)"; //(objectGUID=*\4a3e*)

-> ldap_search($filters, [...]) then ldap_get_entries() : count=0


I tried :

$filters = "(objectGUID=*\\4a\\3e*)"; //(objectGUID=*\4a\3e*)

-> ldap_search($filters, [...]) then ldap_get_entries() : count=0


I tried :

$filters = "(objectGUID=*\\4a-3e*)"; //(objectGUID=*\4a-3e*)

-> ldap_search($filters, [...]) then ldap_get_entries() : count=0


I tried :

$filters = "(objectGUID=*\\4a*3e*)"; //(objectGUID=*\4a*3e*)

-> ldap_search($filters, [...]) then ldap_get_entries() : count=0


Do you know a good way to search an user in AD by objectGUID with Php ?

Thank you.

1

There are 1 best solutions below

0
jwilleke On

You filter needs to be something like

(objectGUID=\90\39\5F\19\1A\B5\1B\4A\9E\96\86\C6\6C\B1\8D\11)

objectGUID are stored in Microsoft Active Directory as a "relicaLink" which appears to be like an octetString. I do not think substring searches will work.

More info at: https://ldapwiki.com/wiki/Wiki.jsp?page=ObjectGUID