LdapTools\Operation\AddOperation::setAttributes PHP Méthode

setAttributes() public méthode

Set the attributes selected or added to/from LDAP (add or select operation).
public setAttributes ( array $attributes )
$attributes array
    public function setAttributes(array $attributes)
    {
        $this->properties['attributes'] = $attributes;
        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::setAttributes