我現在花費了足夠的時間來研究這個問題,可以說 LDAP 轉介,至少在嘗試在正確地將轉介給主伺服器的從伺服器上新增、修改或刪除記錄時,在 PHP 中是無法運作的。我的建議是關閉 LDAP 轉介,並使用內建的轉介處理來編寫您自己的新增、修改和刪除函式。如下所示:
<?php
function ldap_referral_add($connection,$add_dn,$Add_entry,$bind_dn,$bind_pw)
{
$rconnection = $connection;
$loop = 10; ldap_get_option($connection,LDAP_OPT_REFERRALS,$old_referral_setting)
do
{
$response = ldap_add($rconnection,$dn,$entry);
if ( $response )
{
ldap_unbind($rconnection);
$loop = 0; ldap_set_option($connection,LDAP_OPT_REFERRALS,$old_referral_setting);
return true;
}
elseif ( !$response && ldap_errno($rconnection) == 0x0a )
{
$new_server_url = $server= preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $ldap_error($rconnection)); $rconnection = ldap_connect($new_server_url);
ldap_set_option($rconnection,LDAP_OPT_REFERRALS,0)
ldap_set_option($rconnection,LDAP_OPT_PROTOCOL_VERSION, 3)
ldap_bind($rconnection,$bind_dn,$bind_pw);
$loop = $loop - 1;
}
else
{
ldap_unbind($rconnection);
$loop = 0; ldap_set_option($connection,LDAP_OPT_REFERRALS,$old_referral_setting);
return false;
}
} while ( $loop > 0);
}
?>