From 43de9af71f7f4ca5731b94a06d688ae8412ba427 Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Fri, 6 Jul 2018 11:14:41 +0200 Subject: 2018/Feb/28 -i állapot hozzáadva, mint a módosítások kiindulási állapota --- .../www/include/backend/ldapng/auth/login.php | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 mayor-orig/www/include/backend/ldapng/auth/login.php (limited to 'mayor-orig/www/include/backend/ldapng/auth') diff --git a/mayor-orig/www/include/backend/ldapng/auth/login.php b/mayor-orig/www/include/backend/ldapng/auth/login.php new file mode 100644 index 00000000..b24b4b96 --- /dev/null +++ b/mayor-orig/www/include/backend/ldapng/auth/login.php @@ -0,0 +1,163 @@ + 1 ) { + // Több ilyen uid is van + $_SESSION['alert'][] = "message:multi_uid"; + ldap_close($ds); + return _AUTH_FAILURE_2; + } + + if ($info['count']==1) { // Van - egy - ilyen felhasználó + + + $accountInformation['cn'] = $info[0][ $AUTH[$toPolicy]['ldapCnAttr'] ][0]; + $accountInformation['studyId'] = $info[0][ $AUTH[$toPolicy]['ldapStudyIdAttr'] ][0]; + + $accountInformation['dn'] = $info[0]['dn']; + $accountInformation['account'] = $userAccount; + // Lejárt-e + // A lejárat ideje a shadowExpire és shadowLastChange+shadowMax kötül a kisebbik + if ($info[0]['pwdlastset'][0] != '') { // A pwdLastSet és shadowLastChange közül a kisebbiket használjuk +// if ($info[0]['shadowlastchange'][0] != '') +// $info[0]['shadowlastchange'][0] = min(pwdLastSet2shadowLastChange($info[0]['pwdlastset'][0]), $info[0]['shadowlastchange'][0]); +// else + $info[0]['shadowlastchange'][0] = pwdLastSet2shadowLastChange($info[0]['pwdlastset'][0]); + } + if ($info[0]['accountexpires'][0] != '') { // Az accountExpires és a shadowExpire közül a kisebbiket használjuk +// if ($info[0]['shadowexpire'][0] != '') +// $info[0]['shadowexpire'][0] = min(pwdLastSet2shadowLastChange($info[0]['accountexpires'][0]), $info[0]['shadowexpire'][0]); +// else + $info[0]['shadowexpire'][0] = pwdLastSet2shadowLastChange($info[0]['accountexpires'][0]); + } + if ($info[0]['shadowexpire'][0] != '') $expireTimestamp = $info[0]['shadowexpire'][0]; + if ( + $info[0]['shadowmax'][0] != '' && + ( + !isset($expireTimestamp) || + $expireTimestamp > $info[0]['shadowlastchange'][0] + $info[0]['shadowmax'][0] + ) + ) $expireTimestamp = $info[0]['shadowlastchange'][0] + $info[0]['shadowmax'][0]; + // lejárt, ha lejárat ideje már elmúlt + $accountExpired = (isset($expireTimestamp) && ($expireTimestamp <= floor(time()/(60*60*24)))); + + // Le van-e tiltva + // Ha több mint shadowInactive napja lejárt + if ( // onDisabled: none | refuse + $AUTH[$toPolicy]['onDisabled'] == 'refuse' && + isset($expireTimestamp) && + $expireTimestamp + $info[0]['shadowinactive'][0] <= floor(time()/(60*60*24)) + ) { + // Le van tiltva + $_SESSION['alert'][] = 'message:account_disabled'; + ldap_close($ds); + return _AUTH_FAILURE_4; + } // onDisabled + + // Jelszó ellenőrzés - lehet-e csatlakozni + if (!@ldap_bind($ds, $accountInformation['dn'], $userPassword)) { + $_SESSION['alert'][] = 'message:bad_pw'; + return _AUTH_FAILURE_3; + } + + ldap_close($ds); + // Lejárt-e az azonosító + if ($AUTH[$toPolicy]['onExpired'] != 'none' && isset($expireTimestamp)) { // onExpired: none | warning | force update + // Lejárt-e + $pwLejar = $expireTimestamp - floor(time()/(60*60*24)); + if (0 < $pwLejar && $pwLejar < $info[0]['shadowwarning'][0]) { + $_SESSION['alert'][] = 'info:account_warning:'.$pwLejar; + return _AUTH_SUCCESS; + } elseif ($pwLejar <= 0) { + $_SESSION['alert'][] = 'info:account_expired:'.abs($pwLejar); + if ($AUTH[$toPolicy]['onDisabled'] == 'refuse') $_SESSION['alert'][] = 'info:warn_account_disable:'.($info[0]['shadowinactive'][0]+$pwLejar); + if ($AUTH[$toPolicy]['onExpired'] == 'warning') { + return _AUTH_SUCCESS; + } elseif ($AUTH[$toPolicy]['onExpired'] == 'force update') { + return _AUTH_EXPIRED; + } else { + return _AUTH_FAILURE; + } + } + } // onExpired + // Ha idáig eljut, akkor minden rendben. + return _AUTH_SUCCESS; + + } // count == 1 + + } + +?> -- cgit v1.2.3