PHP Openldap检索所有请求的属性,但;地点“;

PHP Openldap检索所有请求的属性,但;地点“;,php,attributes,openldap,Php,Attributes,Openldap,我正在制作一种电话簿,一切都很好: 连接和身份验证非常有效 研究也在进行中 我可以修改用户的属性 然后,我的老板让我添加法语中的Location属性,也就是“Bureau”,但openldap不会检索它,只会检索它 代码如下: $attributes = array(); $attributes[] = 'givenname'; $attributes[] = 'sn'; $attributes[] = 'samaccountname'; $attributes[] = 'mail'; $a

我正在制作一种电话簿,一切都很好:

  • 连接和身份验证非常有效
  • 研究也在进行中
  • 我可以修改用户的属性
然后,我的老板让我添加法语中的Location属性,也就是“Bureau”,但openldap不会检索它,只会检索它

代码如下:

$attributes = array();
$attributes[] = 'givenname';
$attributes[] = 'sn';
$attributes[] = 'samaccountname';
$attributes[] = 'mail';
$attributes[] = 'telephonenumber';
$attributes[] = 'useraccountcontrol';
$attributes[] = 'dn';
$attributes[] = 'location';

/*------------------------------------------------------------------------------*/
if ($ldap_bind) // Si la connexon s'est effectuée
{
    // Query sur LDAP
    $resultat = ldap_search($ldap_connect, $dn, $search_filter, $attributes) or die('Une erreur est survenue pendant la recherche.');

    // Transformation de l'objet LDAP en données explotables
    $entries = ldap_get_entries($ldap_connect, $resultat);
但是当Ivar\u dump($entries)时,location属性不在数组中,就像name属性出错一样。但根据我的理解,它是正确拼写的属性


因此,现在我向您求助,希望有人能在这个问题上提供帮助。

在LDAP中,如果未设置属性,则不会将其检索为空,但不会在响应条目数组中设置


检索条目的每个属性并将其var_dump以查看是否已设置

您是否已使用其他方法确认DN
$DN
的条目具有
位置
属性?此外,请确保您用来进行查询的凭据可以访问
位置
属性。它将检索从“givenname”到“dn”的所有属性(因此,如果它可以获取“usersaccountcontrol”,它也应检索“location”)。用于连接的帐户具有管理员权限,因此应该可以。是的,我正在测试的entrie的location属性中填充了“Helpdesk”。您说您使用的帐户具有“管理员权限”。OpenLDAP使用灵活的ACL来控制访问:您可以转储ACL并为进行访问的帐户提供相关的ACL行吗?对不起,我完全忘了将此问题标记为已回答。我使用了错误的属性(它是“office”,我之前已经测试过它,但后来它工作了。)