function ldapConnect2($refer = false) { $ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['ldap_server']['host']); if (!$ds) { return false; } ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ds, LDAP_OPT_REFERRALS, $refer); if ($refer) { ldap_set_rebind_proc($ds, 'rebind'); } @ldap_bind($ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'], $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); return $ds; }
function connect($host = '', $dn = '', $passwd = '', $ldapreferral = false) { if (!$host || $host == $GLOBALS['phpgw_info']['server']['ldap_host']) { $dn = $dn ? $dn : $GLOBALS['phpgw_info']['server']['ldap_root_dn']; $passwd = $passwd ? $passwd : $GLOBALS['phpgw_info']['server']['ldap_root_pw']; $host = $host ? $host : $GLOBALS['phpgw_info']['server']['ldap_host']; } $conection = ldap_connect($host); if (!ldap_set_option($conection, LDAP_OPT_PROTOCOL_VERSION, 3)) { $GLOBALS['phpgw_info']['server']['ldap_version3'] = False; } ldap_set_option($conection, LDAP_OPT_REFERRALS, $ldapreferral); if ($ldapreferral) { $GLOBALS['phpgw_info']['server']['user_ldap_referral'] = $dn; $GLOBALS['phpgw_info']['server']['password_ldap_referral'] = $passwd; ldap_set_rebind_proc($conection, ldap_rebind); } if ($dn && $passwd && !@ldap_bind($conection, $dn, $passwd)) { @ldap_bind($conection, $dn, $passwd); } $this->connection = $conection; return $conection; }
public function rebind_callback($ldap, $referral) { // ldap options ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap, LDAP_OPT_REFERRALS, 1); ldap_set_rebind_proc($ldap, array($this, 'rebind_callback')); // Bind to new host, assumes initial bind dn has access to the referred servers. if (!ldap_bind($ldap, $this->bind_dn, $this->bind_passwd)) { echo "Could not bind to referral server: {$referral}"; return 1; } return 0; }
/** * Set a callback function to do re-binds on referral chasing. * * @param callable $callback * * @return bool */ public function setRebindCallback(callable $callback) { if ($this->suppressErrors) { return @ldap_set_rebind_proc($this->getConnection(), $callback); } return ldap_set_rebind_proc($this->getConnection(), $callback); }
<?php require "connect.inc"; function rebind_proc($ds, $ldap_url) { global $user; global $passwd; global $protocol_version; // required by most modern LDAP servers, use LDAPv3 ldap_set_option($a, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); if (!ldap_bind($a, $user, $passwd)) { print "Cannot bind"; } } $link = ldap_connect($host, $port); var_dump(ldap_set_rebind_proc($link)); var_dump(ldap_set_rebind_proc($link, "rebind_proc", "Additional data")); var_dump(ldap_set_rebind_proc($link, "rebind_proc_inexistent")); ?> ===DONE===
/** * {@inheritdoc} */ public function setRebindCallback(callable $callback) { return ldap_set_rebind_proc($this->getConnection(), $callback); }
<?php require "connect.inc"; function rebind_proc($ds, $ldap_url) { global $user; global $passwd; global $protocol_version; // required by most modern LDAP servers, use LDAPv3 ldap_set_option($a, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); if (!ldap_bind($a, $user, $passwd)) { print "Cannot bind"; } } $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); var_dump(ldap_set_rebind_proc($link, "rebind_proc")); var_dump(ldap_set_rebind_proc($link, "")); ?> ===DONE===
/** * Set a callback function to do re-binds on referral chasing * * @param callable $callback * @return self */ public function setRebindProcedure(callable $callback) { @ldap_set_rebind_proc($this->resource, $callback); $this->verifyOperation(); return $this; }
<?php require "connect.inc"; function rebind_proc($ds, $ldap_url) { global $user; global $passwd; global $protocol_version; // required by most modern LDAP servers, use LDAPv3 ldap_set_option($a, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); if (!ldap_bind($a, $user, $passwd)) { print "Cannot bind"; } } $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); ldap_set_rebind_proc($link, "rebind_proc"); var_dump(ldap_unbind($link)); ?> ===DONE===
/** * @link http://php.net/manual/en/function.ldap-set-rebind-proc.php * @param $link * @param $callback * @return bool */ public function setRebindProc($link, $callback) { return ldap_set_rebind_proc($link, $callback); }
/** * @param callable $callback * @throws UnavailableException * @throws OptionFailureException */ public function setRebindProc(callable $callback) { $this->checkConnected(); if (!ldap_set_rebind_proc($this->link, $callback)) { throw new OptionFailureException(ldap_error($this->link), ldap_errno($this->link)); } }
{ @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'], $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); } if ($_SESSION['phpgw_info']['expressomail']['user']['account_lid'] == '') { exit; } $mail = $_GET['mail']; if (!preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+$/i', $mail)) { exit; } $ldap_host = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host']; $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; $ldap_conn = ldap_connect($ldap_host); ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); ldap_set_rebind_proc($ldap_conn, ldapRebind); $r = ldap_bind($ldap_conn, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'], $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); if (!$r) { echo 'Sem BIND: ' . ldap_error($ldap_conn); exit; } $justthese = array("jpegPhoto"); $filter = "(mail={$mail})"; $search = ldap_search($ldap_conn, $ldap_context, $filter, $justthese); $entry = ldap_first_entry($ldap_conn, $search); $contact = ldap_get_attributes($ldap_conn, $entry); if ($contact['jpegPhoto']) { $contact['jpegPhoto'] = ldap_get_values_len($ldap_conn, $entry, "jpegPhoto"); $image = imagecreatefromstring($contact['jpegPhoto'][0]); } else { $loadFile = "../templates/default/images/photo.jpg";