本文整理汇总了PHP中Zend_Ldap_Dn::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Ldap_Dn::fromArray方法的具体用法?PHP Zend_Ldap_Dn::fromArray怎么用?PHP Zend_Ldap_Dn::fromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Ldap_Dn
的用法示例。
在下文中一共展示了Zend_Ldap_Dn::fromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDnCreation
public function testDnCreation()
{
Zend_Ldap_Dn::setDefaultCaseFold(Zend_Ldap_Dn::ATTR_CASEFOLD_NONE);
$dnString1 = 'CN=Baker\\, Alice,CN=Users+OU=Lab,DC=example,DC=com';
$dnArray1 = array(array('CN' => 'Baker, Alice'), array('CN' => 'Users', 'OU' => 'Lab'), array('DC' => 'example'), array('DC' => 'com'));
$dnString2 = 'cn=Baker\\, Alice,cn=Users+ou=Lab,dc=example,dc=com';
$dnArray2 = array(array('cn' => 'Baker, Alice'), array('cn' => 'Users', 'ou' => 'Lab'), array('dc' => 'example'), array('dc' => 'com'));
$dnString3 = 'Cn=Baker\\, Alice,Cn=Users+Ou=Lab,Dc=example,Dc=com';
$dnArray3 = array(array('Cn' => 'Baker, Alice'), array('Cn' => 'Users', 'Ou' => 'Lab'), array('Dc' => 'example'), array('Dc' => 'com'));
$dn11 = Zend_Ldap_Dn::fromString($dnString1);
$dn12 = Zend_Ldap_Dn::fromArray($dnArray1);
$dn13 = Zend_Ldap_Dn::factory($dnString1);
$dn14 = Zend_Ldap_Dn::factory($dnArray1);
$this->assertEquals($dn11, $dn12);
$this->assertEquals($dn11, $dn13);
$this->assertEquals($dn11, $dn14);
$this->assertEquals($dnString1, $dn11->toString());
$this->assertEquals($dnString1, $dn11->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER));
$this->assertEquals($dnString2, $dn11->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER));
$this->assertEquals($dnArray1, $dn11->toArray());
$this->assertEquals($dnArray1, $dn11->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER));
$this->assertEquals($dnArray2, $dn11->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER));
$dn21 = Zend_Ldap_Dn::fromString($dnString2);
$dn22 = Zend_Ldap_Dn::fromArray($dnArray2);
$dn23 = Zend_Ldap_Dn::factory($dnString2);
$dn24 = Zend_Ldap_Dn::factory($dnArray2);
$this->assertEquals($dn21, $dn22);
$this->assertEquals($dn21, $dn23);
$this->assertEquals($dn21, $dn24);
$this->assertEquals($dnString2, $dn21->toString());
$this->assertEquals($dnString1, $dn21->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER));
$this->assertEquals($dnString2, $dn21->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER));
$this->assertEquals($dnArray2, $dn21->toArray());
$this->assertEquals($dnArray1, $dn21->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER));
$this->assertEquals($dnArray2, $dn21->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER));
$this->assertEquals($dnArray2, $dn22->toArray());
$dn31 = Zend_Ldap_Dn::fromString($dnString3);
$dn32 = Zend_Ldap_Dn::fromArray($dnArray3);
$dn33 = Zend_Ldap_Dn::factory($dnString3);
$dn34 = Zend_Ldap_Dn::factory($dnArray3);
$this->assertEquals($dn31, $dn32);
$this->assertEquals($dn31, $dn33);
$this->assertEquals($dn31, $dn34);
$this->assertEquals($dnString3, $dn31->toString());
$this->assertEquals($dnString1, $dn31->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER));
$this->assertEquals($dnString2, $dn31->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER));
$this->assertEquals($dnArray3, $dn31->toArray());
$this->assertEquals($dnArray1, $dn31->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_UPPER));
$this->assertEquals($dnArray2, $dn31->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER));
try {
$dn = Zend_Ldap_Dn::factory(1);
$this->fail('Expected Zend_Ldap_Exception not thrown');
} catch (Zend_Ldap_Exception $e) {
$this->assertEquals('Invalid argument type for $dn', $e->getMessage());
}
}
示例2: copyToSubtree
/**
* Copies a LDAP entry from one DN to another subtree.
*
* @param string|Zend_Ldap_Dn $from
* @param string|Zend_Ldap_Dn $to
* @param boolean $recursively
* @return Zend_Ldap Provides a fluid interface
* @throws Zend_Ldap_Exception
*/
public function copyToSubtree($from, $to, $recursively = false)
{
if ($from instanceof Zend_Ldap_Dn) {
$orgDnParts = $from->toArray();
} else {
$orgDnParts = Zend_Ldap_Dn::explodeDn($from);
}
if ($to instanceof Zend_Ldap_Dn) {
$newParentDnParts = $to->toArray();
} else {
$newParentDnParts = Zend_Ldap_Dn::explodeDn($to);
}
$newDnParts = array_merge(array(array_shift($orgDnParts)), $newParentDnParts);
$newDn = Zend_Ldap_Dn::fromArray($newDnParts);
return $this->copy($from, $newDn, $recursively);
}