note 102653 added to function.ldap-set-rebind-proc

From: Date: Sat, 26 Feb 2011 19:40:10 +0000
Subject: note 102653 added to function.ldap-set-rebind-proc
Groups: php.notes 
Request: Send a blank email to php-notes+get-177360@lists.php.net to get a copy of this message
I have now spent enough time looking at this issue to say that ldap referrals, at least when trying to add, modify or delete a record on a slave server that correctly gives a referral to a master server, does not work in php. My suggestion is turn turn off ldap referrals and write your own add, modify and delete functions with built in referral handling. Something like this: function ldap_referral_add($connection,$add_dn,$Add_entry,$bind_dn,$bind_pw) { $rconnection = $connection; $loop = 10; # max number of referral hops. # Turn off normal referrals ldap_get_option($connection,LDAP_OPT_REFERRALS,$old_referral_setting) do { $response = ldap_add($rconnection,$dn,$entry); # We get a success message: if ( $response ) { ldap_unbind($rconnection); $loop = 0; # Probably not needed ldap_set_option($connection,LDAP_OPT_REFERRALS,$old_referral_setting); return true; } # We get a referral message: elseif ( !$response && ldap_errno($rconnection) == 0x0a ) { $new_server_url = $server= preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $ldap_error($rconnection)); # May need some sanity checking here $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; # Probably not needed ldap_set_option($connection,LDAP_OPT_REFERRALS,$old_referral_setting); return false; } } while ( $loop > 0); } ---- Server IP: 92.48.74.199 Probable Submitter: 83.136.70.54 ---- Manual Page -- http://www.php.net/manual/en/function.ldap-set-rebind-proc.php Edit -- https://master.php.net/note/edit/102653 Del: integrated -- https://master.php.net/note/delete/102653/integrated Del: useless -- https://master.php.net/note/delete/102653/useless Del: bad code -- https://master.php.net/note/delete/102653/bad+code Del: spam -- https://master.php.net/note/delete/102653/spam Del: non-english -- https://master.php.net/note/delete/102653/non-english Del: in docs -- https://master.php.net/note/delete/102653/in+docs Del: other reasons-- https://master.php.net/note/delete/102653 Reject -- https://master.php.net/note/reject/102653 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177360) next »