setFilter() public method

Set the operator that will be used as a filter for querying LDAP for this object type.
public setFilter ( BaseOperator $filter )
$filter LdapTools\Query\Operator\BaseOperator
 function let(LdapConnectionInterface $connection)
 {
     $config = new Configuration();
     $domain = new DomainConfiguration('example.com');
     $domain->setServers(['example'])->setBaseDn('dc=example,dc=com')->setLazyBind(true)->setPageSize(500);
     $connection->getConfig()->willReturn($domain);
     $config->setCacheType('none');
     $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder());
     $cache = CacheFactory::get($config->getCacheType(), []);
     $dispatcher = new SymfonyEventDispatcher();
     $schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $dispatcher);
     $this->fb = new FilterBuilder();
     $this->schema = $schemaFactory;
     $this->objectSchema = $schema = new LdapObjectSchema('ad', 'user');
     $this->objectSchema->setFilter($this->fb->bAnd($this->fb->eq('objectCategory', 'person'), $this->fb->eq('objectClass', 'user')));
     $this->beConstructedWith($connection, $schemaFactory);
 }
Esempio n. 2
0
 /**
  * Attempt to find the object type definition in the schema and create its object representation.
  *
  * @param array $schema
  * @param string $schemaName
  * @param string $objectType
  * @return LdapObjectSchema
  * @throws SchemaParserException
  */
 protected function parseYamlForObject(array $schema, $schemaName, $objectType)
 {
     $objectSchema = $this->getObjectFromSchema($schema, $objectType);
     $objectSchema = $this->mergeAnyExtendedSchemas($objectSchema, $schemaName);
     $objectSchema = $this->cleanObjectArray($objectSchema);
     $this->updateObjectArray($schemaName, $objectSchema);
     $ldapObjectSchema = new LdapObjectSchema($schemaName, $objectSchema['type']);
     foreach ($this->optionMap as $option => $setter) {
         if (array_key_exists($option, $objectSchema)) {
             $ldapObjectSchema->{$setter}($objectSchema[$option]);
         }
     }
     $ldapObjectSchema->setFilter($this->parseFilter($ldapObjectSchema, $objectSchema));
     $ldapObjectSchema->setAttributeMap(isset($objectSchema['attributes']) ? $objectSchema['attributes'] : []);
     $ldapObjectSchema->setConverterMap($this->parseConverterMap($objectSchema));
     $ldapObjectSchema->setControls(...$this->parseControls($objectSchema));
     $this->validateObjectSchema($ldapObjectSchema);
     return $ldapObjectSchema;
 }
 function it_should_convert_the_filter_for_a_schema_if_it_uses_mapped_attribute_names_with_converters()
 {
     $this->schema->setFilter(new Comparison('exchangeHideFromGAL', '=', true));
     $this->toLdap()->toLdapFilter()->shouldEqual('(|(msExchHideFromAddressLists=TRUE)(objectClass=organizationalUnit))');
 }
 function it_should_get_the_ldap_filter_for_a_specific_alias()
 {
     $foo = new LdapObjectSchema('foo', 'foo');
     $foo->setFilter(new Comparison('foo', Comparison::EQ, 'bar'));
     $bar = new LdapObjectSchema('foo', 'bar');
     $bar->setFilter(new Comparison('bar', Comparison::EQ, 'foo'));
     $this->addLdapObjectSchema($bar);
     $this->addLdapObjectSchema($foo);
     $this->toLdapFilter('foo')->shouldBeEqualTo('(foo=bar)');
     $this->toLdapFilter('bar')->shouldBeEqualTo('(bar=foo)');
 }
Esempio n. 5
0
 function it_should_limit_the_results_for_subsequent_operations_if_a_size_limit_is_set_so_we_dont_go_over_the_limit($connection)
 {
     $foo = new LdapObjectSchema('foo', 'foo');
     $bar = new LdapObjectSchema('foo', 'bar');
     $foo->setFilter(new Comparison('foo', '=', 'bar'));
     $bar->setFilter(new Comparison('bar', '=', 'foo'));
     $filter = new OperatorCollection();
     $filter->addLdapObjectSchema($foo);
     $filter->addLdapObjectSchema($bar);
     $this->operation->setFilter($filter);
     $this->operation->setAttributes([]);
     $this->operation->setSizeLimit(4);
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(foo=bar)' && $op->getSizeLimit() == 4;
     }))->shouldBeCalled()->willReturn($this->ldapEntries);
     // The above returns 2 results, since the limit is 4 this next call should be set to a max of 2...
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(bar=foo)' && $op->getSizeLimit() == 2;
     }))->shouldBeCalled()->willReturn($this->sortEntries);
     $this->getResult();
 }