mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-23 00:43:48 +01:00
Fix reconnectAs() calls
This commit is contained in:
parent
d27a59f807
commit
fb62ce2eed
2 changed files with 25 additions and 16 deletions
|
@ -81,26 +81,27 @@ class LSldap extends LSlog_staticLoggerClass {
|
|||
* @param[in] $dn string Bind DN
|
||||
* @param[in] $pwd array Bind password
|
||||
* @param[in] $config array LDAP configuration array in format of Net_LDAP2
|
||||
* (optional, default: keep current)
|
||||
*
|
||||
* @retval boolean true if connected, false instead
|
||||
*/
|
||||
public static function reconnectAs($dn,$pwd,$config) {
|
||||
public static function reconnectAs($dn, $pwd, $config=null) {
|
||||
if ($config) {
|
||||
self :: setConfig($config);
|
||||
}
|
||||
if (self :: $cnx) {
|
||||
self :: $cnx -> done();
|
||||
}
|
||||
$config=self :: $config;
|
||||
$config['binddn']=$dn;
|
||||
$config['bindpw']=$pwd;
|
||||
self :: $cnx = Net_LDAP2::connect($config);
|
||||
if (Net_LDAP2::isError(self :: $cnx)) {
|
||||
LSerror :: addErrorCode('LSldap_01',self :: $cnx -> getMessage());
|
||||
self :: $cnx = NULL;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
if (self :: $cnx) {
|
||||
self :: $cnx -> done();
|
||||
}
|
||||
$config = self :: $config;
|
||||
$config['binddn'] = $dn;
|
||||
$config['bindpw'] = $pwd;
|
||||
self :: $cnx = Net_LDAP2::connect($config);
|
||||
if (Net_LDAP2::isError(self :: $cnx)) {
|
||||
LSerror :: addErrorCode('LSldap_01', self :: $cnx -> getMessage());
|
||||
self :: $cnx = NULL;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -786,7 +786,11 @@ class LSsession {
|
|||
self :: $userLDAPcreds = false;
|
||||
return;
|
||||
}
|
||||
if (!LSldap :: reconnectAs(self :: $userLDAPcreds['dn'],self :: $userLDAPcreds['pwd'])) {
|
||||
if (!LSldap :: reconnectAs(
|
||||
self :: $userLDAPcreds['dn'],
|
||||
self :: $userLDAPcreds['pwd'],
|
||||
self :: $ldapServer['ldap_config']
|
||||
)) {
|
||||
LSerror :: addErrorCode('LSsession_15');
|
||||
return;
|
||||
}
|
||||
|
@ -1239,7 +1243,11 @@ class LSsession {
|
|||
return;
|
||||
}
|
||||
if (self :: $dn && isset(self :: $ldapServer['useUserCredentials']) && self :: $ldapServer['useUserCredentials']) {
|
||||
LSldap :: reconnectAs(self :: $userLDAPcreds['dn'], self :: $userLDAPcreds['pwd'],self :: $ldapServer['ldap_config']);
|
||||
LSldap :: reconnectAs(
|
||||
self :: $userLDAPcreds['dn'],
|
||||
self :: $userLDAPcreds['pwd'],
|
||||
self :: $ldapServer['ldap_config']
|
||||
);
|
||||
}
|
||||
else {
|
||||
LSldap :: connect(self :: $ldapServer['ldap_config']);
|
||||
|
|
Loading…
Reference in a new issue