From 6551a86d4d82153bb4831c2f790a0c5c828f88e0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 9 Nov 2015 11:40:30 +0100 Subject: [PATCH] LdapRepository: Drop method isAmbiguous() and introduce isRelatedDn() refs #10567 --- library/Icinga/Repository/LdapRepository.php | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/library/Icinga/Repository/LdapRepository.php b/library/Icinga/Repository/LdapRepository.php index 5e79c41bb..0ebde56dd 100644 --- a/library/Icinga/Repository/LdapRepository.php +++ b/library/Icinga/Repository/LdapRepository.php @@ -42,15 +42,6 @@ abstract class LdapRepository extends Repository 'groupofuniquenames' => 'groupOfUniqueNames' ); - /** - * Object attributes whose value is not distinguished name - * - * @var array - */ - protected $ambiguousAttributes = array( - 'posixGroup' => 'memberUid' - ); - /** * Create a new LDAP repository object * @@ -79,15 +70,19 @@ abstract class LdapRepository extends Repository } /** - * Return whether the given object attribute's value is not a distinguished name + * Return whether the given object DN is related to the given base DN * - * @param string $objectClass - * @param string $attributeName + * Will use the current connection's root DN if $baseDn is not given. + * + * @param string $dn The object DN to check + * @param string $baseDn The base DN to compare the object DN with * * @return bool */ - protected function isAmbiguous($objectClass, $attributeName) + protected function isRelatedDn($dn, $baseDn = null) { - return isset($this->ambiguousAttributes[$objectClass][$attributeName]); + $normalizedDn = strtolower(join(',', array_map('trim', explode(',', $dn)))); + $normalizedBaseDn = strtolower(join(',', array_map('trim', explode(',', $baseDn ?: $this->ds->getDn())))); + return strpos($normalizedDn, $normalizedBaseDn) !== false; } }