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,26 +1262,28 @@ 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();
$filter = '(&(objectClass=posixAccount)(gidNumber=*))';
if ($this->isWindows()) {
$filter = '(&(objectClass=user)(gidNumber=*))';
}
if (!empty($typeSettings['filter_user'])) {
$typeFilter = $typeSettings['filter_user'];
if (strpos($typeFilter, '(') !== 0) {
$typeFilter = '(' . $typeFilter . ')';
}
$filter = '(&' . $filter . $typeFilter . ')';
}
$result = searchLDAPByFilter($filter, array('uid', 'gidNumber', 'cn'), array('user'));
$this->cachedUserToGIDList = array(); $this->cachedUserToGIDList = array();
$resultCount = sizeof($result); $typeManager = new TypeManager();
for ($i = 0; $i < $resultCount; $i++) { foreach ($typeManager->getConfiguredTypesForScope('user') as $type) {
$this->cachedUserToGIDList[$result[$i]['uid'][0]] = array( $filter = '(&(objectClass=posixAccount)(gidNumber=*))';
'gid' => $result[$i]['gidnumber'][0], if ($this->isWindows()) {
'cn' => $result[$i]['cn'][0], $filter = '(&(objectClass=user)(gidNumber=*))';
'dn' => $result[$i]['dn']); }
$typeFilter = $type->getAdditionalLdapFilter();
if (!empty($typeFilter)) {
if (strpos($typeFilter, '(') !== 0) {
$typeFilter = '(' . $typeFilter . ')';
}
$filter = '(&' . $filter . $typeFilter . ')';
}
$result = searchLDAPByFilter($filter, array('uid', 'gidNumber', 'cn'), array('user'));
$resultCount = sizeof($result);
for ($i = 0; $i < $resultCount; $i++) {
$this->cachedUserToGIDList[$result[$i]['uid'][0]] = array(
'gid' => $result[$i]['gidnumber'][0],
'cn' => $result[$i]['cn'][0],
'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));
@ -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,16 +1329,12 @@ 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']; return true;
if (in_array('windowsGroup', $conf->get_AccountModules($this->get_scope()))) { }
return true; else {
} return false;
else {
return false;
}
} }
return false;
} }
/** /**