当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_LDAP2::add方法代码示例

本文整理汇总了PHP中Net_LDAP2::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_LDAP2::add方法的具体用法?PHP Net_LDAP2::add怎么用?PHP Net_LDAP2::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_LDAP2的用法示例。


在下文中一共展示了Net_LDAP2::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: move

 /**
  * Rename or move an entry
  *
  * This method will instantly carry out an update() after the move,
  * so the entry is moved instantly.
  * You can pass an optional Net_LDAP2 object. In this case, a cross directory
  * move will be performed which deletes the entry in the source (THIS) directory
  * and adds it in the directory $target_ldap.
  * A cross directory move will switch the Entrys internal LDAP reference so
  * updates to the entry will go to the new directory.
  *
  * Note that if you want to do a cross directory move, you need to
  * pass an Net_LDAP2_Entry object, otherwise the attributes will be empty.
  *
  * @param string|Net_LDAP2_Entry $entry       Entry DN or Entry object
  * @param string                 $newdn       New location
  * @param Net_LDAP2              $target_ldap (optional) Target directory for cross server move; should be passed via reference
  *
  * @return Net_LDAP2_Error|true
  */
 public function move($entry, $newdn, $target_ldap = null)
 {
     if (is_string($entry)) {
         $entry_o = $this->getEntry($entry);
     } else {
         $entry_o =& $entry;
     }
     if (!$entry_o instanceof Net_LDAP2_Entry) {
         return PEAR::raiseError('Parameter $entry is expected to be a Net_LDAP2_Entry object! (If DN was passed, conversion failed)');
     }
     if (null !== $target_ldap && !$target_ldap instanceof Net_LDAP2) {
         return PEAR::raiseError('Parameter $target_ldap is expected to be a Net_LDAP2 object!');
     }
     if ($target_ldap && $target_ldap !== $this) {
         // cross directory move
         if (is_string($entry)) {
             return PEAR::raiseError('Unable to perform cross directory move: operation requires a Net_LDAP2_Entry object');
         }
         if ($target_ldap->dnExists($newdn)) {
             return PEAR::raiseError('Unable to perform cross directory move: entry does exist in target directory');
         }
         $entry_o->dn($newdn);
         $res = $target_ldap->add($entry_o);
         if (self::isError($res)) {
             return PEAR::raiseError('Unable to perform cross directory move: ' . $res->getMessage() . ' in target directory');
         }
         $res = $this->delete($entry_o->currentDN());
         if (self::isError($res)) {
             $res2 = $target_ldap->delete($entry_o);
             // undo add
             if (self::isError($res2)) {
                 $add_error_string = 'Additionally, the deletion (undo add) of $entry in target directory failed.';
             }
             return PEAR::raiseError('Unable to perform cross directory move: ' . $res->getMessage() . ' in source directory. ' . $add_error_string);
         }
         $entry_o->setLDAP($target_ldap);
         return true;
     } else {
         // local move
         $entry_o->dn($newdn);
         $entry_o->setLDAP($this);
         return $entry_o->update();
     }
 }
开发者ID:yozhi,项目名称:YetiForceCRM,代码行数:64,代码来源:LDAP2.php


注:本文中的Net_LDAP2::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。