getConfig() public method

Get the DomainConfiguration instance in use by the connection.
public getConfig ( ) : DomainConfiguration
return LdapTools\DomainConfiguration
 function let(LdapManager $ldap, LdapQueryBuilder $qb, LdapQuery $query, LdapConnectionInterface $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'];
     $config = new DomainConfiguration('foo.bar');
     $filter = new ADFilterBuilder();
     $ldapObject = new LdapObject($this->attr, ['user'], ['user'], 'user');
     $query->getSingleResult()->willReturn($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($filter);
     $qb->where($filter->hasMemberRecursively($this->attr['guid'], 'members'))->willReturn($qb);
     $ldap->buildLdapQuery()->willReturn($qb);
     $connection->getConfig()->willReturn($config);
     $ldap->getConnection()->willReturn($connection);
     $this->beConstructedWith($ldap, $attrMap, $roleMap, true);
 }
示例#2
0
 /**
  * @param string $type
  * @return \LdapTools\Schema\LdapObjectSchema
  */
 protected function getSchemaForType($type)
 {
     if (!$this->schemaFactory || !$this->connection) {
         throw new InvalidArgumentException('If you set a schema type for a LDIF entry you must use a SchemaFactory and LdapConnection in the LDIF constructor.');
     }
     return $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type);
 }
 /**
  * @param \Symfony\Component\Security\Core\User\UserProviderInterface $userProvider
  * @param \LdapTools\Bundle\LdapToolsBundle\Security\User\LdapUserChecker $userChecker
  * @param \LdapTools\LdapManager $ldap
  * @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token
  * @param \LdapTools\Bundle\LdapToolsBundle\Security\User\LdapUser $user
  * @param \LdapTools\Connection\LdapConnectionInterface $connection
  * @param \LdapTools\Operation\AuthenticationResponse $response
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
  */
 function let($userProvider, $userChecker, $ldap, $token, $user, $connection, $response, $dispatcher)
 {
     $this->userProvider = $userProvider;
     $this->userChecker = $userChecker;
     $this->ldap = $ldap;
     $this->token = $token;
     $this->user = $user;
     $this->connection = $connection;
     $this->operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar');
     $this->response = $response;
     $this->dispatcher = $dispatcher;
     $token->getUsername()->willReturn('foo');
     $token->getCredentials()->willReturn('bar');
     $token->hasAttribute('ldap_domain')->willReturn(false);
     $token->getAttributes()->willReturn([]);
     $this->userProvider->loadUserByUsername('foo')->willReturn($user);
     $this->connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $this->connection->execute($this->operation)->willReturn($this->response);
     $this->response->isAuthenticated()->willReturn(true);
     $this->ldap->getConnection()->willReturn($this->connection);
     $this->ldap->getDomainContext()->willReturn('foo.bar');
     $this->user->getUsername()->willReturn('foo');
     $this->user->getRoles()->willReturn(['ROLE_USER']);
     $this->user->isAccountNonLocked()->willReturn(true);
     $this->user->isEnabled()->willReturn(true);
     $this->user->isAccountNonExpired()->willReturn(true);
     $this->user->isCredentialsNonExpired()->willReturn(true);
     $this->beConstructedWith('restricted', true, $this->userProvider, new LdapUserChecker(), $this->ldap, $this->dispatcher);
 }
示例#4
0
 /**
  * Do the LDAP query to get the LDAP object.
  *
  * @param bool $anonymous
  * @return \LdapTools\Object\LdapObject
  */
 protected function doLdapQuery($anonymous)
 {
     if ($anonymous) {
         $this->connection->connect('', '', true);
     }
     $schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
     return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
 }
 function let(\LdapTools\Connection\LdapConnectionInterface $connection)
 {
     $options = ['addressType' => ['exchangeSmtpAddress' => 'smtp', 'exchangeDefaultSmtpAddress' => 'smtp'], 'default' => ['exchangeDefaultSmtpAddress']];
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $this->setOptions($options);
     $this->setLdapConnection($connection);
     $this->setDn('cn=foo,dc=foo,dc=bar');
 }
