diff --git a/app/Classes/LDAP/Schema/MatchingRuleUse.php b/app/Classes/LDAP/Schema/MatchingRuleUse.php deleted file mode 100644 index d69462e4..00000000 --- a/app/Classes/LDAP/Schema/MatchingRuleUse.php +++ /dev/null @@ -1,99 +0,0 @@ -used_by_attrs = collect(); - - for ($i=0; $iname .= (strlen($this->name) ? ' ' : '').$strings[++$i]; - - } while (! preg_match("/\'$/s",$strings[$i])); - - } else { - $i++; - - do { - $this->name .= (strlen($this->name) ? ' ' : '').$strings[++$i]; - - } while (! preg_match("/\'$/s",$strings[$i])); - - do { - $i++; - - } while (! preg_match('/\)+\)?/',$strings[$i])); - } - - $this->name = preg_replace("/^\'(.*)\'$/",'$1',$this->name); - - Log::debug(sprintf(sprintf('- Case NAME returned (%s)',$this->name))); - break; - - case 'APPLIES': - if ($strings[$i+1] != '(') { - // Has a single attribute name - $this->used_by_attrs = collect($strings[++$i]); - - } else { - // Has multiple attribute names - while ($strings[++$i] != ')') { - $new_attr = $strings[++$i]; - $new_attr = preg_replace("/^\'(.*)\'$/",'$1',$new_attr); - - $this->used_by_attrs->push($new_attr); - } - } - - Log::debug(sprintf('- Case APPLIES returned (%s)',$this->used_by_attrs->join(','))); - break; - - default: - if (preg_match('/[\d\.]+/i',$strings[$i]) && ($i === 1)) { - $this->oid = $strings[$i]; - Log::debug(sprintf('- Case default returned (%s)',$this->oid)); - - } elseif ($strings[$i]) - Log::alert(sprintf('! Case default discovered a value NOT parsed (%s)',$strings[$i]),['line'=>$line]); - } - } - } - - /** - * Gets an array of attribute names (strings) which use this MatchingRuleUse object. - * - * @return array The array of attribute names (strings). - * @deprecated use $this->used_by_attrs - */ - public function getUsedByAttrs() - { - return $this->used_by_attrs; - } -} \ No newline at end of file diff --git a/app/Classes/LDAP/Server.php b/app/Classes/LDAP/Server.php index 3c2e8909..e5d36145 100644 --- a/app/Classes/LDAP/Server.php +++ b/app/Classes/LDAP/Server.php @@ -16,7 +16,7 @@ use LdapRecord\Query\Builder; use LdapRecord\Query\Collection as LDAPCollection; use LdapRecord\Query\ObjectNotFoundException; -use App\Classes\LDAP\Schema\{AttributeType,Base,LDAPSyntax,MatchingRule,MatchingRuleUse,ObjectClass}; +use App\Classes\LDAP\Schema\{AttributeType,Base,LDAPSyntax,MatchingRule,ObjectClass}; use App\Exceptions\InvalidUsage; use App\Ldap\Entry; @@ -28,7 +28,6 @@ final class Server private Collection $attributetypes; private Collection $ldapsyntaxes; private Collection $matchingrules; - private Collection $matchingruleuse; private Collection $objectclasses; /* ObjectClass Types */ @@ -176,7 +175,7 @@ final class Server } if (! $objects) - return collect($rootdse->namingcontexts); + return collect($rootdse->namingcontexts ?: []); return Cache::remember('basedns'.Session::id(),config('ldap.cache.time'),function() use ($rootdse) { $result = collect(); @@ -464,7 +463,6 @@ final class Server case 'matchingrules': Log::debug(sprintf('%s:Matching Rules',self::LOGKEY)); - $this->matchingruleuse = collect(); foreach ($schema->{$item} as $line) { if (is_null($line) || ! strlen($line)) @@ -474,31 +472,11 @@ final class Server $this->matchingrules->put($o->name_lc,$o); } - /* - * For each MatchingRuleUse entry, add the attributes who use it to the - * MatchingRule in the $rules array. - */ - if ($schema->matchingruleuse) { - foreach ($schema->matchingruleuse as $line) { - if (is_null($line) || ! strlen($line)) - continue; + foreach ($this->schema('attributetypes') as $attr) { + $rule_key = strtolower($attr->getEquality()); - $o = new MatchingRuleUse($line); - $this->matchingruleuse->put($o->name_lc,$o); - - if ($this->matchingrules->has($o->name_lc) !== FALSE) - $this->matchingrules[$o->name_lc]->setUsedByAttrs($o->getUsedByAttrs()); - } - - } else { - /* No MatchingRuleUse entry in the subschema, so brute-forcing - * the reverse-map for the "$rule->getUsedByAttrs()" data.*/ - foreach ($this->schema('attributetypes') as $attr) { - $rule_key = strtolower($attr->getEquality()); - - if ($this->matchingrules->has($rule_key) !== FALSE) - $this->matchingrules[$rule_key]->addUsedByAttr($attr->name); - } + if ($this->matchingrules->has($rule_key) !== FALSE) + $this->matchingrules[$rule_key]->addUsedByAttr($attr->name); } return $this->matchingrules;