當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。