getRootDse() public method

Return a RootDse LDAP object for this connection.
public getRootDse ( ) : LdapObject
return LdapTools\Object\LdapObject
コード例 #1
0
 function let(LdapConnectionInterface $connection, LdapObject $rootdse)
 {
     $domain = new DomainConfiguration('example.local');
     $domain->setUseTls(true);
     $connection->getConfig()->willReturn($domain);
     $connection->getRootDse()->willReturn($rootdse);
     $config = new Configuration();
     $this->parser = new SchemaYamlParser($config->getSchemaFolder());
     $this->schema = $this->parser->parse('ad', 'user');
 }
コード例 #2
0
 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']));
 }
コード例 #3
0
ファイル: LdapQuerySpec.php プロジェクト: ldaptools/ldaptools
 function let(LdapConnectionInterface $connection)
 {
     $attribbutes = ['defaultNamingContext' => 'dc=example,dc=local', 'configurationNamingContext' => 'cn=Configuration,dc=example,dc=local'];
     $rootDse = new LdapObject($attribbutes);
     $this->filter = new OperatorCollection();
     $this->filter->add(new Comparison('foo', '=', 'bar'));
     $this->operation = new QueryOperation($this->filter);
     $this->operation->setFilter($this->filter);
     $this->operation->setAttributes(["cn", "givenName", "foo"]);
     $op = clone $this->operation;
     $op->setFilter($this->filter->toLdapFilter());
     $connection->execute($op)->willReturn($this->ldapEntries);
     $connection->getRootDse()->willReturn($rootDse);
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $this->beConstructedWith($connection);
     $this->setQueryOperation($this->operation);
 }
コード例 #4
0
ファイル: SddlParser.php プロジェクト: ldaptools/ldaptools
 /**
  * @param bool $isRoot
  * @return SID
  */
 protected function getDomainSid($isRoot)
 {
     if (!$isRoot && $this->domainSid) {
         return $this->domainSid;
     } elseif ($isRoot && $this->rootDomainSid) {
         return $this->rootDomainSid;
     }
     $baseDn = $isRoot ? 'rootDomainNamingContext' : 'defaultNamingContext';
     $domainSid = (new LdapQueryBuilder($this->connection))->setBaseDn($this->connection->getRootDse()->get($baseDn))->select('objectSid')->where(['objectClass' => 'domain'])->andWhere(['objectClass' => 'domainDns'])->setSizeLimit(1)->getLdapQuery()->getSingleScalarResult();
     $sid = new SID($domainSid);
     if ($isRoot) {
         $this->rootDomainSid = $sid;
     } else {
         $this->domainSid = $sid;
     }
     return $sid;
 }
コード例 #5
0
 public function let(LdapConnectionInterface $connection)
 {
     $this->config = (new DomainConfiguration('example.com'))->setSchemaName('example');
     $this->config->setUseTls(true);
     $ldapObject = new LdapObject(['defaultNamingContext' => 'dc=example,dc=com'], ['*'], '', 'ad');
     $connection->getConfig()->willReturn($this->config);
     $connection->getRootDse()->willReturn($ldapObject);
     $config = new Configuration();
     $parser = SchemaParserFactory::get($config->getSchemaFormat(), $config->getSchemaFolder());
     $parserTest = SchemaParserFactory::get($config->getSchemaFormat(), __DIR__ . '/../../resources/schema');
     $cache = CacheFactory::get('none', []);
     $this->dispatcher = new SymfonyEventDispatcher();
     $this->schemaFactoryTest = new LdapObjectSchemaFactory($cache, $parserTest, $this->dispatcher);
     $this->schemaFactory = new LdapObjectSchemaFactory($cache, $parser, $this->dispatcher);
     $this->attributes['unicodePwd'] = (new EncodeWindowsPassword())->toLdap('12345');
     $this->addOperation = (new AddOperation('foo'))->setDn("cn=somedude,dc=foo,dc=bar")->setAttributes($this->attributes);
     $this->beConstructedWith($connection, $this->schemaFactoryTest, $this->dispatcher);
 }
