LdapTools\Operation\AddOperation::setLocation PHP Method

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
    public function setLocation($location)
    {
        $this->properties['location'] = $location;
        return $this;
    }

Usage Example

 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');
 }
All Usage Examples Of LdapTools\Operation\AddOperation::setLocation