/** * Returns the LDAP filter that will be applied * * @string */ protected function render() { $parts = array(); if (!isset($this->filters['objectClass']) || $this->filters['objectClass'] === null) { // throw new Exception('Object class is mandatory'); } foreach ($this->filters as $key => $value) { $parts[] = sprintf('%s=%s', LdapUtils::quoteForSearch($key), LdapUtils::quoteForSearch($value, true)); } if (count($parts) > 1) { return '(&(' . implode(')(', $parts) . '))'; } else { return '(' . $parts[0] . ')'; } }
/** * @param $dn * @param array $props * @return Node */ public function createChildByDN($dn, $props = array()) { $dn = $this->stripMyDN($dn); $parts = array_reverse(LdapUtils::explodeDN($dn)); $parent = $this; while ($rdn = array_shift($parts)) { if ($parent->hasChildRDN($rdn)) { $child = $parent->getChildByRDN($rdn); } else { $child = Node::createWithRDN($parent, $rdn, (array) $props); $parent->addChild($child); } $parent = $child; } return $child; }