function LdapServer::bind in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_servers/LdapServer.class.php \LdapServer::bind()
- 7.2 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.
2 calls to LdapServer::bind()
- 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_servers/
tests/ LdapServerTest.class.php - * Bind (authenticate) against an active LDAP database. * *
File
- ldap_servers/
LdapServer.class.php, line 252 - 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) {
if (@(!ldap_bind($this->connection))) {
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))) {
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;
}