本文整理汇总了PHP中Zend\Ldap\Dn::implodeRdn方法的典型用法代码示例。如果您正苦于以下问题:PHP Dn::implodeRdn方法的具体用法?PHP Dn::implodeRdn怎么用?PHP Dn::implodeRdn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Ldap\Dn
的用法示例。
在下文中一共展示了Dn::implodeRdn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
} 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 = 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: rename
/**
* Renames a LDAP entry from one DN to another DN.
*
* This method implicitly moves the entry to another location within the tree.
*
* @param string|Dn $from
* @param string|Dn $to
* @param boolean $recursively
* @param boolean $alwaysEmulate
* @return Ldap Provides a fluid interface
* @throws Exception\LdapException
*/
public function rename($from, $to, $recursively = false, $alwaysEmulate = false)
{
$emulate = (bool) $alwaysEmulate;
if (!function_exists('ldap_rename')) {
$emulate = true;
} elseif ($recursively) {
$emulate = true;
}
if ($emulate === false) {
if ($from instanceof Dn) {
$from = $from->toString();
}
if ($to instanceof Dn) {
$newDnParts = $to->toArray();
} else {
$newDnParts = Dn::explodeDn($to);
}
$newRdn = Dn::implodeRdn(array_shift($newDnParts));
$newParent = Dn::implodeDn($newDnParts);
ErrorHandler::start(E_WARNING);
$isOK = ldap_rename($this->getResource(), $from, $newRdn, $newParent, true);
ErrorHandler::stop();
if ($isOK === false) {
throw new Exception\LdapException($this, 'renaming ' . $from . ' to ' . $to);
} elseif (!$this->exists($to)) {
$emulate = true;
}
}
if ($emulate) {
$this->copy($from, $to, $recursively);
$this->delete($from, $recursively);
}
return $this;
}
示例3: testImplodeRdnInvalidThree
/**
* @expectedException Zend\Ldap\Exception
*/
public function testImplodeRdnInvalidThree()
{
$a = array('cn' => 'value', 'ou');
Ldap\Dn::implodeRdn($a);
}