PHP(5.3.2)/ Apache(2.0.59)/ Windows(2003)を使用してActive Directoryに認証しようとしています。PHPを使用してActive Directoryに接続するときにldap.confが必要ですか?
しかし、私は次のエラー取得しています:
ldap_start_tls()[function.ldapスタート-TLS]:TLSを開始できません:Eのエラーを接続します。ライン15の\ my_page.phpをここで
は私の現在のスクリプトです:
putenv('LDAPTLS_REQCERT=never');
$resource = ldap_connect("xxx")
or die("Failed to connect to LDAP server.");
echo "Connected to LDAP server.<br />";
//these options may not be necessary in all environments
ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($resource, LDAP_OPT_REFERRALS, 0);
$result = ldap_start_tls($resource) or die("Failed to start TLS.<br />");
echo "Started TLS.<br />";
$result = ldap_sasl_bind($resource, NULL, '', 'GSSAPI', 'xxx', '', '')
or die("Failed to GSSAPI bind.<br />");
echo "GSSAPI bound.";
私はthis question for helpを見てきました、しかし、私はのldap.confへの参照を見ておきます。
これはOpenLDAPの場合と同様に、接続先のLDAPサーバーですか?そうであれば、既存のEnteprise Active Directoryを使用するため、無視することができますか?
これは、LDAPサーバー(つまり、ldap_connect())に接続するPHPライブラリ用ですか? Wiresharkのの
編集#1
スクリーンショット...私はそこに見
、未知のCAは...どのように私は(オンラインATMを見て)これを解いて行くでしょう。
編集#2
更新、私は今、別のエラーを取得しています。 ldap.confの
コンテンツにsysconf \ OpenLDAPの\:\とC:私はC上のldap.confを作成
今#
# LDAP Defaults
#
TLS_REQCERT never
、それは正常ですldap_sasl_bind方法で立ち往生しています - それがインストールされていません。あなたは、未知のCAとの正しい軌道に乗っている
function isAuthenticated($user, $pass){
//init
$ldap_server = "";
$ldap_user = "";
$ldap_pass = "";
$ldap_dn = "";
$ldap_filter_fields = array("dn","cn","samaccountname");
//establish connection
$ldap_conn = ldap_connect($ldap_server)
or die("Failed to connect to LDAP server.");
//these options may not be necessary in all environments
ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($resource, LDAP_OPT_REFERRALS, 0);
//Magic happens here, encrypted tunnel starts!
$result = ldap_start_tls($ldap_conn) or die("Failed to start TLS.<br />");
$out = 0;
//connect using our known user
if($bind = ldap_bind($ldap_conn, $ldap_user, $ldap_pass)){
//search for the user
$ldap_search_results = ldap_search($ldap_conn, $ldap_dn, "samaccountname=".$user, $ldap_filter_fields) or die ("Failed to search LDAP");
//get entry
$ldap_record = ldap_get_entries($ldap_conn, $ldap_search_results);
debug($ldap_record);
if($ldap_record["count"] > 0){
//try to authenticate user here
if($bind2 = @ldap_bind($ldap_conn, $ldap_record[0]["dn"], $pass))
$out = 1;
else
//wrong password
$out = 0;
}
else
//user wasn't found
$out = 3;
}
else
//something happened when connecting with our ldap_user
$out = 2;
return $out;
}
LDAPクライアントがTLSへの接続を促進しようとした場合に、A/Dからのログなどの情報を投稿できます。 –
@TerryGardner私の編集を参照してください。私はWiresharkのスクリーンショットを含めました。私は未知のCAを持っているようですか? – TekiusFanatikus