本文整理汇总了PHP中ldap_mod_add函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_mod_add函数的具体用法?PHP ldap_mod_add怎么用?PHP ldap_mod_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ldap_mod_add函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, "[email protected]", "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
示例16: print_r
$modfi = 0;
}
# dann löschen
if ($delfi == 1) {
echo "Löschen: ";
print_r($filedel);
echo "<br>";
if (ldap_mod_del($ds, $pxeDN, $filedel)) {
$mesg = "PXE Dateiname(n) erfolgreich gelöscht<br><br>";
} else {
$mesg = "Fehler beim löschen des PXE Dateinamens !<br><br>";
}
$delfi = 0;
}
}
# PXE Dateiname neu anlegen
if ($newfilename == "") {
}
if ($newfilename != "") {
echo "PXE Dateiname hinzufügen";
$fileadd['filename'] = $newfilename;
if (ldap_mod_add($ds, $pxeDN, $fileadd)) {
$mesg = "PXE Dateiname <b>" . $newfilename . "</b> erfolgreich angelegt<br><br>";
} else {
$mesg = "Fehler beim anlegen des PXE Dateinamens " . $newfilename . " !<br><br>";
}
}
#########################
$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br>\t\t\t\t\n\t\t\tFalls nicht, klicken Sie hier <a href=" . $url . " style='publink'>back</a>";
redirect($seconds, $url, $mesg, $addSessionId = TRUE);
echo "</td></tr></table></body>\n</html>";
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:31,代码来源:pxe_change.php
示例17: ldap_mod_del
$add_r[$attrmap["{$key}"]][] = $val;
}
}
}
}
if (isset($del)) {
if ($config[ldap_debug] == 'true') {
print "<b>DEBUG(LDAP): ldap_mod_del(): DN='{$dn}'</b><br>\n";
print "<b>DEBUG(LDAP): ldap_mod_del(): Data:";
print_r($del);
print "</b><br>\n";
}
@ldap_mod_del($ds, $dn, $del);
}
if (isset($add_r)) {
if ($config[ldap_debug] == 'true') {
print "<b>DEBUG(LDAP): ldap_mod_add(): DN='{$dn}'</b><br>\n";
print "<b>DEBUG(LDAP): ldap_mod_add(): Data:";
print_r($add_r);
print "</b><br>\n";
}
@ldap_mod_add($ds, $dn, $add_r);
}
}
if (@ldap_error($ds) == 'Success') {
echo "<b>The changes were successfully commited to the directory</b><br>\n";
} else {
echo "<b>LDAP ERROR: " . ldap_error($ds) . "</b><br>\n";
}
@ldap_close($ds);
}
开发者ID:greendev5,项目名称:freeradius-server-wasel,代码行数:31,代码来源:change_attrs.php
示例18: addMemberToGroup
function addMemberToGroup($object_name, $uid)
{
$group_cn = "cn=" . $object_name . "," . $this->getLdapGroupDn();
$members = $this->getLdapUserDn($uid);
$group_info['member'] = $members;
@ldap_mod_add($this->ldapResource, $group_cn, $group_info);
if (@ldap_error($this->ldapResource) == "Success") {
return true;
} else {
return false;
}
}
开发者ID:blestab,项目名称:frontaccounting,代码行数:12,代码来源:Ldap.php
示例19: group_add_user
function group_add_user($group, $user)
{
//adding a user is a bit fiddly, we need to get the full DN of the user
//and add it using the full DN of the group
//find the user's dn
$user_info = $this->user_info($user, array("cn"));
if ($user_info[0]["dn"] == NULL) {
return false;
}
$user_dn = $user_info[0]["dn"];
//find the group's dn
$group_info = $this->group_info($group, array("cn"));
if ($group_info[0]["dn"] == NULL) {
return false;
}
$group_dn = $group_info[0]["dn"];
$add = array();
$add["member"] = $user_dn;
$result = @ldap_mod_add($this->_conn, $group_dn, $add);
if ($result == false) {
return false;
}
return true;
}
开发者ID:jcorbinredtree,项目名称:framework,代码行数:24,代码来源:ActiveDirectory.php
示例20: simpleQuery
/**
* Performs a request against the LDAP server
*
* The type of request (and the corresponding PHP ldap function called)
* depend on two additional parameters, added in respect to the
* DB_common interface.
*
* @param string $filter text of the request to send to the LDAP server
* @param string $action type of request to perform, defaults to search (ldap_search())
* @param array $params array of additional parameters to pass to the PHP ldap function requested
* @return result from ldap function or DB Error object if no result
*/
function simpleQuery($filter, $action = null, $params = null)
{
if ($action === null) {
$action = !empty($this->q_action) ? $this->q_action : $this->action;
}
if ($params === null) {
$params = count($this->q_params) > 0 ? $this->q_params : array();
}
if (!$this->isManip($action)) {
$base = $this->q_base ? $this->q_base : $this->base;
$attributes = array();
$attrsonly = 0;
$sizelimit = 0;
$timelimit = 0;
$deref = LDAP_DEREF_NEVER;
$sorting = '';
$sorting_method = '';
reset($params);
while (list($k, $v) = each($params)) {
if (isset(${$k})) {
${$k} = $v;
}
}
$this->sorting = $sorting;
$this->sorting_method = $sorting_method;
$this->attributes = $attributes;
# double escape char for filter: '(o=Przedsi\C4\99biorstwo)' => '(o=Przedsi\\C4\\99biorstwo)'
$filter = str_replace('\\', '\\\\', $filter);
$this->last_query = $filter;
if ($action == 'search') {
$result = @ldap_search($this->connection, $base, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
} else {
if ($action == 'list') {
$result = @ldap_list($this->connection, $base, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
} else {
if ($action == 'read') {
$result = @ldap_read($this->connection, $base, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
} else {
return $this->ldapRaiseError(DB_ERROR_UNKNOWN_LDAP_ACTION);
}
}
}
if (!$result) {
return $this->ldapRaiseError();
}
} else {
# If first argument is an array, it contains the entry with DN.
if (is_array($filter)) {
$entry = $filter;
$filter = $entry["dn"];
} else {
$entry = array();
}
unset($entry["dn"]);
$attribute = '';
$value = '';
$newrdn = '';
$newparent = '';
$deleteoldrdn = false;
reset($params);
while (list($k, $v) = each($params)) {
if (isset(${$k})) {
${$k} = $v;
}
}
$this->last_query = $filter;
if ($action == 'add') {
$result = @ldap_add($this->connection, $filter, $entry);
} else {
if ($action == 'compare') {
$result = @ldap_add($this->connection, $filter, $attribute, $value);
} else {
if ($action == 'delete') {
$result = @ldap_delete($this->connection, $filter);
} else {
if ($action == 'modify') {
$result = @ldap_modify($this->connection, $filter, $entry);
} else {
if ($action == 'mod_add') {
$result = @ldap_mod_add($this->connection, $filter, $entry);
} else {
if ($action == 'mod_del') {
$result = @ldap_mod_del($this->connection, $filter, $entry);
} else {
if ($action == 'mod_replace') {
$result = @ldap_mod_replace($this->connection, $filter, $entry);
} else {
if ($action == 'rename') {
//.........这里部分代码省略.........
开发者ID:altesien,项目名称:FinalProject,代码行数:101,代码来源:ldap.php
注:本文中的ldap_mod_add函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论