我刚刚开始处理LDAP
并尝试在PHP
和{}之间建立联系。 LDAP
。
我创建了一个小脚本,通过引用this获取所有属性信息 脚本。
$ldap_server = "My_Server_Name";
$ldap_user = "uid=platypus,ou=users,dc=crowd";
$ldap_pass = "My_Password";
$ad = ldap_connect($ldap_server);
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
$bound = ldap_bind($ad, $ldap_user, $ldap_pass);
$result = ldap_read($ad, $ldap_user, "objectClass=*");
$attributes = ldap_get_attributes($ad, $result);
echo "<pre>";
print_r($attributes);
连接成功,绑定也正常,ldap_read
也给了我#resourse id
但ldap_get_attributes
给了我以下错误:
PHP警告 - yii \ base \ ErrorException ldap_get_attributes():提供的资源不是有效的ldap结果条目资源
任何帮助都将不胜感激。
由于
答案 0 :(得分:1)
ldap_get_attributes() expects the input parameter to be a reference to a single entry not to the complete resultset as stated on the ldap_get_attributes-documentation.
Have a look at ldap_get_first() or ldap_get_next() to get such a single entry reference.
Thanks to tejesh s for pointing in the right direction. I originally wanted to improve his answer but it was too much change :/
答案 1 :(得分:0)
ldap_get_attributes()期望输入参数是单个条目而不是数组。 http://php.net/manual/en/function.ldap-get-attributes.php
我希望这会对你有所帮助。