コード例 #1
0
ファイル: Ldap.php プロジェクト: rexmac/zf2
 /**
  * Copies a LDAP entry from one DN to another DN.
  *
  * @param  string|\Zend\Ldap\Dn $from
  * @param  string|\Zend\Ldap\Dn $to
  * @param  boolean             $recursively
  * @return \Zend\Ldap\Ldap Provides a fluid interface
  * @throws \Zend\Ldap\Exception
  */
 public function copy($from, $to, $recursively = false)
 {
     $entry = $this->getEntry($from, array(), true);
     if ($to instanceof DN) {
         $toDnParts = $to->toArray();
     } else {
         $toDnParts = DN::explodeDn($to);
     }
     $this->add($to, $entry);
     if ($recursively === true && $this->countChildren($from) > 0) {
         $children = $this->_getChildrenDns($from);
         foreach ($children as $c) {
             $cDnParts = DN::explodeDn($c);
             $newChildParts = array_merge(array(array_shift($cDnParts)), $toDnParts);
             $newChild = DN::implodeDn($newChildParts);
             $this->copy($c, $newChild, true);
         }
     }
     return $this;
 }