setAttributes() public method

Set the attributes selected or added to/from LDAP (add or select operation).
public setAttributes ( array $attributes )
$attributes array
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
 /**
  * @param AddOperation $operation
  */
 protected function hydrateAddOperation(AddOperation $operation)
 {
     $this->setDefaultParameters();
     $operation->setAttributes(parent::hydrateToLdap($operation->getAttributes()));
     $this->setDnToUse($operation);
     $operation->setAttributes($this->filterAttributeValues($operation->getAttributes()));
 }
Ejemplo n.º 3
0
 /**
  * Workaround AD special cases with the unicodePwd attribute...
  *
  * @link https://support.microsoft.com/en-us/kb/263991
  * @param AddOperation $operation
  */
 protected function unicodePwdHack(AddOperation $operation)
 {
     if (!$this->isUnicodePwdHackNeeded()) {
         return;
     }
     $attributes = $operation->getAttributes();
     foreach ($attributes as $attribute => $value) {
         if (strtolower($attribute) !== 'unicodepwd') {
             continue;
         }
         $value = is_array($value) ? reset($value) : $value;
         $attributes[$attribute] = base64_encode($value);
     }
     $operation->setAttributes($attributes);
 }