简体   繁体   中英

ldap get objectguid (php ldap) with ldap_search

I've an Application whith searches our ldap and saves a few attributes in a cache. It's no problem to get attributes like mail displayname sn etc. but I dont get the objectguid. Maybe its just a display error course the object id is in oktett or binary format. But i dont know exaktly if Im only not able to show the objectguid or if ldap doesnt give me the objectguid.

my code is

  $filter="(&(!(pager=))(!(pager=NO_MA)))";
  $justthese = array("ou", "sn", "givenname", "mail", "pager","objectGUID");            
  $sr=ldap_search($ad, $basedn, $filter, $justthese);            
  $info = ldap_get_entries($ad, $sr);

i've tried different filters and without justthese i get always the same value in $myarray[$number][objectguid][0]. It is always NULL. A few trys after i got an output but with ldap_first_entry. but i want to get the value like all other values! ive allready tryed to convert the guid with bin2hex() and unpack("H*hex,$guid") <- tryed different methodes, but i got the same value (NULL). btw i build my array like this:

 for ($i=0; $i<count($info); $i++) 
  {
      $myarray['ldap'][$i]["name"]      = utf8_decode($info[$i]["givenname"][0]);
      $myarray['ldap'][$i]["sname"]             = utf8_decode($info[$i]["sn"][0]);
      $myarray['ldap'][$i]["mail"]           = $info[$i]["mail"][0];
      $myarray['ldap'][$i]["pnr"]            = $info[$i]["pager"][0];

      $myarray['ldap'][$i]["guid"]           = $info[$i]["objectGUID"][0];
   }

did anyone have a idea to fix my problem? or know a better way to read the complete ad ( with filters and OBJECTGUID ) into an array?

thank you verry mutch if you answer...

try this

$myarray['ldap'][$i]["guid"] = mssql_guid_string($info[$i]["objectGUID"][0]);

more info at http://www.php.net/manual/en/function.mssql-guid-string.php

ObjectGUID must be lowercase like "objectguid"

$objectguid = bin2hex($entries['objectguid'][0]);
echo "Object Guid: ". $objectguid;

Result:

Object Guid: 362b6d25af3c9a42a23235e2c6c5e380

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM