new type API

This commit is contained in:
Roland Gruber 2017-05-06 11:09:43 +02:00
parent f60c37edcd
commit 711d5b3d77
1 changed files with 28 additions and 30 deletions

View File

@ -1241,7 +1241,7 @@ class posixGroup extends baseModule implements passwordService {
$this->cachedGIDList = array(); $this->cachedGIDList = array();
$attrs = array('gidNumber'); $attrs = array('gidNumber');
$filter = '(&(objectClass=posixGroup)(gidNumber=*))'; $filter = '(&(objectClass=posixGroup)(gidNumber=*))';
$suffix = $_SESSION['config']->get_Suffix('group'); $suffix = $this->getAccountContainer()->get_type()->getSuffix();
if (isset($this->moduleSettings['posixGroup_gidCheckSuffix'][0]) && ($this->moduleSettings['posixGroup_gidCheckSuffix'][0] != '')) { if (isset($this->moduleSettings['posixGroup_gidCheckSuffix'][0]) && ($this->moduleSettings['posixGroup_gidCheckSuffix'][0] != '')) {
$suffix = $this->moduleSettings['posixGroup_gidCheckSuffix'][0]; $suffix = $this->moduleSettings['posixGroup_gidCheckSuffix'][0];
} }
@ -1262,20 +1262,21 @@ class posixGroup extends baseModule implements passwordService {
if ($this->cachedUserToGIDList != null) { if ($this->cachedUserToGIDList != null) {
return $this->cachedUserToGIDList; return $this->cachedUserToGIDList;
} }
$typeSettings = $_SESSION['config']->get_typeSettings(); $this->cachedUserToGIDList = array();
$typeManager = new TypeManager();
foreach ($typeManager->getConfiguredTypesForScope('user') as $type) {
$filter = '(&(objectClass=posixAccount)(gidNumber=*))'; $filter = '(&(objectClass=posixAccount)(gidNumber=*))';
if ($this->isWindows()) { if ($this->isWindows()) {
$filter = '(&(objectClass=user)(gidNumber=*))'; $filter = '(&(objectClass=user)(gidNumber=*))';
} }
if (!empty($typeSettings['filter_user'])) { $typeFilter = $type->getAdditionalLdapFilter();
$typeFilter = $typeSettings['filter_user']; if (!empty($typeFilter)) {
if (strpos($typeFilter, '(') !== 0) { if (strpos($typeFilter, '(') !== 0) {
$typeFilter = '(' . $typeFilter . ')'; $typeFilter = '(' . $typeFilter . ')';
} }
$filter = '(&' . $filter . $typeFilter . ')'; $filter = '(&' . $filter . $typeFilter . ')';
} }
$result = searchLDAPByFilter($filter, array('uid', 'gidNumber', 'cn'), array('user')); $result = searchLDAPByFilter($filter, array('uid', 'gidNumber', 'cn'), array('user'));
$this->cachedUserToGIDList = array();
$resultCount = sizeof($result); $resultCount = sizeof($result);
for ($i = 0; $i < $resultCount; $i++) { for ($i = 0; $i < $resultCount; $i++) {
$this->cachedUserToGIDList[$result[$i]['uid'][0]] = array( $this->cachedUserToGIDList[$result[$i]['uid'][0]] = array(
@ -1283,6 +1284,7 @@ class posixGroup extends baseModule implements passwordService {
'cn' => $result[$i]['cn'][0], 'cn' => $result[$i]['cn'][0],
'dn' => $result[$i]['dn']); 'dn' => $result[$i]['dn']);
} }
}
logNewMessage(LOG_DEBUG, 'Found ' . $resultCount . ' Unix users.'); logNewMessage(LOG_DEBUG, 'Found ' . $resultCount . ' Unix users.');
logNewMessage(LOG_DEBUG, print_r($result, true)); logNewMessage(LOG_DEBUG, print_r($result, true));
return $this->cachedUserToGIDList; return $this->cachedUserToGIDList;
@ -1310,7 +1312,7 @@ class posixGroup extends baseModule implements passwordService {
$this->cachedGroupNameList = array(); $this->cachedGroupNameList = array();
$attrs = array('cn'); $attrs = array('cn');
$filter = '(&(objectClass=posixGroup)(cn=*))'; $filter = '(&(objectClass=posixGroup)(cn=*))';
$suffix = $_SESSION['config']->get_Suffix('group'); $suffix = $this->getAccountContainer()->get_type()->getSuffix();
if (isset($this->moduleSettings['posixGroup_gidCheckSuffix'][0]) && ($this->moduleSettings['posixGroup_gidCheckSuffix'][0] != '')) { if (isset($this->moduleSettings['posixGroup_gidCheckSuffix'][0]) && ($this->moduleSettings['posixGroup_gidCheckSuffix'][0] != '')) {
$suffix = $this->moduleSettings['posixGroup_gidCheckSuffix'][0]; $suffix = $this->moduleSettings['posixGroup_gidCheckSuffix'][0];
} }
@ -1327,17 +1329,13 @@ class posixGroup extends baseModule implements passwordService {
* @return boolean is Windows * @return boolean is Windows
*/ */
private function isWindows() { private function isWindows() {
if (isset($_SESSION['config'])) { if (in_array('windowsGroup', $this->getAccountContainer()->get_type()->getModules())) {
$conf = $_SESSION['config'];
if (in_array('windowsGroup', $conf->get_AccountModules($this->get_scope()))) {
return true; return true;
} }
else { else {
return false; return false;
} }
} }
return false;
}
/** /**
* Returns if cn and description attributes should be managed. * Returns if cn and description attributes should be managed.