Rev 1116 | Rev 1131 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1116 | Rev 1130 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | // phpcs:enable PSR1.Files.SideEffects |
24 | // phpcs:enable PSR1.Files.SideEffects |
25 | 25 | ||
26 | class OIDplusPagePublicLoginLdap extends OIDplusPagePluginPublic { |
26 | class OIDplusPagePublicLoginLdap extends OIDplusPagePluginPublic { |
27 | 27 | ||
28 | /** |
28 | /** |
29 | * @param $ra |
29 | * @param OIDplusRA $ra |
30 | * @param $ldap_userinfo |
30 | * @param array $ldap_userinfo |
31 | * @return void |
31 | * @return void |
32 | * @throws OIDplusException |
32 | * @throws OIDplusException |
33 | */ |
33 | */ |
34 | private function registerRA($ra, $ldap_userinfo) { |
34 | private function registerRA(OIDplusRA $ra, array $ldap_userinfo) { |
35 | $email = $ra->raEmail(); |
35 | $email = $ra->raEmail(); |
36 | 36 | ||
37 | $ra->register_ra(null); // create a user account without password |
37 | $ra->register_ra(null); // create a user account without password |
38 | 38 | ||
39 | /* |
39 | /* |
Line 78... | Line 78... | ||
78 | } |
78 | } |
79 | } |
79 | } |
80 | } |
80 | } |
81 | 81 | ||
82 | /** |
82 | /** |
83 | * @param $remember_me |
83 | * @param bool $remember_me |
84 | * @param $email |
84 | * @param string $email |
85 | * @param $ldap_userinfo |
85 | * @param array $ldap_userinfo |
86 | * @return void |
86 | * @return void |
87 | * @throws OIDplusException |
87 | * @throws OIDplusException |
88 | */ |
88 | */ |
89 | private function doLoginRA($remember_me, $email, $ldap_userinfo) { |
89 | private function doLoginRA(bool $remember_me, string $email, array $ldap_userinfo) { |
90 | $ra = new OIDplusRA($email); |
90 | $ra = new OIDplusRA($email); |
91 | if (!$ra->existing()) { |
91 | if (!$ra->existing()) { |
92 | $this->registerRA($ra, $ldap_userinfo); |
92 | $this->registerRA($ra, $ldap_userinfo); |
93 | OIDplus::logger()->log("[INFO]RA($email)!", "RA '$email' was created because of successful LDAP login"); |
93 | OIDplus::logger()->log("[INFO]RA($email)!", "RA '$email' was created because of successful LDAP login"); |
94 | } |
94 | } |
Line 97... | Line 97... | ||
97 | 97 | ||
98 | OIDplus::db()->query("UPDATE ###ra set last_login = ".OIDplus::db()->sqlDate()." where email = ?", array($email)); |
98 | OIDplus::db()->query("UPDATE ###ra set last_login = ".OIDplus::db()->sqlDate()." where email = ?", array($email)); |
99 | } |
99 | } |
100 | 100 | ||
101 | /** |
101 | /** |
102 | * @param $upn |
102 | * @param string $upn |
103 | * @return int |
103 | * @return int |
104 | * @throws OIDplusException |
104 | * @throws OIDplusException |
105 | */ |
105 | */ |
106 | private function getDomainNumber($upn) { |
106 | private function getDomainNumber(string $upn): int { |
107 | $numDomains = OIDplus::baseConfig()->getValue('LDAP_NUM_DOMAINS', 1); |
107 | $numDomains = OIDplus::baseConfig()->getValue('LDAP_NUM_DOMAINS', 1); |
108 | for ($i=1; $i<=$numDomains; $i++) { |
108 | for ($i=1; $i<=$numDomains; $i++) { |
109 | $cfgSuffix = $i == 1 ? '' : "__$i"; |
109 | $cfgSuffix = $i == 1 ? '' : "__$i"; |
110 | $upnSuffix = OIDplus::baseConfig()->getValue('LDAP_UPN_SUFFIX'.$cfgSuffix, ''); |
110 | $upnSuffix = OIDplus::baseConfig()->getValue('LDAP_UPN_SUFFIX'.$cfgSuffix, ''); |
111 | if (str_ends_with($upn, $upnSuffix)) return $i; |
111 | if (str_ends_with($upn, $upnSuffix)) return $i; |
Line 370... | Line 370... | ||
370 | /** |
370 | /** |
371 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.5 |
371 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.5 |
372 | * @return array |
372 | * @return array |
373 | * @throws OIDplusException |
373 | * @throws OIDplusException |
374 | */ |
374 | */ |
375 | public function alternativeLoginMethods() { |
375 | public function alternativeLoginMethods(): array { |
376 | $logins = array(); |
376 | $logins = array(); |
377 | if (OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) { |
377 | if (OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) { |
378 | $logins[] = array( |
378 | $logins[] = array( |
379 | 'oidplus:login_ldap', |
379 | 'oidplus:login_ldap', |
380 | _L('Login using LDAP / ActiveDirectory'), |
380 | _L('Login using LDAP / ActiveDirectory'), |
Line 384... | Line 384... | ||
384 | return $logins; |
384 | return $logins; |
385 | } |
385 | } |
386 | 386 | ||
387 | /** |
387 | /** |
388 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
388 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
389 | * @param $user |
389 | * @param string|null $user |
390 | * @return array |
390 | * @return array |
391 | * @throws OIDplusException |
391 | * @throws OIDplusException |
392 | */ |
392 | */ |
393 | public function getNotifications($user=null): array { |
393 | public function getNotifications(string $user=null): array { |
394 | $notifications = array(); |
394 | $notifications = array(); |
395 | if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) { |
395 | if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) { |
396 | if (OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) { |
396 | if (OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) { |
397 | if (!function_exists('ldap_connect')) { |
397 | if (!function_exists('ldap_connect')) { |
398 | $title = _L('LDAP Login'); |
398 | $title = _L('LDAP Login'); |