note 111417 added to function.ldap-set-rebind-proc
| From: | mvanbeekatforgetaboutitdotnet | Date: | Mon, 18 Feb 2013 12:15:27 +0000 |
| Subject: | note 111417 added to function.ldap-set-rebind-proc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193670@lists.php.net to get a copy of this message | ||
The $referral that is used in the callback function isn't the bind dn, but the dn of the record
that was being accessed (or rather it's location on the master server, I guess, if there is a
difference in the two), so you need to rebind with your existing credentials. The connection ($ldap)
appears to have already been made to the new server, so it is just a rebind process, nothing else
more complicated than that. There must be a loop in the underlying library that re-submits the
request that prompted the referral until either a success or fail is returned.
I guess if the bind dn you were using in the first place won't let you edit the record on the
master, then that is an ldap rather than php issue. However, at least with the rebind procedure you
have a way to modify the bind dn first.
So, the rebind process is really quite simple, now that I understand how it works! I was assuming it
to be way more complicated. In it's simplest form, this is all you need, assuming your bind $dn
and $pass are globals
function rebind($ldap, $referral) {
// Set ldap options
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, True);
ldap_set_rebind_proc($ldap, 'rebind');
// Rebind
if (!ldap_bind($ldap, $dn, $pass)) {
echo 'Could not bind to referral server';
return 1; // Yes, a 1 means a failure.
}
return 0; // Yes, return a 0 on success.
}
----
Server IP: 69.147.83.199
Probable Submitter: 83.136.70.54
----
Manual Page -- http://php.net/manual/en/function.ldap-set-rebind-proc.php
Edit -- https://master.php.net/note/edit/111417
Del: integrated -- https://master.php.net/note/delete/111417/integrated
Del: useless -- https://master.php.net/note/delete/111417/useless
Del: bad code -- https://master.php.net/note/delete/111417/bad+code
Del: spam -- https://master.php.net/note/delete/111417/spam
Del: non-english -- https://master.php.net/note/delete/111417/non-english
Del: in docs -- https://master.php.net/note/delete/111417/in+docs
Del: other reasons-- https://master.php.net/note/delete/111417
Reject -- https://master.php.net/note/reject/111417
Search -- https://master.php.net/manage/user-notes.php