Commit e7cf9dda authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5395 Improved templates search to avoid mixing ogroup and posixGroup templates

Showing with 17 additions and 5 deletions
+17 -5
......@@ -125,7 +125,7 @@ class objects
return $ldap->count();
}
private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $scope = 'subtree')
private static function search ($types, $search_attrs, $ou = NULL, $filter = '', $scope = 'subtree', $templateSearch = FALSE)
{
global $config;
......@@ -162,6 +162,16 @@ class objects
}
$filter = '(&'.$filter.'(|'.implode($typeFilters).'))';
}
if ($templateSearch) {
$templateFilterObject = new ldapFilter(
'&',
array(
new ldapFilterLeaf('objectClass', '=', 'fdTemplate'),
fdTemplateFilter(ldapFilter::parse($filter)),
)
);
$filter = "$templateFilterObject";
}
$ldap->cd($ou);
$ldap->search($filter, $search_attrs, $scope);
if (!$ldap->success()) {
......@@ -276,7 +286,7 @@ class objects
/* !\brief This method returns a list of all available templates for the given type
*/
static function getTemplates ($type, $requiredPermissions = 'r')
static function getTemplates ($type, $requiredPermissions = 'r', $filter = '')
{
global $config, $ui;
......@@ -286,9 +296,11 @@ class objects
$ldap = $config->get_ldap_link();
foreach ($config->departments as $key => $value) {
// Search all templates from the current dn.
$ldap->cd($infos['ou'].$value);
// We could also adapt object filter to match templates
$ldap->search('(objectClass=fdTemplate)', array('cn'));
try {
$ldap = static::search($type, array('cn'), $infos['ou'].$value, $filter, 'subtree', TRUE);
} catch (NonExistingBranchException $e) {
continue;
}
if ($ldap->count() != 0) {
while ($attrs = $ldap->fetch()) {
$dn = $attrs['dn'];
......
  • bmortier @bmortier

    mentioned in issue #1722 (closed)

    By rpatroix on 2017-09-02T15:35:44 (imported from GitLab)

    ·

    mentioned in issue #1722 (closed)

    By rpatroix on 2017-09-02T15:35:44 (imported from GitLab)

    Toggle commit list
  • bmortier @bmortier

    mentioned in issue #5395 (closed)

    By Côme Chilliet on 2018-11-20T16:04:22 (imported from GitLab)

    ·

    mentioned in issue #5395 (closed)

    By Côme Chilliet on 2018-11-20T16:04:22 (imported from GitLab)

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment