29 static protected $username;
30 static protected $password;
32 static function init ()
34 static::$username = NULL;
35 static::$password = NULL;
42 if ($config->get_cfg_value(
'schemaCheck') !=
'TRUE') {
46 $cfg[
'admin'] = $config->current[
'ADMINDN'];
47 $cfg[
'password'] = $config->current[
'ADMINPASSWORD'];
48 $cfg[
'connection'] = $config->current[
'SERVER'];
49 $cfg[
'tls'] = ($config->get_cfg_value(
'ldapTLS') ==
'TRUE');
51 foreach ($str as $tr) {
53 if ($tr[
'IS_MUST_HAVE']) {
68 $ldap = $config->get_ldap_link();
69 $ldap->cat(
get_ou(
'lockRDN').
get_ou(
'fusiondirectoryRDN').$config->current[
'BASE'], [
'dn']);
70 $attrs = $ldap->fetch();
72 $ldap->cd($config->current[
'BASE']);
74 $ldap->create_missing_trees(
get_ou(
'lockRDN').
get_ou(
'fusiondirectoryRDN').$config->current[
'BASE']);
87 global $message, $smarty;
88 static::$username = trim(static::$username);
89 if (!preg_match(
'/^[@A-Za-z0-9_.-]+$/', static::$username)) {
90 $message = _(
'Please specify a valid username!');
92 } elseif (mb_strlen(static::$password,
'UTF-8') == 0) {
93 $message = _(
'Please specify your password!');
94 $smarty->assign(
'focusfield',
'password');
103 global $ui, $config, $message, $smarty;
110 logging::log(
'security',
'login failure', static::$username, [],
'Authentication failed: '.$e->getMessage());
112 $message = $e->getMessage();
113 $smarty->assign(
'focusfield',
'password');
122 global $ui, $config, $plist, $message, $smarty;
134 if (!$plistReloaded) {
140 $config->checkLdapConfig();
143 $expired = $ui->expired_status();
145 if ($expired == POSIX_ACCOUNT_EXPIRED) {
146 logging::log(
'security',
'account', $ui->dn, [],
'Account for user "'.static::$username.
'" has expired');
147 $message = _(
'Account locked. Please contact your system administrator!');
148 $smarty->assign(
'focusfield',
'username');
163 session_regenerate_id();
166 logging::log(
'security',
'login', $ui->uid, [],
'Logged in successfully');
168 session::set(
'DEBUGLEVEL', $config->get_cfg_value(
'DEBUGLEVEL'));
175 header(
'Location: main.php');
183 foreach ($steps as $step) {
184 $status = static::$step();
185 if (is_string($status)) {
189 } elseif ($status === FALSE) {
203 global $config, $smarty;
205 $method = $config->get_cfg_value(
'LoginMethod',
'');
206 if (empty($method)) {
208 if ($config->get_cfg_value(
'httpAuthActivated') ==
'TRUE') {
209 $method =
'LoginHTTPAuth';
210 } elseif ($config->get_cfg_value(
'casActivated') ==
'TRUE') {
211 $method =
'LoginCAS';
212 } elseif ($config->get_cfg_value(
'httpHeaderAuthActivated') ==
'TRUE') {
213 $method =
'LoginHTTPHeader';
215 $method =
'LoginPost';
219 $method::loginProcess();
223 $display =
'<h1>'.htmlescape(_(
'An unrecoverable error occurred. Please contact your administator.')).
'</h1><p>';
224 if (ini_get(
'display_errors') == 1) {
227 $display .=
'Error detail display is turned off.';
229 $display .=
'</p>'.
"\n";
230 $smarty->assign(
'headline', _(
'Fatal error!'));
231 $smarty->assign(
'headline_image',
'geticon.php?context=status&icon=dialog-error&size=32');
232 $smarty->assign(
'usePrototype',
'false');
233 $smarty->assign(
'date', date(
'l, dS F Y H:i:s O'));
234 $smarty->assign(
'lang', preg_replace(
'/_.*$/',
'', $lang));
249 static function getMethods ()
258 foreach ($methods as $method) {
259 $label = $method::getLabel();
261 $return[$method] = $label;
static loginProcess()
All login steps in the right order.
htmlescape(string $str)
Escape string for HTML output.
static runSchemaCheck()
Runs schemaCheck if activated in configuration.
get_ou($name)
Get the OU of a certain RDN.
static load()
Loads plist and load it in config object.
static redirect()
Final step of successful login: redirect to main.php.
get_template_path($filename='', $plugin=FALSE, $path='')
Return themed path for specified base file.
static get($name)
Accessor of a session var.
static log(string $action, string $objecttype, string $object, array $changes=[], string $result='')
logging method
static display($title, string $message, int $type=INFO_DIALOG, array $trace=[])
Display a message dialog.
static deleteByUser(string $userdn)
Remove all locks owned by a specific userdn.
static set($name, $value)
Set a value in a session.
static checkForLockingBranch()
Check if locking LDAP branch is here or create it.
static init($lang=NULL)
Initialize language configuration.
check_schema(array $cfg)
Check if LDAP schema matches the requirements.
Base class for login methods.
static loginUser(string $username, string $password)
Verify user login against LDAP directory.
static loginAndCheckExpired()
Called after successful login, return FALSE if account is expired.
static un_set($name)
Unset a session.
static connect()
Connect user.
static ldapLoginUser()
Performs an LDAP bind with $username and $password.
static validateUserInput()
Check username for invalid characters and check password is not empty Also trims username.
Parent class for all errors in FusionDirectory.
static isRTL($lang)
Returns TRUE if $lang is a right to left language.
static runSteps($steps)
Run each step in $steps, stop on errors.
static getLabel()
Displayed name for each login method. Returning FALSE disables a method.