setAttributes() public method

Set the attributes to be selected for the query operation.
public setAttributes ( array $attributes )
$attributes array
Exemplo n.º 1
0
 function it_should_sort_case_sensitive_if_specified($connection)
 {
     $this->setIsCaseSensitiveSort(true)->shouldReturnAnInstanceOf('LdapTools\\Query\\LdapQuery');
     $this->operation->setAttributes(['givenName', 'sn', 'whenCreated']);
     $this->setOrderBy(['givenName' => 'ASC']);
     $entries = $this->sortEntries;
     $entries[1]['givenname'][0] = 'archie';
     $connection->execute(Argument::that(function ($op) {
         return $op->getAttributes() == ['givenName', 'sn', 'whenCreated'];
     }))->willReturn($entries);
     $this->getResult()->shouldHaveFirstValue('givenName', 'archie');
     $this->setOrderBy(['givenName' => 'DESC']);
     $this->getResult()->shouldHaveFirstValue('givenName', 'Archie');
 }
Exemplo n.º 2
0
 /**
  * @param QueryOperation $operation
  */
 protected function hydrateQueryOperation(QueryOperation $operation)
 {
     $operation->setAttributes($this->getAttributesToLdap($operation->getAttributes(), true, $this->schema, $this->alias));
     // Only want it set if it wasn't explicitly set...
     if ($this->schema && is_null($operation->getBaseDn())) {
         $operation->setBaseDn($this->schema->getBaseDn());
     }
     // Empty check instead of null due to the way the BaseDN is set for a RootDSE query...
     if (!empty($operation->getBaseDn()) && ParameterResolver::hasParameters($operation->getBaseDn())) {
         $this->setDefaultParameters();
         $operation->setBaseDn($this->resolveParameters(['baseDn' => $operation->getBaseDn()])['baseDn']);
     }
     // If null then we default to the domain config or the explicitly set value...
     if ($this->schema && !is_null($this->schema->getUsePaging())) {
         $operation->setUsePaging($this->schema->getUsePaging());
     }
     if ($this->schema && !is_null($this->schema->getScope())) {
         $operation->setScope($this->schema->getScope());
     }
     if ($this->schema) {
         $operation->addControl(...$this->schema->getControls());
     }
     if ($operation->getFilter() instanceof OperatorCollection) {
         $this->convertValuesToLdap($operation->getFilter());
         $operation->setFilter($operation->getFilter()->toLdapFilter($this->alias));
     }
 }
Exemplo n.º 3
0
 public function let()
 {
     $this->operation = new QueryOperation('(foo=bar)');
     $this->operation->setAttributes(['foo'])->setBaseDn('foo')->setPageSize(2000)->setScope(QueryOperation::SCOPE['SUBTREE']);
     $this->beConstructedWith($this->operation);
 }
Exemplo n.º 4
0
 function it_should_correctly_add_attributes_to_select_based_off_aliases_in_the_order_by_selection($connection)
 {
     $this->setLdapConnection($connection);
     $gSchema = $this->parser->parse('ad', 'group');
     $operators = new OperatorCollection();
     $operators->addLdapObjectSchema($this->schema, 'u');
     $operators->addLdapObjectSchema($gSchema, 'g');
     $operationSelect = new QueryOperation($operators);
     $operationDefault = clone $operationSelect;
     $operationSelect->setAttributes(['u.firstName', 'u.lastName', 'name', 'g.description', 'g.members']);
     $operationDefault->setAttributes(['g.name', 'g.description']);
     $this->setOrderBy(['g.sid' => LdapQuery::ORDER['DESC'], 'u.department' => LdapQuery::ORDER['ASC'], 'guid' => LdapQuery::ORDER['ASC'], 'u.lastName' => LdapQuery::ORDER['DESC']]);
     // Any specifically selected attributes + specifically aliased attributes in the order by + generic in the order by.
     // Should also avoid adding duplicates.
     $this->setLdapObjectSchema($this->schema);
     $this->setAlias('u');
     $this->hydrateToLdap(clone $operationSelect)->getAttributes()->shouldBeEqualTo(['givenName', 'sn', 'cn', 'department', 'objectGuid']);
 }