| 1 |
<?php |
<?php |
| 2 |
// $Id: LDAPInterface.inc,v 1.4 2009/07/28 14:03:06 miglius Exp $ |
// $Id: LDAPInterface.inc,v 1.5 2009/08/25 14:17:59 miglius Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 130 |
|
|
| 131 |
function initConnection() { |
function initConnection() { |
| 132 |
if (!$con = ldap_connect($this->server, $this->port)) { |
if (!$con = ldap_connect($this->server, $this->port)) { |
| 133 |
watchdog('user', 'LDAP Connect failure to '. $this->server .':'. $this->port); |
watchdog('ldap', 'LDAP Connect failure to @server:@port', array('@server' => $this->server, '@port' => $this->port), WATCHDOG_ERROR); |
| 134 |
return; |
return; |
| 135 |
} |
} |
| 136 |
|
|
| 140 |
if ($this->tls) { |
if ($this->tls) { |
| 141 |
ldap_get_option($con, LDAP_OPT_PROTOCOL_VERSION, $vers); |
ldap_get_option($con, LDAP_OPT_PROTOCOL_VERSION, $vers); |
| 142 |
if ($vers == -1) { |
if ($vers == -1) { |
| 143 |
watchdog('user', 'Could not get LDAP protocol version.'); |
watchdog('ldap', 'Could not get LDAP protocol version.', array(), WATCHDOG_ERROR); |
| 144 |
return; |
return; |
| 145 |
} |
} |
| 146 |
if ($vers != 3) { |
if ($vers != 3) { |
| 147 |
watchdog('user', 'Could not start TLS, only supported by LDAP v3.'); |
watchdog('ldap', 'Could not start TLS, only supported by LDAP v3.', array(), WATCHDOG_ERROR); |
| 148 |
return; |
return; |
| 149 |
} |
} |
| 150 |
else if (!function_exists('ldap_start_tls')) { |
else if (!function_exists('ldap_start_tls')) { |
| 151 |
watchdog('user', 'Could not start TLS. It does not seem to be supported by this PHP setup.'); |
watchdog('ldap', 'Could not start TLS. It does not seem to be supported by this PHP setup.', array(), WATCHDOG_ERROR); |
| 152 |
return; |
return; |
| 153 |
} |
} |
| 154 |
else if (!ldap_start_tls($con)) { |
else if (!ldap_start_tls($con)) { |
| 155 |
watchdog('user', t("Could not start TLS. (Error %errno: %error).", array('%errno' => ldap_errno($con), '%error' => ldap_error($con)))); |
watchdog('ldap', 'Could not start TLS. (Error %errno: %error).', array('%errno' => ldap_errno($con), '%error' => ldap_error($con)), WATCHDOG_ERROR); |
| 156 |
return; |
return; |
| 157 |
} |
} |
| 158 |
} |
} |
| 164 |
|
|
| 165 |
$con = $this->connection; |
$con = $this->connection; |
| 166 |
if (!$this->bind($dn, $pass)) { |
if (!$this->bind($dn, $pass)) { |
| 167 |
watchdog('user', 'LDAP Bind failure for user %user. Error %errno: %error', array('%user' => $dn, '%errno' => ldap_errno($con), '%error' => ldap_error($con))); |
watchdog('ldap', 'LDAP Bind failure for user %user. Error %errno: %error', array('%user' => $dn, '%errno' => ldap_errno($con), '%error' => ldap_error($con))); |
| 168 |
return NULL; |
return NULL; |
| 169 |
} |
} |
| 170 |
|
|