| 1 |
<?php |
| 2 |
namespace LAM\INIT; |
| 3 |
|
| 4 |
use LAM\PDF\PdfStructurePersistenceManager; |
| 5 |
use LAM\PROFILES\AccountProfilePersistenceManager; |
| 6 |
use LAM\TYPES\TypeManager; |
| 7 |
use LAMException; |
| 8 |
|
| 9 |
/* |
| 10 |
|
| 11 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 12 |
Copyright (C) 2003 - 2023 Roland Gruber |
| 13 |
|
| 14 |
This program is free software; you can redistribute it and/or modify |
| 15 |
it under the terms of the GNU General Public License as published by |
| 16 |
the Free Software Foundation; either version 2 of the License, or |
| 17 |
(at your option) any later version. |
| 18 |
|
| 19 |
This program is distributed in the hope that it will be useful, |
| 20 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
GNU General Public License for more details. |
| 23 |
|
| 24 |
You should have received a copy of the GNU General Public License |
| 25 |
along with this program; if not, write to the Free Software |
| 26 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 27 |
|
| 28 |
*/ |
| 29 |
|
| 30 |
/** |
| 31 |
* This page redirects to the correct start page after login. |
| 32 |
* |
| 33 |
* @package main |
| 34 |
* @author Roland Gruber |
| 35 |
*/ |
| 36 |
|
| 37 |
/** config object */ |
| 38 |
include_once __DIR__ . '/../lib/config.inc'; |
| 39 |
/** profiles */ |
| 40 |
include_once __DIR__ . '/../lib/profiles.inc'; |
| 41 |
|
| 42 |
// start session |
| 43 |
startSecureSession(); |
| 44 |
enforceUserIsLoggedIn(); |
| 45 |
|
| 46 |
setlanguage(); |
| 47 |
|
| 48 |
$accountProfilePersistenceManager = new AccountProfilePersistenceManager(); |
| 49 |
$pdfStructurePersistenceManager = new PdfStructurePersistenceManager(); |
| 50 |
try { |
| 51 |
$accountProfilePersistenceManager->installAccountProfileTemplates($_SESSION['config']->getName()); |
| 52 |
$pdfStructurePersistenceManager->installPDFTemplates($_SESSION['config']->getName()); |
| 53 |
} catch (LAMException $e) { |
| 54 |
logNewMessage(LOG_ERR, $e->getTitle()); |
| 55 |
} |
| 56 |
|
| 57 |
$conf = $_SESSION['config']; |
| 58 |
|
| 59 |
// check if user password is not expired |
| 60 |
if (!$conf->isHidePasswordPromptForExpiredPasswords()) { |
| 61 |
$userDn = $_SESSION['ldap']->getUserName(); |
| 62 |
$userData = ldapGetDN($userDn, ['*', '+', 'pwdReset', 'passwordExpirationTime']); |
| 63 |
$ldapErrorCode = ldap_errno($_SESSION['ldap']->server()); |
| 64 |
logNewMessage(LOG_DEBUG, 'Expired password check: Reading ' . $userDn . ' with return code ' . $ldapErrorCode . ' and data: ' . print_r($userData, true)); |
| 65 |
if (($ldapErrorCode !== 32) && ($ldapErrorCode !== 34)) { |
| 66 |
$pwdResetMarker = (!empty($userData['pwdreset'][0]) && ($userData['pwdreset'][0] == 'TRUE')); |
| 67 |
$pwdExpiration = (!empty($userData)) && class_exists('\locking389ds') && \locking389ds::isPasswordExpired($userData); |
| 68 |
if (($userData === null) || $pwdResetMarker || $pwdExpiration) { |
| 69 |
metaRefresh("changePassword.php"); |
| 70 |
exit(); |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
// check if all suffixes in conf-file exist |
| 76 |
$new_suffs = []; |
| 77 |
// get list of active types |
| 78 |
$typeManager = new TypeManager(); |
| 79 |
$types = $typeManager->getConfiguredTypes(); |
| 80 |
foreach ($types as $type) { |
| 81 |
$info = @ldap_read($_SESSION['ldap']->server(), $type->getSuffix(), "(objectClass=*)", ['objectClass'], 0, 0, 0, LDAP_DEREF_NEVER); |
| 82 |
if (($info === false) && !in_array($type->getSuffix(), $new_suffs)) { |
| 83 |
$new_suffs[] = $type->getSuffix(); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
// display page to add suffixes, if needed |
| 88 |
if (($new_suffs !== []) && checkIfWriteAccessIsAllowed()) { |
| 89 |
$_SESSION['missingSuffixes'] = $new_suffs; |
| 90 |
metaRefresh("initsuff.php"); |
| 91 |
exit(); |
| 92 |
} |
| 93 |
|
| 94 |
if (count($types) > 0) { |
| 95 |
foreach ($types as $type) { |
| 96 |
if ($type->isHidden()) { |
| 97 |
continue; |
| 98 |
} |
| 99 |
metaRefresh("lists/list.php?type=" . $type->getId()); |
| 100 |
exit(); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
metaRefresh("tools/treeView.php"); |