function LDAPInterface::initConnection in LDAP integration 5.2
Same name and namespace in other branches
- 5 ldap_integration/LDAPInterface.php \LDAPInterface::initConnection()
- 6 includes/LDAPInterface.inc \LDAPInterface::initConnection()
1 call to LDAPInterface::initConnection()
- LDAPInterface::connectAndBind in ldap_integration/
LDAPInterface.php
File
- ldap_integration/
LDAPInterface.php, line 115
Class
Code
function initConnection() {
if (!($con = ldap_connect($this->server, $this->port))) {
watchdog('user', 'LDAP Connect failure to ' . $this->server . ':' . $this->port);
return NULL;
}
$this->connection = $con;
ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($con, LDAP_OPT_REFERRALS, 0);
// TLS encryption contributed by sfrancis@drupal.org
if ($this->tls) {
$vers = $this
->getOption('version');
if ($vers == -1) {
watchdog('user', 'Could not get LDAP protocol version.');
}
if ($vers != 3) {
watchdog('user', 'Could not start TLS, only supported by LDAP v3.');
}
else {
if (!function_exists('ldap_start_tls')) {
watchdog('user', 'Could not start TLS. It does not seem to be supported by this PHP setup.');
}
else {
if (!ldap_start_tls($con)) {
watchdog('user', t("Could not start TLS. (Error %errno: %error).", array(
'%errno' => ldap_errno($con),
'%error' => ldap_error($con),
)));
}
}
}
}
}