0

PHP から LDAP への認証スクリプトを作成しています。私の問題は、ユーザーが管理者でない場合にユーザーを確認する方法が本当にわからないことです。

よくわかりません。ldap_bindここでは、管理者ユーザーとしてしかログインできませんが、ou で他のユーザーを検索できますが、パスワードを確認する方法がわかりません。

私がこれまでに持っているもの:

function login($up, $pw){
    $ldap = ldap_connect("dejan.local") or die("Could not connect to LDAP server.");

    if ($ldap){
        ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
        ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);

        //if I try $up and $pw here, I get an error
        if ($bind = ldap_bind($ldap, "Admin", "Somepassword")){
            $sr = ldap_search($ldap, "ou=testunit,DC=dejan,DC=local", "samaccountname=$up");
            $info = ldap_get_entries($ldap, $sr);

            //so here I've gotten information from the user $up
            //but I would like to check if his password matches and then get his information    
        }
    }
}

私は他の人からある種の認証スクリプトを見て、彼らは を通じて情報をチェックしましたldap_bindが、私は自分の管理者ユーザーとしか接続できません。

4

1 に答える 1

1

必要な変更は次のとおりだと思います。

if ($bind = ldap_bind($ldap, "$up@dejan.local", $pw)){

これにより、リクエストが特定のドメインに対してローカルになります。Active Directory (これは多少異なり、Kerberos のせいです) では、ログイン用のコンテキストを提供する必要があります。

于 2012-08-11T23:04:07.653 に答える