示例#6
0
 /**
  * Get a FilterBuilder instance based on the connection.
  * 
  * @param LdapConnectionInterface|null $connection
  * @return ADFilterBuilder|FilterBuilder
  */
 public static function getInstance(LdapConnectionInterface $connection = null)
 {
     if ($connection && $connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD) {
         $filterBuilder = new ADFilterBuilder();
     } else {
         $filterBuilder = new self();
     }
     return $filterBuilder;
 }
示例#7
0
 function let(LdapConnectionInterface $connection, EventDispatcherInterface $dispatcher)
 {
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == "(&(objectClass=*))" && $operation->getBaseDn() == "";
     }))->willReturn($this->entry);
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $connection->isBound()->willReturn(false);
     $connection->connect('', '', true)->willReturn(null);
     $this->beConstructedWith($connection, $dispatcher);
 }
 function let(LdapConnectionInterface $connection, AddOperation $operation)
 {
     $schema = new LdapObjectSchema('ad', 'user');
     $schema->setAttributeMap(['username' => 'sAMAccountName', 'emailAddress' => 'mail', 'disabled' => 'userAccountControl', 'passwordMustChange' => 'pwdLastSet', 'passwordNeverExpires' => 'userAccountControl', 'trustedForAllDelegation' => 'userAccountControl', 'groups' => 'memberOf']);
     $schema->setConverterMap(['disabled' => 'user_account_control', 'passwordMustChange' => 'password_must_change', 'trustedForAllDelegation' => 'user_account_control', 'passwordNeverExpires' => 'user_account_control', 'groups' => 'group_membership']);
     $schema->setConverterOptions(['user_account_control' => ['uacMap' => ['disabled' => '2', 'passwordNeverExpires' => '65536', 'smartCardRequired' => '262144', 'trustedForAllDelegation' => '524288', 'passwordIsReversible' => '128'], 'defaultValue' => '512'], 'group_membership' => ['groups' => ['to_attribute' => 'member', 'from_attribute' => 'memberOf', 'attribute' => 'sAMAccountName', 'filter' => ['objectClass' => 'group']]]]);
     $this->schema = $schema;
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $this->beConstructedThrough('getInstance', [$schema, $this->entryTo, AttributeConverterInterface::TYPE_CREATE]);
 }
 function let(LdapConnectionInterface $connection, LdapObject $rootdse)
 {
     $domain = new DomainConfiguration('example.local');
     $domain->setUseTls(true);
     $connection->getConfig()->willReturn($domain);
     $connection->getRootDse()->willReturn($rootdse);
     $config = new Configuration();
     $this->parser = new SchemaYamlParser($config->getSchemaFolder());
     $this->schema = $this->parser->parse('ad', 'user');
 }
 function let(LdapManager $ldap, LdapConnectionInterface $connection, RouterInterface $router, EventDispatcherInterface $dispatcher)
 {
     $this->userChecker = new LdapUserChecker();
     $this->request = new Request();
     $this->request->setSession(new Session());
     $router->generate('login')->willReturn('/login');
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $ldap->getConnection()->willReturn($connection);
     $ldap->getDomainContext()->willReturn('foo.bar');
     $this->beConstructedWith(true, $this->userChecker, $ldap, $router, $dispatcher);
 }
