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,35 +115,54 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
|
|||
$dn = $tmpDN;
|
||||
}
|
||||
|
||||
/* Now do the actual authentication of the user */
|
||||
$bind = @ldap_bind($ds, $dn, $password);
|
||||
/* Check if user already exists in the database. Return with an error
|
||||
* only if the sql statements fails, but not if no user was found.
|
||||
*/
|
||||
$user = $dms->getUserByLogin($username);
|
||||
if($user === false) {
|
||||
ldap_close($ds);
|
||||
return false;
|
||||
}
|
||||
if ($bind) {
|
||||
// Successfully authenticated. Now check to see if the user exists within
|
||||
// the database. If not, add them in if _restricted is not set,
|
||||
// but do not add their password.
|
||||
if (is_null($user) && !$settings->_restricted) {
|
||||
// Retrieve the user's LDAP information.
|
||||
if (isset($settings->_ldapFilter) && strlen($settings->_ldapFilter) > 0) {
|
||||
$search = ldap_search($ds, $settings->_ldapBaseDN, "(&(".$ldapSearchAttribut.$username.")".$settings->_ldapFilter.")");
|
||||
} else {
|
||||
$search = ldap_search($ds, $settings->_ldapBaseDN, $ldapSearchAttribut.$username);
|
||||
}
|
||||
|
||||
if (!is_bool($search)) {
|
||||
$info = ldap_get_entries($ds, $search);
|
||||
/* 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
|
||||
// the database. If not, add them in if _restricted is not set,
|
||||
// but do not add their password.
|
||||
if (!$settings->_restricted) {
|
||||
// Retrieve the user's LDAP information.
|
||||
if (isset($settings->_ldapFilter) && strlen($settings->_ldapFilter) > 0) {
|
||||
$search = ldap_search($ds, $settings->_ldapBaseDN, "(&(".$ldapSearchAttribut.$username.")".$settings->_ldapFilter.")");
|
||||
} else {
|
||||
$search = ldap_search($ds, $settings->_ldapBaseDN, $ldapSearchAttribut.$username);
|
||||
}
|
||||
|
||||
if (!is_bool($search)) {
|
||||
$info = ldap_get_entries($ds, $search);
|
||||
|
||||
if (!is_bool($info) && $info["count"]==1 && $info[0]["count"]>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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user