php ldap_get_values()超过1个值

时间:2015-09-17 12:49:27

标签: php

我在使用LDAP身份验证的脚本中使用ldap_get_values函数。

我的问题是:

是否可以在一个value中提取多个query(顾名思义'值')?或者它是否必须循环(这对我来说真的没有意义,因为这意味着多次查询AD会效率低下?

我目前的职能是:

ldap_get_values($ds, $entry, "mail"); 

它会提取邮件值。

1 个答案:

答案 0 :(得分:0)

我发现我需要在ldap_search函数中使用另一个属性,如下所示:

// Call function to check which MS SQL database driver extension is loaded
$mssql_db_driver = get_db_loaded_extension();

// Switch to determine how to make the appropriate connection
switch($mssql_db_driver) {
    case "mssql":
        // Set the MSSQL database variables
        $mssql_servername = "xxx.xxx.xxx.xxx";
        $mssql_username = "my_user";
        $mssql_password = "**********";

        // Create conection to MSSQL using the mssql php extension
        $mssql_conn = mssql_connect($mssql_servername, $mssql_username, $mssql_password);
        break;

    case "sqlsrv":
        // Set the MSSQL database variables
        $mssql_servername = "xxx.xxx.xxx.xxx";
        $mssql_conn_info = array(
          "UID" => "my_user",
          "PWD"=> "**********"
        );

        // Create conection to MSSQL using the sqlsrv php extension
        $mssql_conn = sqlsrv_connect($mssql_servername, $mssql_conn_info);
        break;

    default:
        echo $mssql_db_driver;
        break;
}

// Check the MSSQL connection
if(!$mssql_conn) {
    exit("Could not connect to the database. Please contact the administrator.");
}