mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
some reorganization of code
This commit is contained in:
parent
eae779832f
commit
7b8f3ef0bb
|
@ -115,18 +115,30 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
|
||||||
$dn = $tmpDN;
|
$dn = $tmpDN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now do the actual authentication of the user */
|
/* Check if user already exists in the database. Return with an error
|
||||||
$bind = @ldap_bind($ds, $dn, $password);
|
* only if the sql statements fails, but not if no user was found.
|
||||||
|
*/
|
||||||
$user = $dms->getUserByLogin($username);
|
$user = $dms->getUserByLogin($username);
|
||||||
if($user === false) {
|
if($user === false) {
|
||||||
ldap_close($ds);
|
ldap_close($ds);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($bind) {
|
|
||||||
|
/* Now do the actual authentication of the user */
|
||||||
|
$bind = @ldap_bind($ds, $dn, $password);
|
||||||
|
if (!$bind) {
|
||||||
|
ldap_close($ds);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
<<<<<<< Updated upstream
|
||||||
|
if (!is_bool($info) && $info["count"]==1 && $info[0]["count"]>0) {
|
||||||
|
$user = $dms->addUser($username, null, $info[0]['cn'][0], $info[0]['mail'][0], $settings->_language, $settings->_theme, "", 0);
|
||||||
|
=======
|
||||||
// Successfully authenticated. Now check to see if the user exists within
|
// Successfully authenticated. Now check to see if the user exists within
|
||||||
// the database. If not, add them in if _restricted is not set,
|
// the database. If not, add them in if _restricted is not set,
|
||||||
// but do not add their password.
|
// but do not add their password.
|
||||||
if (is_null($user) && !$settings->_restricted) {
|
if (!$settings->_restricted) {
|
||||||
// Retrieve the user's LDAP information.
|
// Retrieve the user's LDAP information.
|
||||||
if (isset($settings->_ldapFilter) && strlen($settings->_ldapFilter) > 0) {
|
if (isset($settings->_ldapFilter) && strlen($settings->_ldapFilter) > 0) {
|
||||||
$search = ldap_search($ds, $settings->_ldapBaseDN, "(&(".$ldapSearchAttribut.$username.")".$settings->_ldapFilter.")");
|
$search = ldap_search($ds, $settings->_ldapBaseDN, "(&(".$ldapSearchAttribut.$username.")".$settings->_ldapFilter.")");
|
||||||
|
@ -138,12 +150,19 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
|
||||||
$info = ldap_get_entries($ds, $search);
|
$info = ldap_get_entries($ds, $search);
|
||||||
|
|
||||||
if (!is_bool($info) && $info["count"]==1 && $info[0]["count"]>0) {
|
if (!is_bool($info) && $info["count"]==1 && $info[0]["count"]>0) {
|
||||||
$user = $dms->addUser($username, null, $info[0]['cn'][0], $info[0]['mail'][0], $settings->_language, $settings->_theme, "", 0);
|
if (is_null($user)) {
|
||||||
|
$user = $dms->addUser($username, null, $info[0]['cn'][0], $info[0]['mail'][0], $settings->_language, $settings->_theme, "", 3);
|
||||||
|
} else {
|
||||||
|
if(isset($info[0]['cn'][0]) && ($info[0]['cn'][0] != $user->getFullName())) {
|
||||||
|
$user->setFullName($info[0]['cn'][0]);
|
||||||
|
}
|
||||||
|
if(isset($info[0]['mail'][0]) && ($info[0]['mail'][0] != $user->getEmail())) {
|
||||||
|
$user->setEmail($info[0]['mail'][0]);
|
||||||
|
}
|
||||||
|
>>>>>>> Stashed changes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif($user) {
|
|
||||||
$user = false;
|
|
||||||
}
|
}
|
||||||
ldap_close($ds);
|
ldap_close($ds);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user