コード例 #6
0
 function let(LdapConnectionInterface $connection)
 {
     $connection->getConfig()->willReturn(new DomainConfiguration('sub.example.local'));
     $connection->getRootDse()->willReturn(new LdapObject(['rootDomainNamingContext' => 'example.local', 'defaultNamingContext' => 'sub.example.local']));
     $this->beConstructedWith($connection);
 }
コード例 #7
0
 function it_should_get_the_ldif_string_representation_in_the_context_of_a_type_and_a_schema(LdapConnectionInterface $connection, LdapObject $rootdse)
 {
     $domain = new DomainConfiguration('example.local');
     $domain->setUseTls(true);
     $connection->getConfig()->willReturn($domain);
     $connection->getRootDse()->willReturn($rootdse);
     $config = new Configuration();
     $parser = new SchemaYamlParser($config->getSchemaFolder());
     $schema = $parser->parse('ad', 'user');
     $dn = 'cn=foo,dc=foo,dc=bar';
     $this->beConstructedWith($dn);
     $this->setLdapObjectSchema($schema);
     $this->setLdapConnection($connection);
     $this->add('phoneNumber', '555-5555');
     $this->reset('lastName');
     $this->replace('firstName', 'bar');
     $this->delete('password', 'foo');
     $this->add('password', 'bar');
     $ldif = "dn: {$dn}\r\n" . "changetype: modify\r\n" . "add: telephoneNumber\r\n" . "telephoneNumber: 555-5555\r\n" . "-\r\n" . "delete: sn\r\n" . "-\r\n" . "replace: givenName\r\n" . "givenName: bar\r\n" . "-\r\n" . "delete: unicodePwd\r\n" . "unicodePwd: IgBmAG8AbwAiAA==\r\n" . "-\r\n" . "add: unicodePwd\r\n" . "unicodePwd: IgBiAGEAcgAiAA==\r\n" . "-\r\n";
     $this->toString()->shouldBeEqualTo($ldif);
 }
コード例 #8
0
 function it_should_allow_specifying_the_object_type_to_create_when_calling_createLdapObject(LdapConnectionInterface $connection)
 {
     $domain = (new DomainConfiguration('foo.bar'))->setBaseDn('dc=foo,dc=bar')->setUseTls(true);
     $connection->getConfig()->willReturn($domain);
     $connection->getRootDse()->willReturn(new LdapObject(['dc' => '']));
     $this->beConstructedWith(new Configuration(), $connection);
     $connection->execute(Argument::that(function ($operation) {
         return array_key_exists('samaccountname', array_change_key_case($operation->getAttributes()));
     }))->shouldBeCalled();
     $this->createLdapObject('user')->with(['username' => 'foo', 'password' => 'bar'])->in('dc=foo,dc=bar')->execute();
 }
コード例 #9
0
 function it_should_get_the_ldif_representation_in_the_context_of_a_type_and_schema(LdapConnectionInterface $connection, LdapObject $rootdse)
 {
     $domain = new DomainConfiguration('example.local');
     $domain->setUseTls(true);
     $connection->getConfig()->willReturn($domain);
     $connection->getRootDse()->willReturn($rootdse);
     $config = new Configuration();
     $parser = new SchemaYamlParser($config->getSchemaFolder());
     $schema = $parser->parse('ad', 'user');
     $this->beConstructedWith(null);
     $this->setLdapObjectSchema($schema);
     $this->setLdapConnection($connection);
     $this->setAttributes(['username' => 'John', 'password' => '12345']);
     $this->setLocation('ou=employees,dc=example,dc=local');
     $ldif = "dn: cn=John,ou=employees,dc=example,dc=local\r\n" . "changetype: add\r\n" . "cn: John\r\n" . "displayname: John\r\n" . "givenName: John\r\n" . "userPrincipalName: John@example.local\r\n" . "objectclass: top\r\n" . "objectclass: person\r\n" . "objectclass: organizationalPerson\r\n" . "objectclass: user\r\n" . "sAMAccountName: John\r\n" . "unicodePwd: IgAxADIAMwA0ADUAIgA=\r\n" . "userAccountControl: 512\r\n";
     $this->toString()->shouldBeEqualTo($ldif);
 }