function LdapServer::bind in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_servers/LdapServer.class.php \LdapServer::bind()
- 7 ldap_servers/LdapServer.class.php \LdapServer::bind()
* Bind (authenticate) against an active LDAP database. * *
Parameters
$userdn: * The DN to bind against. If NULL, we use $this->binddn * @param $pass * The password search base. If NULL, we use $this->bindpw
Return value
Result of bind; TRUE if successful, FALSE otherwise.
5 calls to LdapServer::bind()
- LdapServer::connectAndBindIfNotAlready in ldap_servers/
LdapServer.class.php - LdapServer::createLdapEntry in ldap_servers/
LdapServer.class.php - create ldap entry.
- LdapServer::delete in ldap_servers/
LdapServer.class.php - Perform an LDAP delete.
- LdapServer::search in ldap_servers/
LdapServer.class.php - Perform an LDAP search.
- LdapServer::__invoke in ldap_servers/
LdapServer.class.php - Invoke Method
1 method overrides LdapServer::bind()
- LdapServerTest::bind in ldap_test/
LdapServerTest.class.php - * Bind (authenticate) against an active LDAP database. * *
File
- ldap_servers/
LdapServer.class.php, line 293 - Defines server classes and related functions.
Class
- LdapServer
- LDAP Server Class
Code
function bind($userdn = NULL, $pass = NULL, $anon_bind = FALSE) {
// Ensure that we have an active server connection.
if (!$this->connection) {
watchdog('ldap', "LDAP bind failure for user %user. Not connected to LDAP server.", array(
'%user' => $userdn,
));
return LDAP_CONNECT_ERROR;
}
if ($anon_bind !== FALSE && $userdn === NULL && $pass === NULL && $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON) {
$anon_bind = TRUE;
}
if ($anon_bind === TRUE) {
if (@(!ldap_bind($this->connection))) {
if ($this->detailedWatchdogLog) {
watchdog('ldap', "LDAP anonymous bind error. Error %errno: %error", array(
'%errno' => ldap_errno($this->connection),
'%error' => ldap_error($this->connection),
));
}
return ldap_errno($this->connection);
}
}
else {
$userdn = $userdn != NULL ? $userdn : $this->binddn;
$pass = $pass != NULL ? $pass : $this->bindpw;
if (drupal_strlen($pass) == 0 || drupal_strlen($userdn) == 0) {
watchdog('ldap', "LDAP bind failure for user userdn=%userdn, pass=%pass.", array(
'%userdn' => $userdn,
'%pass' => $pass,
));
return LDAP_LOCAL_ERROR;
}
if (@(!ldap_bind($this->connection, $userdn, $pass))) {
if ($this->detailedWatchdogLog) {
watchdog('ldap', "LDAP bind failure for user %user. Error %errno: %error", array(
'%user' => $userdn,
'%errno' => ldap_errno($this->connection),
'%error' => ldap_error($this->connection),
));
}
return ldap_errno($this->connection);
}
}
return LDAP_SUCCESS;
}