示例#11
0
 /**
  * Get the batch modification array that ldap_modify_batch expects.
  *
  * @param BatchModifyOperation $operation
  * @param string $type
  */
 protected function hydrateOperation(BatchModifyOperation $operation, $type)
 {
     $this->hydrator->setOperationType(AttributeConverterInterface::TYPE_MODIFY);
     if ($type) {
         $this->hydrator->setLdapObjectSchema($this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type));
     }
     $this->hydrator->hydrateToLdap($operation);
     if ($type) {
         $this->hydrator->setLdapObjectSchema(null);
     }
 }
 function let(LdapConnectionInterface $connection)
 {
     $schema = new LdapObjectSchema('ad', 'user');
     $schema->setAttributeMap(['username' => 'sAMAccountName', 'emailAddress' => 'mail', 'disabled' => 'userAccountControl', 'passwordMustChange' => 'pwdLastSet', 'passwordNeverExpires' => 'userAccountControl', 'trustedForAllDelegation' => 'userAccountControl', 'groups' => 'memberOf']);
     $schema->setConverterMap(['disabled' => 'user_account_control', 'passwordMustChange' => 'password_must_change', 'trustedForAllDelegation' => 'user_account_control', 'passwordNeverExpires' => 'user_account_control', 'groups' => 'group_membership']);
     $schema->setConverterOptions(['user_account_control' => ['uacMap' => ['disabled' => '2', 'passwordNeverExpires' => '65536', 'smartCardRequired' => '262144', 'trustedForAllDelegation' => '524288', 'passwordIsReversible' => '128'], 'defaultValue' => '512'], 'group_membership' => ['groups' => ['to_attribute' => 'member', 'from_attribute' => 'memberOf', 'attribute' => 'sAMAccountName', 'filter' => ['objectClass' => 'group']]]]);
     $this->expectedSearch = new QueryOperation('(&(distinguishedName=cn=foo,dc=foo,dc=bar))', ['userAccountControl']);
     $this->schema = $schema;
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $connection->getRootDse()->willReturn(new LdapObject(['foo' => 'bar']));
 }
 function let(LdapConnectionInterface $connection, EventDispatcherInterface $dispatcher, LdapLoggerInterface $logger)
 {
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $connection->getConnection()->willReturn(null);
     $connection->isBound()->willReturn(true);
     $connection->getServer()->willReturn('foo');
     $connection->getIdleTime()->willReturn(1);
     $this->setConnection($connection);
     $this->setEventDispatcher($dispatcher);
     $this->setLogger($logger);
 }
 function let(\LdapTools\Connection\LdapConnectionInterface $connection)
 {
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $options = ['defaultValue' => '-2147483646', 'distribution' => 'typeDistribution', 'types' => ['scope' => ['scopeDomainLocal', 'scopeGlobal', 'scopeUniversal'], 'type' => ['typeBuiltin', 'typeSecurity', 'typeDistribution']], 'typeMap' => ['typeBuiltin' => '1', 'typeSecurity' => '2147483648', 'typeDistribution' => '2147483648', 'scopeDomainLocal' => '4', 'scopeGlobal' => '2', 'scopeUniversal' => '8']];
     $this->expectedSearch = new QueryOperation('(&(distinguishedName=cn=foo,dc=foo,dc=bar))', ['groupType']);
     $this->setOptions($options);
     $this->setLdapConnection($connection);
     $this->setDn('cn=foo,dc=foo,dc=bar');
     $this->expectedOp = function ($operation) {
         return $operation->getFilter() == '(&(objectClass=*))' && $operation->getBaseDn() == 'cn=foo,dc=foo,dc=bar';
     };
 }
