setAttributeMap() 공개 메소드

Set the map of names to actual LDAP attribute names.
public setAttributeMap ( array $attributeMap )
$attributeMap array
 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 it_should_return_all_LDAP_attributes_merged_with_the_schema_if_a_wildcard_was_used()
 {
     $map = ['firstName' => 'givenName', 'lastName' => 'sn', 'emailAddress' => 'mail', 'name' => 'cn'];
     $schema = new LdapObjectSchema('ad', 'user');
     $schema->setAttributeMap($map);
     $fromLdap = ['givenName' => 'Egon', 'sn' => 'Spengler', 'mail' => '*****@*****.**', 'cn' => 'Egon', 'dn' => 'CN=Egon,dc=whhhhhy,dc=local'];
     $keys = array_unique(array_merge(array_keys($fromLdap), array_keys($map)));
     $this->beConstructedWith($schema);
     $this->fromLdap($fromLdap, ['*'])->shouldHaveKeys($keys);
 }
 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 it_should_hydrate_a_ldap_object_with_batch_modification()
 {
     $schema = new LdapObjectSchema('ad', 'user');
     $schema->setAttributeMap(['firstName' => 'givenName', 'lastName' => 'sn', 'emailAddress' => 'mail', 'username' => 'sAMAccountName']);
     $this->setLdapObjectSchema($schema);
     $ldapObject = new LdapObject(['dn' => 'cn=foo,dc=foo,dc=bar'], [], 'user', 'user');
     $ldapObject->set('firstName', 'Chad');
     $ldapObject->add('lastName', 'Sikorra');
     $ldapObject->remove('username', 'csikorra');
     $ldapObject->reset('emailAddress');
     $this->hydrateToLdap($ldapObject)->shouldBeEqualTo($this->batch);
     $this->hydrateToLdap($ldapObject)->shouldHaveCount(4);
 }
예제 #5
0
 function it_should_convert_values_when_hydrating_to_ldap()
 {
     $schema = new LdapObjectSchema('ad', 'user');
     $schema->setAttributeMap(['foo' => 'bar']);
     $schema->setConverterMap(['foo' => 'bool']);
     $this->setLdapObjectSchema($schema);
     $attributes = $this->objectToLdap;
     $attributes['foo'] = true;
     $this->hydrateToLdap($attributes)->shouldContain('TRUE');
 }
예제 #6
0
 function it_should_query_results_from_multiple_schema_types($connection)
 {
     $foo = new LdapObjectSchema('foo', 'foo');
     $bar = new LdapObjectSchema('foo', 'bar');
     $foo->setFilter(new Comparison('foo', '=', 'bar'));
     $bar->setFilter(new Comparison('bar', '=', 'foo'));
     $map = ['firstName' => 'givenname', 'lastName' => 'sn', 'created' => 'whencreated', 'name' => 'cn'];
     $bar->setAttributeMap($map);
     $bar->setAttributesToSelect(['name', 'created']);
     $bar->setConverterMap(['generalized_time' => ['created']]);
     $foo->setAttributeMap($map);
     $foo->setAttributesToSelect(['firstName', 'lastName']);
     $fb = new FilterBuilder();
     $filter = new OperatorCollection();
     $filter->addLdapObjectSchema($foo);
     $filter->addLdapObjectSchema($bar);
     $filter->add($fb->bAnd($fb->startsWith('foo.firstName', 'J'), $fb->startsWith('bar.name', 'Smith'), $fb->present('lastName')));
     $this->operation->setFilter($filter);
     $this->operation->setAttributes([]);
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(&(foo=bar)(&(givenname=J*)(sn=*)))' && $op->getAttributes() == ['givenname', 'sn'];
     }))->shouldBeCalled()->willReturn($this->ldapEntries);
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(&(bar=foo)(&(cn=Smith*)(sn=*)))' && $op->getAttributes() == ['cn', 'whencreated'];
     }))->shouldBeCalled()->willReturn($this->sortEntries);
     $this->getResult()->count()->shouldBeEqualTo(4);
     $this->getArrayResult()->shouldHaveCount(4);
 }