本文整理汇总了PHP中Zend_Ldap_Dn::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Ldap_Dn::fromString方法的具体用法?PHP Zend_Ldap_Dn::fromString怎么用?PHP Zend_Ldap_Dn::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Ldap_Dn
的用法示例。
在下文中一共展示了Zend_Ldap_Dn::fromString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRecursiveCopyWithDnObjects
public function testRecursiveCopyWithDnObjects()
{
$orgSubTreeDn = Zend_Ldap_Dn::fromString($this->_orgSubTreeDn);
$newSubTreeDn = Zend_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()));
}
示例2: testLoadFromLdapWithDnObject
public function testLoadFromLdapWithDnObject()
{
$dn = Zend_Ldap_Dn::fromString($this->_createDn('ou=Test1,'));
$node = Zend_Ldap_Node::fromLdap($dn, $this->_getLdap());
$this->assertType('Zend_Ldap_Node', $node);
$this->assertTrue($node->isAttached());
}
示例3: testArrayAccessImplementation
public function testArrayAccessImplementation()
{
$dnString = 'cn=Baker\\, Alice,cn=Users,dc=example,dc=com';
$dn = Zend_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 = Zend_Ldap_Dn::fromString($dnString);
unset($dn[0]);
$this->assertEquals('cn=Users,dc=example,dc=com', $dn->toString());
$dn = Zend_Ldap_Dn::fromString($dnString);
unset($dn[1]);
$this->assertEquals('cn=Baker\\, Alice,dc=example,dc=com', $dn->toString());
$dn = Zend_Ldap_Dn::fromString($dnString);
unset($dn[2]);
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=com', $dn->toString());
$dn = Zend_Ldap_Dn::fromString($dnString);
unset($dn[3]);
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=example', $dn->toString());
$dn = Zend_Ldap_Dn::fromString($dnString);
$dn[0] = array('uid' => 'abaker');
$this->assertEquals('uid=abaker,cn=Users,dc=example,dc=com', $dn->toString());
$dn = Zend_Ldap_Dn::fromString($dnString);
$dn[1] = array('ou' => 'Lab');
$this->assertEquals('cn=Baker\\, Alice,ou=Lab,dc=example,dc=com', $dn->toString());
$dn = Zend_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 = Zend_Ldap_Dn::fromString($dnString);
$dn[3] = array('dc' => 'de+fr');
$this->assertEquals('cn=Baker\\, Alice,cn=Users,dc=example,dc=de\\+fr', $dn->toString());
}
示例4: getSchemaDn
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSchemaNamingContext();
/**
* @see Zend_Ldap_Dn
*/
require_once 'Zend/Ldap/Dn.php';
return Zend_Ldap_Dn::fromString($schemaDn);
}
示例5: 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(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
$rdn = Zend_Ldap_Dn::implodeRdn($n->getRdnArray(), Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
if ($i == 0) {
$this->assertEquals(Zend_Ldap_Dn::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE)->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER), $dn);
} else {
if ($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 = Zend_Ldap_Dn::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE)->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
}
$this->assertEquals('ou=Test' . $j, $rdn);
$this->assertEquals('ou=Test' . $j . ',' . $base, $dn);
}
}
$i++;
}
$this->assertEquals(9, $i);
}
示例6: getSchemaDn
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSubschemaSubentry();
/**
* @see Zend_Ldap_Dn
*/
// require_once 'Zend/Ldap/Dn.php';
return Zend_Ldap_Dn::fromString($schemaDn);
}
示例7: testDnObjectCloning
public function testDnObjectCloning()
{
$node1 = $this->_createTestNode();
$dn1 = Zend_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 = Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org');
$node2 = Zend_Ldap_Node::create($dn2);
$dn2->prepend(array('cn' => 'name'));
$this->assertNotEquals($dn2->toString(), $node2->getDn()->toString());
$dn3 = Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org');
$node3 = Zend_Ldap_Node::fromArray(array('dn' => $dn3, 'ou' => 'Test'), false);
$dn3->prepend(array('cn' => 'name'));
$this->assertNotEquals($dn3->toString(), $node3->getDn()->toString());
}
示例8: testIsChildOfWithDnObjects
public function testIsChildOfWithDnObjects()
{
$dn1 = Zend_Ldap_Dn::fromString('cb=name1,cn=name2,dc=example,dc=org');
$dn2 = Zend_Ldap_Dn::fromString('dc=example,dc=org');
$this->assertTrue(Zend_Ldap_Dn::isChildOf($dn1, $dn2));
}
示例9: _createDn
protected function _createDn($dn)
{
if (substr($dn, -1) !== ',') {
$dn .= ',';
}
$dn = $dn . TESTS_ZEND_LDAP_WRITEABLE_SUBTREE;
return Zend_Ldap_Dn::fromString($dn)->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
}
示例10: testEmptyStringDn
public function testEmptyStringDn()
{
$dnString = '';
$dn = Zend_Ldap_Dn::fromString($dnString);
$this->assertEquals($dnString, $dn->toString());
}
示例11: testGetSingleEntryWithDnObject
public function testGetSingleEntryWithDnObject()
{
$dn = Zend_Ldap_Dn::fromString($this->_createDn('ou=Test1,'));
$entry = $this->_getLdap()->getEntry($dn);
$this->assertEquals($dn->toString(), $entry["dn"]);
}
示例12: testSaveWithDnObject
public function testSaveWithDnObject()
{
$dn = Zend_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 (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}
}
示例13: _deletePropertyFromLdapRawData
/**
* (non-PHPdoc)
*/
protected function _deletePropertyFromLdapRawData($property, $value)
{
$ldapProperty = $this->_propertyMapping[$property];
if (substr($ldapProperty, -8) == ':boolean') {
$ldapProperty = substr($ldapProperty, 0, -8);
}
$managedPath = Zend_Ldap_Dn::fromString($this->_simpleMailConfig['storage_base'], Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
foreach ($this->_ldapRawData as $index => $dn) {
// change only entries in storage_base path (if existing)
if (isset($dn['simplemail_readonly']) || !isset($dn[$ldapProperty])) {
continue;
}
if ($value === false) {
//unset doesn't remove attribute in ldap
$this->_ldapRawData[$index][$ldapProperty] = null;
} elseif (in_array($value, $this->_ldapRawData[$index][$ldapProperty])) {
$del_index = array_search($value, $this->_ldapRawData[$index][$ldapProperty]);
unset($this->_ldapRawData[$index][$ldapProperty][$del_index]);
// don't keep empty arrays
if (count($this->_ldapRawData[$index][$ldapProperty]) < 1) {
unset($this->_ldapRawData[$index][$ldapProperty]);
}
}
}
}
示例14: getSchemaDn
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSchemaNamingContext();
/**
* @see Zend_Ldap_Dn
*/
return Zend_Ldap_Dn::fromString($schemaDn);
}