示例#15
0
 /**
  * Specify the object type to create. Either by its string name type from the schema of the LdapObjectSchema.
  *
  * @param string|LdapObjectSchema $type
  * @return $this
  */
 public function create($type)
 {
     if (!is_string($type) && !$type instanceof LdapObjectSchema) {
         throw new InvalidArgumentException('You must either pass the schema object type as a string to this method, or pass the schema types ' . 'LdapObjectSchema to this method.');
     }
     if (!$type instanceof LdapObjectSchema) {
         $type = $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type);
     }
     $this->schema = $type;
     $this->container = $type->getDefaultContainer();
     return $this;
 }
 public function let(LdapConnectionInterface $connection)
 {
     $config = new Configuration();
     $config->setCacheType('none');
     $connection->execute(Argument::any())->willReturn($this->ldapEntries);
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $cache = CacheFactory::get($config->getCacheType(), $config->getCacheOptions());
     $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder());
     $dispatcher = new SymfonyEventDispatcher();
     $schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $dispatcher);
     $this->beConstructedWith($schemaFactory->get('ad', 'user'), $connection);
 }
 function let(\LdapTools\Connection\LdapConnectionInterface $connection)
 {
     $config = new DomainConfiguration('foo.bar');
     $config->setBaseDn('dc=foo,dc=bar');
     $connection->getConfig()->willReturn($config);
     $options = ['uacMap' => ['disabled' => '2', 'enabled' => '2', 'passwordNeverExpires' => '65536', 'smartCardRequired' => '262144', 'trustedForAllDelegation' => '262144', 'trustedForAnyAuthDelegation' => '16777216', 'passwordIsReversible' => '128'], 'defaultValue' => '512', 'invert' => ['enabled']];
     $this->setOptions($options);
     $this->setLdapConnection($connection);
     $this->setDn('cn=foo,dc=foo,dc=bar');
     $this->expectedOp = function ($operation) {
         return $operation->getFilter() == '(&(objectClass=*))' && $operation->getAttributes() == ['userAccountControl'] && $operation->getBaseDn() == 'cn=foo,dc=foo,dc=bar';
     };
 }
 function it_should_throw_an_exception_if_ssl_or_tls_is_not_enabled(\LdapTools\Connection\LdapConnectionInterface $connection)
 {
     $this->toLdap('test')->shouldNotThrow('\\LdapTools\\Exception\\LdapConnectionException');
     $config = new DomainConfiguration('example.local');
     $config->setUseTls(true);
     $connection->getConfig()->willReturn($config);
     $this->setLdapConnection($connection);
     $this->toLdap('test')->shouldNotThrow('\\LdapTools\\Exception\\LdapConnectionException');
     $config->setUseTls(false);
     $this->shouldThrow('\\LdapTools\\Exception\\LdapConnectionException')->duringToLdap('test');
     $config->setUseSsl(true);
     $this->toLdap('test')->shouldNotThrow('\\LdapTools\\Exception\\LdapConnectionException');
 }
 function let(LdapConnectionInterface $connection)
 {
     $config = (new DomainConfiguration('example.com'))->setSchemaName('example');
     $connection->getConfig()->willReturn($config);
     $config = new Configuration();
     $parserTest = SchemaParserFactory::get($config->getSchemaFormat(), __DIR__ . '/../resources/schema');
     $parser = SchemaParserFactory::get($config->getSchemaFormat(), __DIR__ . '/../../resources/schema');
     $cache = CacheFactory::get('none', []);
     $this->dispatcherTest = new SymfonyEventDispatcher();
     $this->dispatcher = new SymfonyEventDispatcher();
     $this->objectSchemaFactoryTest = new LdapObjectSchemaFactory($cache, $parserTest, $this->dispatcherTest);
     $this->objectSchemaFactory = new LdapObjectSchemaFactory($cache, $parser, $this->dispatcher);
     $this->beConstructedWith($connection, $this->objectSchemaFactory, $this->dispatcher);
 }
示例#20
0
 /**
  * Encodes any values with the needed type for LDAP.
  *
  * @param array|string $values
  * @return array
  */
 protected function encodeValues($values)
 {
     if (is_null($this->connection) || $this->type == AttributeConverterInterface::TYPE_SEARCH_FROM) {
         return $values;
     }
     $encoded = is_array($values) ? $values : [$values];
     foreach ($encoded as $index => $value) {
         if (is_string($value)) {
             $encoded[$index] = LdapUtilities::encode($value, $this->connection->getConfig()->getEncoding());
         }
     }
     // This is to pass it back the same way it was received. ldap_modify_batch is picky about values being an array.
     return is_array($values) ? $encoded : reset($encoded);
 }
 /**
  * @param \LdapTools\LdapManager $ldap
  * @param \LdapTools\Connection\LdapConnectionInterface $connection
  * @param \Symfony\Component\Routing\RouterInterface $router
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
  */
 function let($ldap, $connection, $router, $dispatcher)
 {
     $this->ldap = $ldap;
     $this->router = $router;
     $this->userChecker = new LdapUserChecker();
     $this->connection = $connection;
     $this->config = new DomainConfiguration('foo.bar');
     $this->request = new Request();
     $this->request->setSession(new Session());
     $this->dispatcher = $dispatcher;
     $this->router->generate('login')->willReturn('/login');
     $this->connection->getConfig()->willReturn($this->config);
     $this->ldap->getConnection()->willReturn($this->connection);
     $this->ldap->getDomainContext()->willReturn('foo.bar');
     $this->beConstructedWith(true, $this->userChecker, $ldap, $router, $dispatcher);
 }
 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);
 }
