eq() public method

An equal-to comparison.
public eq ( $attribute, $value ) : Comparison
$attribute
$value
return LdapTools\Query\Operator\Comparison
 /**
  * @param bool $value
  * @return \LdapTools\Query\Operator\BaseOperator
  */
 protected function getQueryOperator($value)
 {
     $fb = new FilterBuilder();
     if ($value) {
         $operator = $fb->bAnd($fb->gte('accountExpires', '1'), $fb->lte('accountExpires', '9223372036854775806'));
     } else {
         $operator = $fb->bOr($fb->eq('accountExpires', '0'), $fb->eq('accountExpires', self::NEVER_EXPIRES));
     }
     return $operator;
 }
Exemplo n.º 2
0
 /**
  * @param $objectCategory
  * @return null|\LdapTools\Query\Operator\Comparison
  */
 protected function getCategoryOperator($objectCategory)
 {
     $categoryOperator = null;
     if ($objectCategory) {
         $categoryOperator = $this->filterBuilder->eq(self::ATTR_OBJECT_CATEGORY, $objectCategory);
     }
     return $categoryOperator;
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 /**
  * Create a logical 'or' from the passed arguments. Either pass a key => value array with attribute names and
  * expected values (which will be compared in terms of equality) or pass arbitrary Operator objects using the
  * 'filter' method shortcuts or some other way.
  *
  * @param mixed ...$whereStatements Either a key => value array or an Operator type objects.
  * @return $this
  */
 public function orWhere(...$whereStatements)
 {
     $this->addBaseOrIfNotExists();
     if (1 == count($whereStatements) && is_array($whereStatements[0])) {
         foreach ($whereStatements[0] as $attribute => $value) {
             $this->baseOr->add($this->filterBuilder->eq($attribute, $value));
         }
     } else {
         $this->baseOr->add(...$whereStatements);
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function toLdap($value)
 {
     /**
      * @todo There's a lot more potential logic that needs to happen for this to be accurate...
      */
     if ($this->getOperationType() == AttributeConverterInterface::TYPE_SEARCH_TO && !$value) {
         $fb = new FilterBuilder();
         $value = $fb->bNot($fb->eq('pwdLastSet', '0'));
     } else {
         $value = (bool) $value ? '0' : '-1';
     }
     return $value;
 }
Exemplo n.º 6
0
 /**
  * @param bool $value
  * @return \LdapTools\Query\Operator\bOr|\LdapTools\Query\Operator\Comparison
  */
 protected function getQueryValue($value)
 {
     $fb = new FilterBuilder();
     return $value ? $fb->gte('lockoutTime', '1') : $fb->bOr($fb->notPresent('lockoutTime'), $fb->eq('lockoutTime', '0'));
 }
 function it_should_convert_values_with_operators_to_filters()
 {
     $this->collection->add($this->filter->eq('user.disabled', false));
     $this->toLdap()->toLdapFilter()->shouldEqual('(|(&(&(objectCategory=person)(objectClass=user))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))(&(objectClass=organizationalUnit)))');
 }
Exemplo n.º 8
0
 function it_should_hydrate_a_query_operation_to_ldap_with_a_schema($connection)
 {
     $this->schema->setBaseDn('dc=foo,dc=bar');
     $this->setLdapObjectSchema($this->schema);
     $this->setOperationType(AttributeConverterInterface::TYPE_SEARCH_TO);
     $this->setLdapConnection($connection);
     $filter = new FilterBuilder();
     $collection = new OperatorCollection();
     $collection->add($filter->eq('firstName', 'foo'));
     $collection->add($filter->eq('lastName', 'bar'));
     $collection->add($filter->eq('exchangeHideFromGAL', false));
     $collection->addLdapObjectSchema($this->schema);
     $operation = new QueryOperation($collection, ['foo']);
     $this->hydrateToLdap($operation)->getFilter()->shouldBeEqualTo('(&(&(objectCategory=person)(objectClass=user))(givenName=foo)(sn=bar)(msExchHideFromAddressLists=FALSE))');
     $this->hydrateToLdap($operation)->getBaseDn()->shouldBeEqualTo('dc=foo,dc=bar');
 }