本文整理汇总了PHP中Zend\Ldap\Dn::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Dn::fromString方法的具体用法?PHP Dn::fromString怎么用?PHP Dn::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Ldap\Dn
的用法示例。
在下文中一共展示了Dn::fromString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSimpleRecursiveIteration
public function testSimpleRecursiveIteration()
{
$node = $this->getLDAP()->getBaseNode();
$ri = new \RecursiveIteratorIterator($node, \RecursiveIteratorIterator::SELF_FIRST);
$i = 0;
foreach ($ri as $rdn => $n) {
$dn = $n->getDn()->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER);
$rdn = Ldap\Dn::implodeRdn($n->getRdnArray(), Ldap\Dn::ATTR_CASEFOLD_LOWER);
if ($i == 0) {
$this->assertEquals(Ldap\Dn::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE)->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER), $dn);
} elseif ($i == 1) {
$this->assertEquals('ou=Node', $rdn);
$this->assertEquals($this->createDn('ou=Node,'), $dn);
} else {
if ($i < 4) {
$j = $i - 1;
$base = $this->createDn('ou=Node,');
} else {
$j = $i - 3;
$base = Ldap\Dn::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE)->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER);
}
$this->assertEquals('ou=Test' . $j, $rdn);
$this->assertEquals('ou=Test' . $j . ',' . $base, $dn);
}
$i++;
}
$this->assertEquals(9, $i);
}
示例2: createDn
protected function createDn($dn)
{
if (substr($dn, -1) !== ',') {
$dn .= ',';
}
$dn = $dn . TESTS_ZEND_LDAP_WRITEABLE_SUBTREE;
return Ldap\Dn::fromString($dn)->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER);
}
示例3: getSchemaDn
/**
* Returns the schema DN
*
* @return \Zend\Ldap\Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSchemaNamingContext();
return \Zend\Ldap\Dn::fromString($schemaDn);
}
示例4: testSaveWithDnObject
public function testSaveWithDnObject()
{
$dn = Ldap\Dn::fromString($this->_createDn('ou=TestCreated,'));
$data = array('ou' => 'TestCreated', 'objectclass' => 'organizationalUnit');
try {
$this->_getLDAP()->save($dn, $data);
$this->assertTrue($this->_getLDAP()->exists($dn));
$data['l'] = 'mylocation1';
$this->_getLDAP()->save($dn, $data);
$this->assertTrue($this->_getLDAP()->exists($dn));
$entry = $this->_getLDAP()->getEntry($dn);
$this->_getLDAP()->delete($dn);
$this->assertEquals('mylocation1', $entry['l'][0]);
} catch (Ldap\Exception $e) {
if ($this->_getLDAP()->exists($dn)) {
$this->_getLDAP()->delete($dn);
}
$this->fail($e->getMessage());
}
}
示例5: testEmptyStringDn
public function testEmptyStringDn()
{
$dnString = '';
$dn = Ldap\Dn::fromString($dnString);
$this->assertEquals($dnString, $dn->toString());
}
示例6: testArrayAccessImplementation
public function testArrayAccessImplementation()
{
$dnString = 'cn=Baker\\, Alice,cn=Users,dc=example,dc=com';
$dn = Ldap\Dn::fromString($dnString);
$this->assertEquals(array('cn' => 'Baker, Alice'), $dn[0]);
$this->assertEquals(array('cn' => 'Users'), $dn[1]);
$this->assertEquals(array('dc' => 'example'), $dn[2]);
$this->assertEquals(array('dc' => 'com'), $dn[3]);
$this->assertTrue(isset($dn[0]));
$this->assertTrue(isset($dn[1]));
$this->assertTrue(isset($dn[2]));
$this->assertTrue(isset($dn[3]));
$this->assertFalse(isset($dn[-1]));
$this->assertFalse(isset($dn[4]));
$dn = Ldap\Dn::fromString($dnString);
unset($dn[0]);
$this->assertEquals('cn=Users,dc=example,dc=com', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
unset($dn[1]);
$this->assertEquals('cn=Baker\\, Alice,dc=example,dc=com', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
unset($dn[2]);
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=com', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
unset($dn[3]);
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=example', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
$dn[0] = array('uid' => 'abaker');
$this->assertEquals('uid=abaker,cn=Users,dc=example,dc=com', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
$dn[1] = array('ou' => 'Lab');
$this->assertEquals('cn=Baker\\, Alice,ou=Lab,dc=example,dc=com', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
$dn[2] = array('dc' => 'example', 'ou' => 'Test');
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=example+ou=Test,dc=com', $dn->toString());
$dn = Ldap\Dn::fromString($dnString);
$dn[3] = array('dc' => 'de+fr');
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=example,dc=de\\+fr', $dn->toString());
}
示例7: testIsChildOfWithDnObjects
public function testIsChildOfWithDnObjects()
{
$dn1 = Ldap\Dn::fromString('cb=name1,cn=name2,dc=example,dc=org');
$dn2 = Ldap\Dn::fromString('dc=example,dc=org');
$this->assertTrue(Ldap\Dn::isChildOf($dn1, $dn2));
}
示例8: getSchemaDn
/**
* Returns the schema DN
*
* @return \Zend\Ldap\Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSubschemaSubentry();
return Ldap\Dn::fromString($schemaDn);
}
示例9: testLoadFromLDAPWithDnObject
public function testLoadFromLDAPWithDnObject()
{
$dn = Ldap\Dn::fromString($this->_createDn('ou=Test1,'));
$node = Node::fromLDAP($dn, $this->_getLDAP());
$this->assertInstanceOf('Zend\\Ldap\\Node', $node);
$this->assertTrue($node->isAttached());
}
示例10: testDnObjectCloning
public function testDnObjectCloning()
{
$node1 = $this->createTestNode();
$dn1 = Ldap\Dn::fromString('cn=name2,dc=example,dc=org');
$node1->setDn($dn1);
$dn1->prepend(array('cn' => 'name'));
$this->assertNotEquals($dn1->toString(), $node1->getDn()->toString());
$dn2 = Ldap\Dn::fromString('cn=name2,dc=example,dc=org');
$node2 = Ldap\Node::create($dn2);
$dn2->prepend(array('cn' => 'name'));
$this->assertNotEquals($dn2->toString(), $node2->getDn()->toString());
$dn3 = Ldap\Dn::fromString('cn=name2,dc=example,dc=org');
$node3 = Ldap\Node::fromArray(array('dn' => $dn3, 'ou' => 'Test'), false);
$dn3->prepend(array('cn' => 'name'));
$this->assertNotEquals($dn3->toString(), $node3->getDn()->toString());
}
示例11: testRecursiveCopyWithDnObjects
public function testRecursiveCopyWithDnObjects()
{
$orgSubTreeDn = Ldap\Dn::fromString($this->_orgSubTreeDn);
$newSubTreeDn = Ldap\Dn::fromString($this->_newSubTreeDn);
$this->_getLDAP()->copy($orgSubTreeDn, $newSubTreeDn, true);
$this->assertTrue($this->_getLDAP()->exists($orgSubTreeDn));
$this->assertTrue($this->_getLDAP()->exists($newSubTreeDn));
$this->assertEquals(3, $this->_getLDAP()->countChildren($orgSubTreeDn));
$this->assertEquals(3, $this->_getLDAP()->countChildren('ou=Subtree1,' . $orgSubTreeDn->toString()));
$this->assertEquals(3, $this->_getLDAP()->countChildren($newSubTreeDn));
$this->assertEquals(3, $this->_getLDAP()->countChildren('ou=Subtree1,' . $newSubTreeDn->toString()));
}
示例12: testGetSingleEntryWithDnObject
public function testGetSingleEntryWithDnObject()
{
$dn = Ldap\Dn::fromString($this->_createDn('ou=Test1,'));
$entry = $this->_getLDAP()->getEntry($dn);
$this->assertEquals($dn->toString(), $entry["dn"]);
}