示例#23
0
 function let(LdapConnectionInterface $connection)
 {
     $attribbutes = ['defaultNamingContext' => 'dc=example,dc=local', 'configurationNamingContext' => 'cn=Configuration,dc=example,dc=local'];
     $rootDse = new LdapObject($attribbutes);
     $this->filter = new OperatorCollection();
     $this->filter->add(new Comparison('foo', '=', 'bar'));
     $this->operation = new QueryOperation($this->filter);
     $this->operation->setFilter($this->filter);
     $this->operation->setAttributes(["cn", "givenName", "foo"]);
     $op = clone $this->operation;
     $op->setFilter($this->filter->toLdapFilter());
     $connection->execute($op)->willReturn($this->ldapEntries);
     $connection->getRootDse()->willReturn($rootDse);
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $this->beConstructedWith($connection);
     $this->setQueryOperation($this->operation);
 }
 public function let(LdapConnectionInterface $connection)
 {
     $this->config = (new DomainConfiguration('example.com'))->setSchemaName('example');
     $this->config->setUseTls(true);
     $ldapObject = new LdapObject(['defaultNamingContext' => 'dc=example,dc=com'], ['*'], '', 'ad');
     $connection->getConfig()->willReturn($this->config);
     $connection->getRootDse()->willReturn($ldapObject);
     $config = new Configuration();
     $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder());
     $parserTest = SchemaParserFactory::get($config->getSchemaFormat(), __DIR__ . '/../../resources/schema');
     $cache = CacheFactory::get('none', []);
     $this->dispatcher = new SymfonyEventDispatcher();
     $this->schemaFactoryTest = new LdapObjectSchemaFactory($cache, $parserTest, $this->dispatcher);
     $this->schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $this->dispatcher);
     $this->attributes['unicodePwd'] = (new EncodeWindowsPassword())->toLdap('12345');
     $this->addOperation = (new AddOperation('foo'))->setDn("cn=somedude,dc=foo,dc=bar")->setAttributes($this->attributes);
     $this->beConstructedWith($connection, $this->schemaFactoryTest, $this->dispatcher);
 }
 function let(\LdapTools\Connection\LdapConnectionInterface $connection)
 {
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $this->setLdapConnection($connection);
     $this->setDn('cn=foo,dc=foo,dc=bar');
     $dn = $this->dn;
     $groupSidHex = $this->groupSidHex;
     $connection->execute(Argument::that(function ($operation) use($dn) {
         return $operation->getFilter() == '(&(objectClass=*))' && $operation->getAttributes() == ['objectSid'] && $operation->getBaseDn() == $dn;
     }))->willReturn(['count' => 1, ["objectsid" => ["count" => 1, 0 => pack('H*', str_replace('\\', '', $this->userSidHex))], 0 => "objectsid", 'count' => 1, 'dn' => $this->dn]]);
     $connection->execute(Argument::that(function ($operation) use($groupSidHex) {
         return $operation->getFilter() == '(&(objectSid=' . $groupSidHex . '))' && $operation->getAttributes() == ['cn'];
     }))->willReturn(['count' => 1, ["cn" => ["count" => 1, 0 => 'Domain Users'], 0 => "cn", "count" => 1, "dn" => "CN=Domain Users,CN=Users,dc=example,dc=local"]]);
     $connection->execute(Argument::that(function ($operation) use($dn) {
         return $operation->getFilter() == '(&(objectClass=group)(cn=Domain Users)(member=' . $dn . ')(groupType:1.2.840.113556.1.4.803:=2147483648))' && $operation->getAttributes() == ['objectSid'];
     }))->willReturn(['count' => 1, ["objectSid" => ["count" => 1, 0 => pack('H*', str_replace('\\', '', $this->groupSidHex))], 0 => "objectSid", "count" => 1, "dn" => "CN=Domain Users,CN=Users,dc=example,dc=local"]]);
     $connection->execute(Argument::that(function ($operation) use($dn) {
         return $operation->getFilter() == '(&(objectClass=group)(cn=Domain Users)(member=foo)(groupType:1.2.840.113556.1.4.803:=2147483648))' && $operation->getAttributes() == ['objectSid'];
     }))->willReturn(['count' => 0]);
 }
 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);
 }
 function let(UserProviderInterface $userProvider, LdapUserChecker $userChecker, LdapManager $ldap, TokenInterface $token, LdapUser $user, LdapConnectionInterface $connection, AuthenticationResponse $response, \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher)
 {
     $this->operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar');
     $token->getUsername()->willReturn('foo');
     $token->getCredentials()->willReturn('bar');
     $token->hasAttribute('ldap_domain')->willReturn(false);
     $token->getAttributes()->willReturn([]);
     $token->getUser()->willReturn($user);
     $userProvider->loadUserByUsername('foo')->willReturn($user);
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $connection->execute($this->operation)->willReturn($response);
     $response->isAuthenticated()->willReturn(true);
     $ldap->getConnection()->willReturn($connection);
     $ldap->getDomainContext()->willReturn('foo.bar');
     $user->getUsername()->willReturn('foo');
     $user->getRoles()->willReturn(['ROLE_USER']);
     $user->isAccountNonLocked()->willReturn(true);
     $user->isEnabled()->willReturn(true);
     $user->isAccountNonExpired()->willReturn(true);
     $user->isCredentialsNonExpired()->willReturn(true);
     $this->beConstructedWith('restricted', true, $userProvider, new LdapUserChecker(), $ldap, $dispatcher);
 }
