LDAPAccountManager/lam/templates/main.php

99 lines
2.9 KiB
PHP
Raw Permalink Normal View History

<?php
2017-01-06 12:56:17 +00:00
namespace LAM\INIT;
use locking389ds;
2003-03-14 21:59:04 +00:00
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2020 Roland Gruber
2003-03-14 21:59:04 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
2003-03-14 21:59:04 +00:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2003-03-14 21:59:04 +00:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2004-06-10 19:01:18 +00:00
*/
2004-06-10 19:01:18 +00:00
/**
2014-02-02 12:36:12 +00:00
* This page redirects to the correct start page after login.
2004-06-10 19:01:18 +00:00
*
* @package main
* @author Roland Gruber
2003-03-14 21:59:04 +00:00
*/
2007-06-16 11:50:25 +00:00
/** config object */
2017-01-06 12:56:17 +00:00
include_once '../lib/config.inc';
/** profiles */
include_once '../lib/profiles.inc';
2007-06-16 11:50:25 +00:00
// start session
startSecureSession();
2017-02-11 16:11:37 +00:00
enforceUserIsLoggedIn();
2007-06-16 11:50:25 +00:00
setlanguage();
2017-01-06 12:56:17 +00:00
\LAM\PROFILES\installProfileTemplates();
\LAM\PDF\installPDFTemplates();
$conf = $_SESSION['config'];
// check if user password is not expired
if ((version_compare(phpversion(), '7.2.0') >= 0) && !$conf->isHidePasswordPromptForExpiredPasswords()) {
$userDn = $_SESSION['ldap']->getUserName();
$userData = ldapGetDN($userDn, array('*', '+', 'pwdReset', 'passwordExpirationTime'));
$ldapErrorCode = ldap_errno($_SESSION['ldap']->server());
if ($ldapErrorCode != 32) {
$pwdResetMarker = (!empty($userData['pwdreset'][0]) && ($userData['pwdreset'][0] == 'TRUE'));
$pwdExpiration = (!empty($userData)) && locking389ds::isPasswordExpired($userData);
if (($userData === null) || $pwdResetMarker || $pwdExpiration) {
metaRefresh("changePassword.php");
exit();
}
}
}
// check if all suffixes in conf-file exist
$new_suffs = array();
2006-01-01 16:30:05 +00:00
// get list of active types
2017-01-06 12:56:17 +00:00
$typeManager = new \LAM\TYPES\TypeManager();
2016-12-24 12:04:31 +00:00
$types = $typeManager->getConfiguredTypes();
foreach ($types as $type) {
2017-11-04 18:27:02 +00:00
$info = @ldap_read($_SESSION['ldap']->server(), escapeDN($type->getSuffix()), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
if (($info === false) && !in_array($type->getSuffix(), $new_suffs)) {
$new_suffs[] = $type->getSuffix();
continue;
}
2017-10-24 18:48:34 +00:00
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
2016-12-24 12:04:31 +00:00
if (!$res && !in_array($type->getSuffix(), $new_suffs)) {
$new_suffs[] = $type->getSuffix();
}
}
2004-05-30 11:54:18 +00:00
// display page to add suffixes, if needed
2007-12-30 16:08:54 +00:00
if ((sizeof($new_suffs) > 0) && checkIfWriteAccessIsAllowed()) {
2010-01-01 17:21:46 +00:00
metaRefresh("initsuff.php?suffs='" . implode(";", $new_suffs));
exit();
2007-12-30 16:08:54 +00:00
}
if (sizeof($types) > 0) {
foreach ($types as $type) {
if ($type->isHidden()) {
continue;
}
metaRefresh("lists/list.php?type=" . $type->getId());
exit();
2006-01-01 16:30:05 +00:00
}
}
2017-01-06 12:56:17 +00:00
metaRefresh("tree/treeViewContainer.php");