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


PHP ldap_mod_add函数代码示例

本文整理汇总了PHP中ldap_mod_add函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_mod_add函数的具体用法?PHP ldap_mod_add怎么用?PHP ldap_mod_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: update

 /**
  * Update the entry on the directory server
  *
  * This will evaluate all changes made so far and send them
  * to the directory server.
  * Please note, that if you make changes to objectclasses wich
  * have mandatory attributes set, update() will currently fail.
  * Remove the entry from the server and readd it as new in such cases.
  * This also will deal with problems with setting structural object classes.
  *
  * @param Net_LDAP2 $ldap If passed, a call to setLDAP() is issued prior update, thus switching the LDAP-server. This is for perl-ldap interface compliance
  *
  * @access public
  * @return true|Net_LDAP2_Error
  * @todo Entry rename with a DN containing special characters needs testing!
  */
 public function update($ldap = null)
 {
     if ($ldap) {
         $msg = $this->setLDAP($ldap);
         if (Net_LDAP2::isError($msg)) {
             return PEAR::raiseError('You passed an invalid $ldap variable to update()');
         }
     }
     // ensure we have a valid LDAP object
     $ldap =& $this->getLDAP();
     if (!$ldap instanceof Net_LDAP2) {
         return PEAR::raiseError("The entries LDAP object is not valid");
     }
     // Get and check link
     $link = $ldap->getLink();
     if (!is_resource($link)) {
         return PEAR::raiseError("Could not update entry: internal LDAP link is invalid");
     }
     /*
      * Delete the entry
      */
     if (true === $this->_delete) {
         return $ldap->delete($this);
     }
     /*
      * New entry
      */
     if (true === $this->_new) {
         $msg = $ldap->add($this);
         if (Net_LDAP2::isError($msg)) {
             return $msg;
         }
         $this->_new = false;
         $this->_changes['add'] = array();
         $this->_changes['delete'] = array();
         $this->_changes['replace'] = array();
         $this->_original = $this->_attributes;
         $return = true;
         return $return;
     }
     /*
      * Rename/move entry
      */
     if (false == is_null($this->_newdn)) {
         if ($ldap->getLDAPVersion() !== 3) {
             return PEAR::raiseError("Renaming/Moving an entry is only supported in LDAPv3");
         }
         // make dn relative to parent (needed for ldap rename)
         $parent = Net_LDAP2_Util::ldap_explode_dn($this->_newdn, array('casefolding' => 'none', 'reverse' => false, 'onlyvalues' => false));
         if (Net_LDAP2::isError($parent)) {
             return $parent;
         }
         $child = array_shift($parent);
         // maybe the dn consist of a multivalued RDN, we must build the dn in this case
         // because the $child-RDN is an array!
         if (is_array($child)) {
             $child = Net_LDAP2_Util::canonical_dn($child);
         }
         $parent = Net_LDAP2_Util::canonical_dn($parent);
         // rename/move
         if (false == @ldap_rename($link, $this->_dn, $child, $parent, true)) {
             return PEAR::raiseError("Entry not renamed: " . @ldap_error($link), @ldap_errno($link));
         }
         // reflect changes to local copy
         $this->_dn = $this->_newdn;
         $this->_newdn = null;
     }
     /*
      * Carry out modifications to the entry
      */
     // ADD
     foreach ($this->_changes["add"] as $attr => $value) {
         // if attribute exists, add new values
         if ($this->exists($attr)) {
             if (false === @ldap_mod_add($link, $this->dn(), array($attr => $value))) {
                 return PEAR::raiseError("Could not add new values to attribute {$attr}: " . @ldap_error($link), @ldap_errno($link));
             }
         } else {
             // new attribute
             if (false === @ldap_modify($link, $this->dn(), array($attr => $value))) {
                 return PEAR::raiseError("Could not add new attribute {$attr}: " . @ldap_error($link), @ldap_errno($link));
             }
         }
         // all went well here, I guess
//.........这里部分代码省略.........
开发者ID:microcosmx,项目名称:experiments,代码行数:101,代码来源:Entry.php

示例2: add_login

 public function add_login($ad, $grupo, $user, $bdn, $ous)
 {
     try {
         $ous = "CN=" . $grupo . "," . $ous;
         if (self::login($ad, "rsanchez@aicollection.local", "Ac9a7533#Ed")) {
             ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
             ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
             $results = ldap_search($ad, $bdn, "(sAMAccountName={$user})", array("sn", "cn"), 0, 1);
             $entry = ldap_get_entries($ad, $results);
             $first = ldap_first_entry($ad, $results);
             $dn = ldap_get_dn($ad, $first);
             $data = $entry[0]['cn'][0];
             //$dn = str_replace($data, $user, $dn);
             //echo $dn;
             $user_array['member'] = $dn;
             //echo $ous;
             if (ldap_mod_add($ad, $ous, $user_array)) {
                 return 1;
             } else {
                 return 0;
             }
             //end if*/
         } else {
             return 0;
         }
         //end if
     } catch (Exception $e) {
         return 0;
     }
     //end try
 }
开发者ID:RCDResorts,项目名称:loginRCD,代码行数:31,代码来源:ldap.class.php

示例3: addAttribute

 /**
  * addAttribute
  *
  * Adds to an existing attribute without affecting existing values. Ex: adding to pdsRole without affecting existing roles.
  *
  *@param string $username
  *@param array $array
  *@return mixed
  */
 public function addAttribute($username, $array)
 {
     $immid = $this->getPortalAttribute('uid', $username);
     $immid = $immid[0];
     // array need to be keyed appropriately
     return ldap_mod_add($this->_portal_ds, "uid={$immid}, " . $this->_ldap['root'], $array);
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:16,代码来源:portal.class.php

示例4: updateProfile

 public static function updateProfile($numero_membre, $data)
 {
     $handle_ldap = self::initialize();
     if (self::$isDisabled) {
         self::$logger->info("Ldap is disabled, doing nothing.");
         return false;
     }
     $membreExists = @ldap_search($handle_ldap, "cn={$numero_membre}, " . self::$conf['basedn'], "objectclass=*", array("cn", "description", "mail"));
     if ($membreExists) {
         $personnes = ldap_get_entries($handle_ldap, $membreExists);
         $personne = $personnes[0];
         $dn = $personne["dn"];
         //self::$logger->debug(print_r($personne, true));
         $newEmail = self::$conf['defaultEmail'];
         if (isset($data['email']) && $data['email']) {
             $newEmail = $data['email'];
         }
         $hasLdapEmail = @is_array($personne["mail"]);
         $ldapData = ['mail' => [$newEmail]];
         if ($hasLdapEmail) {
             self::$logger->info("Replacing ldap email for #{$numero_membre}: {$newEmail}");
             ldap_mod_replace($handle_ldap, $dn, $ldapData);
         } else {
             self::$logger->info("Adding ldap email for #{$numero_membre}: {$newEmail}");
             ldap_mod_add($handle_ldap, $dn, $ldapData);
         }
         $err = ldap_error($handle_ldap);
         if ($err != "Success") {
             return $err;
         }
     } else {
         return "Membre not found in ldap repo: #{$numero_membre}";
     }
 }
开发者ID:RomainBenetiere,项目名称:mon-compte,代码行数:34,代码来源:LdapSync.php

示例5: addUser

 public function addUser($dn)
 {
     $entry = array();
     $entry['member'] = $dn;
     if (ldap_mod_add($this->ldapconn, $this->dn, $entry) === false) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:tmaex,项目名称:useradmin,代码行数:10,代码来源:group.inc.php

示例6: addUserToGroup

function addUserToGroup($username, $group)
{
    $search = ldap_search($connection, $DN, "(uid=" . $username . ")");
    $ent = ldap_get_entries($connection, $search);
    if ($ent["count"] == 0) {
        return false;
    }
    $user_dn = $ent[0]['dn'];
    $member["member"] = $user_dn;
    return ldap_mod_add($connection, $group, $member);
}
开发者ID:audunel,项目名称:anthropos,代码行数:11,代码来源:user.functions.inc.php

示例7: capture_mail

 function capture_mail($email)
 {
     global $ldap, $dn, $LDAPDATAFIELD;
     $data_new[$LDAPDATAFIELD][] = $email;
     if (ldap_mod_add($ldap, $dn, $data_new)) {
         print "<p class=\"message\">Your Email: {$email} , was successfuly  stored, Thank you! <br>";
         return true;
     } else {
         print "<p class=\"message\">Error setting your data, please try again later";
         return false;
     }
 }
开发者ID:roopesh007,项目名称:adipart,代码行数:12,代码来源:passreset.php

示例8: add2OtherGroup

function add2OtherGroup($ds, $info, $infoGroupes)
{
    $erreur = false;
    for ($i = 1; $i < $infoGroupes['count']; $i++) {
        if (!empty($_POST[$infoGroupes[$i]['cn'][0]])) {
            $r = ldap_mod_add($ds, "cn=" . $infoGroupes[$i]['cn'][0] . ",ou=groups,dc=rBOX,dc=lan", $info);
            if (!$r) {
                if ($erreur) {
                    $grp .= ', ' . $infoGroupes[$i]['cn'][0];
                } else {
                    $erreur = true;
                    $grp = $infoGroupes[$i]['cn'][0];
                }
            }
        }
    }
    // On affiche un message d'erreur si l'utilisateur n'a pas pu être ajouté a un groupe
    if ($erreur) {
        echo '<p class="center red">L\'utilisateur n\'a pas pu être ajouté au(x) groupe(s) ' . $grp . '. Un message sera envoyé à l\'administrateur.</p>';
        return false;
    }
    return true;
}
开发者ID:hillfias,项目名称:LDAPWebApp,代码行数:23,代码来源:addUser.php

示例9: addAttribute

 /**
  * 	Add a LDAP attribute in entry
  *	Ldap object connect and bind must have been done
  *
  *	@param	string		$dn			DN entry key
  *	@param	array		$info		Attributes array
  *	@param	User		$user		Objet user that create
  *	@return	int						<0 if KO, >0 if OK
  */
 function addAttribute($dn, $info, $user)
 {
     global $conf;
     dol_syslog(get_class($this) . "::addAttribute dn=" . $dn . " info=" . join(',', $info));
     // Check parameters
     if (!$this->connection) {
         $this->error = "NotConnected";
         return -2;
     }
     if (!$this->bind) {
         $this->error = "NotConnected";
         return -3;
     }
     // Encode to LDAP page code
     $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
     foreach ($info as $key => $val) {
         if (!is_array($val)) {
             $info[$key] = $this->convFromOutputCharset($val, $this->ldapcharset);
         }
     }
     $this->dump($dn, $info);
     //print_r($info);
     $result = @ldap_mod_add($this->connection, $dn, $info);
     if ($result) {
         dol_syslog(get_class($this) . "::add_attribute successfull", LOG_DEBUG);
         return 1;
     } else {
         $this->error = @ldap_error($this->connection);
         dol_syslog(get_class($this) . "::add_attribute failed: " . $this->error, LOG_ERR);
         return -1;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:41,代码来源:ldap.class.php

示例10: addContact

 /**
  * Add a contact to a group
  * 
  * @param string $group The group to add the contact to
  * @param string $contactDn The DN of the contact to add
  * @return bool
  */
 public function addContact($group, $contactDn)
 {
     // To add a contact we take the contact's DN
     // and add it using the full DN of the group
     // Find the group's dn
     $groupInfo = $this->info($group, array("cn"));
     if ($groupInfo[0]["dn"] === NULL) {
         return false;
     }
     $groupDn = $groupInfo[0]["dn"];
     $add = array();
     $add["member"] = $contactDn;
     $result = @ldap_mod_add($this->adldap->getLdapConnection(), $groupDn, $add);
     if ($result == false) {
         return false;
     }
     return true;
 }
开发者ID:UCCNetworkingSociety,项目名称:NetsocAdmin,代码行数:25,代码来源:adLDAPGroups.php

示例11: update

 /**
  * Update a specific contact record
  *
  * @param mixed Record identifier
  * @param array Hash array with save data
  * @return boolean True on success, False on error
  */
 function update($id, $save_cols)
 {
     $record = $this->get_record($id, true);
     $result = $this->get_result();
     $record = $result->first();
     $newdata = array();
     $replacedata = array();
     $deletedata = array();
     foreach ($save_cols as $col => $val) {
         $fld = $this->_map_field($col);
         if ($fld) {
             // The field does exist compare it to the ldap record.
             if ($record[$col] != $val) {
                 // Changed, but find out how.
                 if (!isset($record[$col])) {
                     // Field was not set prior, need to add it.
                     $newdata[$fld] = $val;
                 } elseif ($val == '') {
                     // Field supplied is empty, verify that it is not required.
                     if (!in_array($fld, $this->prop['required_fields'])) {
                         // It is not, safe to clear.
                         $deletedata[$fld] = $record[$col];
                     }
                     // end if
                 } else {
                     // The data was modified, save it out.
                     $replacedata[$fld] = $val;
                 }
                 // end else
             }
             // end if
         }
         // end if
     }
     // end foreach
     $dn = base64_decode($id);
     // Update the entry as required.
     if (!empty($deletedata)) {
         // Delete the fields.
         $this->_debug("C: Delete [dn: {$dn}]: " . print_r($deletedata, true));
         if (!ldap_mod_del($this->conn, $dn, $deletedata)) {
             $this->_debug("S: " . ldap_error($this->conn));
             return false;
         }
         $this->_debug("S: OK");
     }
     // end if
     if (!empty($replacedata)) {
         // Handle RDN change
         if ($replacedata[$this->prop['LDAP_rdn']]) {
             $newdn = $this->prop['LDAP_rdn'] . '=' . rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true) . ',' . $this->prop['base_dn'];
             if ($dn != $newdn) {
                 $newrdn = $this->prop['LDAP_rdn'] . '=' . rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true);
                 unset($replacedata[$this->prop['LDAP_rdn']]);
             }
         }
         // Replace the fields.
         if (!empty($replacedata)) {
             $this->_debug("C: Replace [dn: {$dn}]: " . print_r($replacedata, true));
             if (!ldap_mod_replace($this->conn, $dn, $replacedata)) {
                 $this->_debug("S: " . ldap_error($this->conn));
                 return false;
             }
             $this->_debug("S: OK");
         }
         // end if
     }
     // end if
     if (!empty($newdata)) {
         // Add the fields.
         $this->_debug("C: Add [dn: {$dn}]: " . print_r($newdata, true));
         if (!ldap_mod_add($this->conn, $dn, $newdata)) {
             $this->_debug("S: " . ldap_error($this->conn));
             return false;
         }
         $this->_debug("S: OK");
     }
     // end if
     // Handle RDN change
     if (!empty($newrdn)) {
         $this->_debug("C: Rename [dn: {$dn}] [dn: {$newrdn}]");
         if (@ldap_rename($this->conn, $dn, $newrdn, NULL, TRUE)) {
             $this->_debug("S: " . ldap_error($this->conn));
             return base64_encode($newdn);
         }
         $this->_debug("S: OK");
     }
     return true;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:96,代码来源:rcube_ldap.php

示例12: add

 /**
  * Adds attributes to that entry.
  * 
  * @param array $attribs The new attributes.
  * @return boolean Returns true on success and false on failure.
  */
 public function add($attribs)
 {
     return ldap_mod_add($this->conn, $this->dn, $attribs);
 }
开发者ID:gossi,项目名称:ldap,代码行数:10,代码来源:LdapEntry.php

示例13: add

 /**
  * Add an attribute to the given DN
  * Note: DN has to exist already
  *
  * @param   string  $dn     The DN of the entry to add the attribute
  * @param   array   $entry  An array of arrays with attributes to add
  *
  * @return  boolean   Result of operation
  *
  * @since   12.1
  */
 public function add($dn, array $entry)
 {
     return @ldap_mod_add($this->_resource, $dn, $entry);
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:15,代码来源:ldap.php

示例14: addValuesToEnd

 function addValuesToEnd($dn, $Attributes)
 {
     @ldap_mod_add($this->LC, $dn, $Attributes);
     //$LS=ldap_search($this->LC, $dn, "name=*", array_unique(array_keys($Attributes)));
     //$Entries=ldap_get_entries($this->LC, $LS);
 }
开发者ID:kotkotofey,项目名称:eight,代码行数:6,代码来源:forms.php

示例15: modAdd

 /**
  * Add attribute values to current attributes.
  *
  * @param string $dn
  * @param array  $entry
  *
  * @return bool
  */
 public function modAdd($dn, array $entry)
 {
     if ($this->suppressErrors) {
         return @ldap_mod_add($this->getConnection(), $dn, $entry);
     }
     return ldap_mod_add($this->getConnection(), $dn, $entry);
 }
开发者ID:HarkiratGhotra,项目名称:application,代码行数:15,代码来源:Ldap.php


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