示例#28
0
 function let(\LdapTools\Connection\LdapConnectionInterface $connection)
 {
     $this->expectedCurrentValueResult[0]['gplink'][0] = implode('', $this->gPLinks);
     $this->expectedDisplayResult[0]['objectguid'][0] = (new GUID('8E1F85EB-4882-4920-88A5-CF52F31D8D31'))->toBinary();
     $this->expectedDisplayResult[1]['objectguid'][0] = (new GUID('B261DB28-5EA3-4D69-B79D-5C22E8018183'))->toBinary();
     $this->expectedSingleDisplayResult[0]['objectguid'][0] = (new GUID('8E1F85EB-4882-4920-88A5-CF52F31D8D31'))->toBinary();
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(|(distinguishedName=cn={B261DB28-5EA3-4D69-B79D-5C22E8018183},cn=policies,cn=system,DC=example,DC=local)(distinguishedName=cn={8E1F85EB-4882-4920-88A5-CF52F31D8D31},cn=policies,cn=system,DC=example,DC=local)))';
     }))->willReturn($this->expectedDisplayResult);
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(|(distinguishedName=cn={8E1F85EB-4882-4920-88A5-CF52F31D8D31},cn=policies,cn=system,DC=example,DC=local)))';
     }))->willReturn($this->expectedSingleDisplayResult);
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(|(displayName=Foo)(displayName=Bar)))';
     }))->willReturn($this->expectedDNResult);
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(objectClass=*))' && $operation->getBaseDn() == 'ou=foo,dc=foo,dc=bar';
     }))->willReturn($this->expectedCurrentValueResult);
     $connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
     $this->setLdapConnection($connection);
     $this->setDn('ou=foo,dc=foo,dc=bar');
     $this->expectedGPOLinks = [new GPOLink(new LdapObject(['dn' => 'cn={B261DB28-5EA3-4D69-B79D-5C22E8018183},cn=policies,cn=system,DC=example,DC=local', 'guid' => 'b261db28-5ea3-4d69-b79d-5c22e8018183', 'name' => 'Bar']), 2), new GPOLink(new LdapObject(['dn' => 'cn={8E1F85EB-4882-4920-88A5-CF52F31D8D31},cn=policies,cn=system,DC=example,DC=local', 'guid' => '8e1f85eb-4882-4920-88a5-cf52f31d8d31', 'name' => 'Foo']), 0)];
 }
示例#29
0
 function it_should_get_an_instance_through_the_factory_method(LdapConnectionInterface $connection)
 {
     $connection->getConfig()->willReturn((new DomainConfiguration('foo.bar'))->setLdapType('ad'));
     $this::getInstance($connection)->shouldReturnAnInstanceOf('LdapTools\\Query\\Builder\\ADFilterBuilder');
 }
示例#30
0
 function let(LdapConnectionInterface $connection)
 {
     $connection->getConfig()->willReturn(new DomainConfiguration('sub.example.local'));
     $connection->getRootDse()->willReturn(new LdapObject(['rootDomainNamingContext' => 'example.local', 'defaultNamingContext' => 'sub.example.local']));
     $this->beConstructedWith($connection);
 }