dongwei2983 2013-03-15 10:50
浏览 316

ldap使用ldap_search获取objectguid(php ldap)

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...

  • 写回答

2条回答 默认 最新

  • drbuowqe02101 2014-04-21 10:24
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?