我有一个应用程序,它可以搜索我们的ldap并在缓存中保存一些属性。获取诸如mail、displayname、sn等属性是没有问题的,但我不能获取objectguid。也许这只是一个显示错误过程,对象id是oktett或二进制格式。但是我不能确切地知道,如果我只是不能显示objectguid,或者ldap没有给我objectguid。
我的代码是
$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);我尝试过不同的过滤器,没有这些过滤器,我在$myarray$number中总是得到相同的值。它始终为空。在我得到一个输出之后,我尝试了几次,但是用的是ldap_first_entry。但我想要像所有其他值一样获得值!我已经尝试过用bin2hex()和unpack("H*hex,$guid") <-尝试不同的方法来转换guid,但是我得到了相同的值(NULL)。顺便说一句,我这样构建我的数组:
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];
}有没有人有办法解决我的问题?或者知道更好的方法将完整的广告(带有过滤器和OBJECTGUID )读入数组?
谢谢你,如果你回答..。
发布于 2014-04-21 18:24:04
尝尝这个
$myarray['ldap'][$i]["guid"] = mssql_guid_string($info[$i]["objectGUID"][0]);
欲了解更多信息,请访问http://www.php.net/manual/en/function.mssql-guid-string.php
发布于 2017-05-23 18:37:18
ObjectGUID必须是小写的,如"objectguid“
$objectguid = bin2hex($entries['objectguid'][0]);
echo "Object Guid: ". $objectguid;结果:
Object Guid: 362b6d25af3c9a42a23235e2c6c5e380https://stackoverflow.com/questions/15430456
复制相似问题