setLocation() public method

Set the location where the LDAP object should be created (ie. OU/container). This is only valid when the operation is hydrated.
public setLocation ( string $location )
$location string
Ejemplo n.º 1
0
 function it_should_hydrate_an_add_operation_to_ldap($connection)
 {
     $this->setLdapObjectSchema($this->schema);
     $this->setOperationType(AttributeConverterInterface::TYPE_CREATE);
     $this->setLdapConnection($connection);
     $operation = new AddOperation();
     $operation->setAttributes(['username' => 'John', 'password' => '12345', 'groups' => 'cn=foo,dc=example,dc=local']);
     $operation->setLocation('ou=employees,dc=example,dc=local');
     $expected = ['cn' => "John", 'displayname' => "John", 'givenName' => "John", 'userPrincipalName' => "*****@*****.**", 'objectclass' => [0 => "top", 1 => "person", 2 => "organizationalPerson", 3 => "user"], 'sAMAccountName' => "John", 'unicodePwd' => (new EncodeWindowsPassword())->toLdap('12345'), 'userAccountControl' => "512"];
     $original1 = clone $operation;
     $original2 = clone $operation;
     $this->hydrateToLdap($operation)->getAttributes()->shouldBeEqualTo($expected);
     $this->hydrateToLdap($original2)->getPostOperations()->shouldHaveCount(1);
     $this->hydrateToLdap($original1)->getDn()->shouldBeEqualTo('cn=John,ou=employees,dc=example,dc=local');
 }
Ejemplo n.º 2
0
 function it_should_call_creation_events_when_creating_a_ldap_object(EventDispatcherInterface $dispatcher, $connection)
 {
     $this->addOperation->setLocation('dc=foo,dc=bar');
     $connection->execute($this->addOperation)->willReturn(true);
     $beforeEvent = new LdapObjectCreationEvent(Event::LDAP_OBJECT_BEFORE_CREATE);
     $beforeEvent->setContainer('dc=foo,dc=bar');
     $beforeEvent->setData(['username' => '%foo%', 'password' => '%bar%']);
     $beforeEvent->setDn('');
     $afterEvent = new LdapObjectCreationEvent(Event::LDAP_OBJECT_AFTER_CREATE);
     $afterEvent->setContainer('dc=foo,dc=bar');
     $afterEvent->setData(['username' => 'somedude', 'password' => '12345']);
     $afterEvent->setDn('cn=somedude,dc=foo,dc=bar');
     $dispatcher->dispatch($beforeEvent)->shouldBeCalled();
     $dispatcher->dispatch($afterEvent)->shouldBeCalled();
     $this->config->setSchemaName('ad');
     $this->beConstructedWith($connection, $this->schemaFactory, $dispatcher);
     $this->createUser()->with(['username' => '%foo%', 'password' => '%bar%'])->in('dc=foo,dc=bar')->setParameter('foo', 'somedude')->setParameter('bar', '12345');
     $this->execute();
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function toOperation()
 {
     $hydrator = new OperationHydrator();
     $hydrator->setOperationType(AttributeConverterInterface::TYPE_CREATE);
     $operation = new AddOperation($this->dn, $this->attributes);
     $operation->setLocation($this->location);
     return $this->hydrateOperation($hydrator, $operation);
 }
Ejemplo n.º 4
0
 /**
  * Get the add operation and take care of the hydration process.
  *
  * @return AddOperation
  */
 protected function getAddOperation()
 {
     $operation = new AddOperation($this->dn, $this->attributes);
     $operation->setLocation($this->container);
     foreach ($this->parameters as $parameter => $value) {
         $this->hydrator->setParameter($parameter, $value);
     }
     $this->hydrator->setLdapObjectSchema($this->schema);
     $this->hydrator->setLdapConnection($this->connection);
     $this->hydrator->setOperationType(AttributeConverterInterface::TYPE_CREATE);
     return $this->hydrator->hydrateToLdap($operation);
 }