buildLdapQuery() 공개 메소드

Get a LdapQueryBuilder object.
public buildLdapQuery ( ) : LdapQueryBuilder
리턴 LdapTools\Query\LdapQueryBuilder
 /**
  * @param \LdapTools\LdapManager $ldap
  * @param \LdapTools\Query\LdapQueryBuilder $qb
  * @param \LdapTools\Query\LdapQuery $query
  * @param \LdapTools\Connection\LdapConnectionInterface $connection
  */
 function let($ldap, $qb, $query, $connection)
 {
     $groups = new LdapObjectCollection();
     $groups->add(new LdapObject(['name' => 'Foo', 'dn' => 'cn=Foo,dc=example,dc=local']));
     $groups->add(new LdapObject(['guid' => '291d8444-9d5b-4b0a-a6d7-853408f704d5', 'dn' => 'cn=Bar,dc=example,dc=local']));
     $groups->add(new LdapObject(['sid' => 'S-1-5-18', 'dn' => 'cn=LocalSys,dc=example,dc=local']));
     $groups->add(new LdapObject(['name' => 'Just a DN', 'dn' => 'cn=Stuff,dc=example,dc=local']));
     $roleMap = ['ROLE_AWESOME' => ['foo'], 'ROLE_ADMIN' => ['291d8444-9d5b-4b0a-a6d7-853408f704d5'], 'ROLE_DN' => ['cn=Stuff,dc=example,dc=local'], 'ROLE_SID' => ['S-1-5-18']];
     $attrMap = ['username' => 'username', 'accountNonLocked' => 'locked', 'accountNonExpired' => 'accountExpirationDate', 'enabled' => 'disabled', 'credentialsNonExpired' => 'passwordMustChange', 'guid' => 'guid', 'groups' => 'groups', 'stringRepresentation' => 'username'];
     $this->ldap = $ldap;
     $this->qb = $qb;
     $this->query = $query;
     $this->connection = $connection;
     $this->config = new DomainConfiguration('foo.bar');
     $this->filter = new ADFilterBuilder();
     $this->ldapObject = new LdapObject($this->attr, ['user'], ['user'], 'user');
     $query->getSingleResult()->willReturn($this->ldapObject);
     $query->getResult()->willReturn($groups);
     $query->getArrayResult()->willReturn([['name' => 'foo'], ['name' => 'bar']]);
     $qb->from(LdapObjectType::USER)->willReturn($qb);
     $qb->from('group')->willReturn($qb);
     $qb->select(["username", "locked", "accountExpirationDate", "disabled", "passwordMustChange", "guid", "groups", "username"])->willReturn($qb);
     $qb->select(["name", "sid", "guid"])->willReturn($qb);
     $qb->select('name')->willReturn($qb);
     $qb->where(['username' => 'foo'])->willReturn($qb);
     $qb->getLdapQuery()->willReturn($query);
     $qb->filter()->willReturn($this->filter);
     $qb->where($this->filter->hasMemberRecursively($this->attr['guid'], 'members'))->willReturn($qb);
     $this->ldap->buildLdapQuery()->willReturn($qb);
     $connection->getConfig()->willReturn($this->config);
     $this->ldap->getConnection()->willReturn($connection);
     $this->beConstructedWith($ldap, $attrMap, $roleMap, true);
 }
 /**
  * Get the LDAP objects from LDAP. Optionally only get those specified by the passed values.
  *
  * @param array $values The values used to narrow the LDAP query.
  * @return \LdapTools\Object\LdapObjectCollection
  */
 protected function getLdapObjectsByQuery($values = [])
 {
     if (!$this->ldapQueryBuilder) {
         $query = $this->ldap->buildLdapQuery()->select([$this->id, $this->labelAttribute])->from($this->type);
     } else {
         $query = clone $this->ldapQueryBuilder;
     }
     if (!empty($values)) {
         foreach ($values as $value) {
             $query->orWhere([$this->id => $value]);
         }
     }
     if ($this->queryCallback) {
         $closure = $this->queryCallback;
         $closure($query);
     }
     return $query->getLdapQuery()->getResult();
 }
 /**
  * @param LdapUser $user
  * @return LdapObjectCollection
  */
 protected function getGroupsForUser(LdapUser $user)
 {
     $select = $this->roleAttrMap;
     unset($select['members']);
     $query = $this->ldap->buildLdapQuery()->from($this->groupObjectType)->select(array_values($select));
     if ($this->checkGroupsRecursively) {
         $query->where($query->filter()->hasMemberRecursively($user->getLdapGuid(), $this->roleAttrMap['members']));
     } else {
         $query->where([$this->roleAttrMap['members'] => $user->getLdapGuid()]);
     }
     return $query->getLdapQuery()->getResult();
 }
 public function let(LdapManager $ldap, LdapQueryBuilder $qb, LdapQuery $query, LdapObjectCollection $collection)
 {
     $ldap->getDomainContext()->willReturn('foo.bar');
     $ldap->buildLdapQuery()->willReturn($qb);
     $qb->select(Argument::any())->willReturn($qb);
     $qb->from(Argument::any())->willReturn($qb);
     $qb->getLdapQuery()->willReturn($query);
     $query->getResult()->WillReturn($collection);
     $collection->toArray()->willReturn([]);
     $this->resolver = new OptionsResolver();
     if (Kernel::VERSION >= 2.6) {
         $this->resolver->setDefault('ldap_type', 'user');
     } else {
         $this->resolver->setDefaults(['ldap_type' => 'user']);
     }
     $this->beConstructedWith($ldap);
 }
 function let(Reader $reader, LdapManager $ldap, LifecycleEventArgs $eventArgs, ObjectManager $om, ClassMetadata $metadata, LdapObjectSchemaFactory $schemaFactory, LdapConnectionInterface $connection, LdapObjectSchema $schema, LdapQueryBuilder $qb, LdapQuery $query, $entity)
 {
     $rc = new \ReflectionClass('Doctrine\\Common\\Persistence\\Event\\LifecycleEventArgs');
     if ($rc->hasMethod('getObjectManager')) {
         $eventArgs->getObjectManager()->willReturn($om);
         $eventArgs->getObject()->willReturn($entity);
     } else {
         $eventArgs->getEntityManager()->willReturn($om);
         $eventArgs->getEntity()->willReturn($entity);
     }
     $om->getClassMetadata(Argument::any())->willReturn($metadata);
     $this->config = new DomainConfiguration('foo.bar');
     $connection->getConfig()->willReturn($this->config);
     $ldap->getDomainContext()->willReturn('foo.bar');
     $ldap->getSchemaFactory()->willReturn($schemaFactory);
     $ldap->getConnection()->willReturn($connection);
     $ldap->buildLdapQuery()->willReturn($qb);
     $qb->getLdapQuery()->willReturn($query);
     $this->beConstructedWith($reader, $ldap);
 }
 /**
  * @param \ReflectionProperty $property
  * @param LdapObjectAnnotation $annotation
  * @param $entity
  * @return LdapObject|LdapObjectCollection|null
  */
 protected function queryLdapForObjects(\ReflectionProperty $property, LdapObjectAnnotation $annotation, $entity)
 {
     $query = $this->ldap->buildLdapQuery()->select($this->getLdapAttributesToSelect($annotation))->from($annotation->type);
     $values = $property->getValue($entity);
     // A single LdapObject type...
     if (is_string($values) && !empty($values)) {
         $query->where([$annotation->id => $values]);
         // A LdapObjectCollection type...
     } elseif (is_array($values) && !empty($values)) {
         foreach ($values as $value) {
             $query->orWhere([$annotation->id => $value]);
         }
         // A currently null/empty value?
     } else {
         return null;
     }
     if ($annotation->collection) {
         $results = $query->getLdapQuery()->getResult();
     } else {
         $results = $query->getLdapQuery()->getOneOrNullResult();
     }
     return $results;
 }
 public function let(LdapManager $ldap, LdapQueryBuilder $qb, LdapQuery $query)
 {
     $ldap->buildLdapQuery()->willReturn($qb);
     $qb->getLdapQuery()->willReturn($query);
     $this->beConstructedWith($ldap, LdapObjectType::USER);
 }