new type API

This commit is contained in:
Roland Gruber 2017-03-21 19:26:31 +01:00
parent 6022dee5a0
commit 0ac6fc6c2e
3 changed files with 22 additions and 23 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
use \LAM\TYPES\TypeManager;
/* /*
$Id$ $Id$
@ -966,11 +967,12 @@ class inetOrgPerson extends baseModule implements passwordService {
} }
// password status change // password status change
if (!$this->isUnixActive()) { if (!$this->isUnixActive()) {
if ((pwd_is_enabled($this->orig['userPassword'][0]) && pwd_is_enabled($this->attributes['userPassword'][0])) $pwdOrig = empty($this->orig['userPassword'][0]) ? '' : $this->orig['userPassword'][0];
|| (!pwd_is_enabled($this->orig['userPassword'][0]) && !pwd_is_enabled($this->attributes['userPassword'][0]))) { $pwdNew = empty($this->attributes['userPassword'][0]) ? '' : $this->attributes['userPassword'][0];
if ((pwd_is_enabled($pwdOrig) && pwd_is_enabled($pwdNew)) || (!pwd_is_enabled($pwdOrig) && !pwd_is_enabled($pwdNew))) {
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'unchanged'; $return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'unchanged';
} }
elseif (pwd_is_enabled($this->orig['userPassword'][0])) { elseif (pwd_is_enabled($pwdOrig)) {
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'locked'; $return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'locked';
} }
else { else {
@ -3600,14 +3602,17 @@ class inetOrgPerson extends baseModule implements passwordService {
$configContainer = new htmlTable(); $configContainer = new htmlTable();
if (isset($_SESSION['conf_config'])) { if (isset($_SESSION['conf_config'])) {
// add password hash type if posixAccount is inactive // add password hash type if posixAccount is inactive
$confActiveUnixModules = $_SESSION['conf_config']->get_AccountModules('user'); $unixModuleFound = false;
if (in_array('host', $_SESSION['conf_config']->get_ActiveTypes())) { $typeManager = new TypeManager($_SESSION['conf_config']);
$confActiveUnixModules = array_merge($confActiveUnixModules, $_SESSION['conf_config']->get_AccountModules('host')); $types = $typeManager->getConfiguredTypesForScopes(array('user', 'group'));
foreach ($types as $type) {
$modules = $type->getModules();
if (in_array('posixAccount', $modules) || in_array('posixGroup', $modules)) {
$unixModuleFound = true;
break;
}
} }
if (in_array('group', $_SESSION['conf_config']->get_ActiveTypes())) { if (!$unixModuleFound) {
$confActiveUnixModules = array_merge($confActiveUnixModules, $_SESSION['conf_config']->get_AccountModules('group'));
}
if (!in_array('posixAccount', $confActiveUnixModules) && !in_array('posixGroup', $confActiveUnixModules)) {
$optionsSelected = array('SSHA'); $optionsSelected = array('SSHA');
$hashOption = new htmlTable(); $hashOption = new htmlTable();
$hashOption->addElement(new htmlTableExtendedSelect('posixAccount_pwdHash', getSupportedHashTypes(), $optionsSelected, _("Password hash type"), 'pwdHash')); $hashOption->addElement(new htmlTableExtendedSelect('posixAccount_pwdHash', getSupportedHashTypes(), $optionsSelected, _("Password hash type"), 'pwdHash'));

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2004 - 2015 Roland Gruber Copyright (C) 2004 - 2017 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -484,15 +484,7 @@ class nisMailAlias extends baseModule {
if ($this->cachedMailList != null) { if ($this->cachedMailList != null) {
return $this->cachedMailList; return $this->cachedMailList;
} }
$objectClass = 'inetOrgPerson'; $this->cachedMailList = searchLDAPByAttribute('mail', '*', null, array('mail'), array('user'));
$activeTypes = $_SESSION['config']->get_ActiveTypes();
if (in_array('user', $activeTypes)) {
$userModules = $_SESSION['config']->get_AccountModules('user');
if (in_array('windowsUser', $userModules)) {
$objectClass = 'user';
}
}
$this->cachedMailList = searchLDAPByAttribute('mail', '*', $objectClass, array('mail'), array('user'));
for ($i = 0; $i < sizeof($this->cachedMailList); $i++) { for ($i = 0; $i < sizeof($this->cachedMailList); $i++) {
$this->cachedMailList[$i] = $this->cachedMailList[$i]['mail'][0]; $this->cachedMailList[$i] = $this->cachedMailList[$i]['mail'][0];
} }

View File

@ -1,9 +1,10 @@
<?php <?php
use \LAM\TYPES\TypeManager;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2014 - 2015 Roland Gruber Copyright (C) 2014 - 2017 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -634,8 +635,9 @@ class nisMailAliasUser extends baseModule {
* @return boolean is active * @return boolean is active
*/ */
private function isMailAliasTypeActive() { private function isMailAliasTypeActive() {
$activeTypes = $_SESSION['config']->get_ActiveTypes(); $typeManager = new TypeManager();
return in_array('mailAlias', $activeTypes); $activeTypes = $typeManager->getConfiguredTypesForScope('mailAlias');
return !empty($activeTypes);
} }
} }