Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP&;LDAP-从sAMAccountName检索用户属性_Php_Ldap - Fatal编程技术网

PHP&;LDAP-从sAMAccountName检索用户属性

PHP&;LDAP-从sAMAccountName检索用户属性,php,ldap,Php,Ldap,是否可以使用用户凭据绑定到ldap服务器并返回该用户的OU成员身份详细信息 我正在创建一个系统,用户在其中登录,与LDAP服务器绑定,并根据他们是适当视图的成员而呈现 目前,我可以返回有关用户的一些详细信息,但它要求我使用用户CN。我希望用户不必输入自己的姓名 $user='xxx'; $pass='yyy'; $ldaprdn = $user.'@x.xxx.com'; // ldap rdn or dn :: We concatenate the username with

是否可以使用用户凭据绑定到ldap服务器并返回该用户的OU成员身份详细信息

我正在创建一个系统,用户在其中登录,与LDAP服务器绑定,并根据他们是适当视图的成员而呈现

目前,我可以返回有关用户的一些详细信息,但它要求我使用用户CN。我希望用户不必输入自己的姓名

$user='xxx';
$pass='yyy';
    $ldaprdn  = $user.'@x.xxx.com';     // ldap rdn or dn :: We concatenate the username with the domain to create the proper string for querying the ldap server
    $ldappass = $pass;  // associated password

    $ldapconn = ldap_connect("x.xxx.com")
            or die("Could not connect to LDAP server.");

        if ($ldapconn) {
            // binding to ldap server
            $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
        }

            // verify binding
            if ($ldapbind) {
            $ds = 'nx.xxx.com';
            $dn ="cn=Jonathan Rxxxr,OU=MIS Department,OU=People,DC=x,DC=xxx,dc=com";
            $filter="(objectClass=user)";

            $justthese = array("ou", "sn", "dn", "givenname", "mail");

             $sr=ldap_search($ldapconn, $dn, $filter, $justthese);

            $info = ldap_get_entries($ldapconn, $sr);
            $ou = strtolower($info[0]["mail"][0]);
            echo $ou;
            print_r($info);//I print the array just for debugging purposes

                echo $info["count"]." entries returned\n";
                echo "success";

我不能完全理解这个问题。你说你不想让用户输入她的名字,但另一方面,用户应该通过服务器的身份验证。如果不提供名称怎么办?如果他们已经通过windows登录,如果您使用的是apache,那么您可以使用modauthspi获取用户名