本文整理汇总了PHP中ldap_mod_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_mod_replace函数的具体用法?PHP ldap_mod_replace怎么用?PHP ldap_mod_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ldap_mod_replace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addAccount
function addAccount($_hookValues)
{
$mailLocalAddress = $_hookValues['account_lid'] . "@" . $this->profileData['defaultDomain'];
$ds = $GLOBALS['phpgw']->common->ldapConnect();
$filter = "uid=" . $_hookValues['account_lid'];
$sri = @ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter);
if ($sri) {
$allValues = ldap_get_entries($ds, $sri);
$accountDN = $allValues[0]['dn'];
$objectClasses = $allValues[0]['objectclass'];
unset($objectClasses['count']);
} else {
return false;
}
if (!in_array('qmailUser', $objectClasses) && !in_array('qmailuser', $objectClasses)) {
$objectClasses[] = 'qmailuser';
}
// the new code for postfix+cyrus+ldap
$newData = array('mail' => $mailLocalAddress, 'accountStatus' => 'active', 'objectclass' => $objectClasses);
ldap_mod_replace($ds, $accountDN, $newData);
#print ldap_error($ds);
}
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:22,代码来源:class.postfixldap.inc.php
示例2: 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
示例3: change_pass
function change_pass($user, $new_pass)
{
global $config;
global $ldap_connection;
get_ldap_connection($config['user'], $config['pass']);
if ($ldap_connection) {
$filter = "(sAMAccountName={$user})";
$result = ldap_search($ldap_connection, $config['domain_dn'], $filter);
ldap_sort($ldap_connection, $result, "sn");
$info = ldap_get_entries($ldap_connection, $result);
$isLocked = $info[0]["lockoutTime"];
if ($isLocked > 0) {
return msg('account_locked');
}
$userDn = $info[0]["distinguishedname"][0];
$userdata["unicodePwd"] = iconv("UTF-8", "UTF-16LE", '"' . $new_pass . '"');
$result = ldap_mod_replace($ldap_connection, $userDn, $userdata);
if (!$result) {
return msg(ldap_error($ldap_connection));
}
} else {
return msg("wrong_admin");
}
close_ldap_connection();
return "";
}
开发者ID:Mi0Tx,项目名称:ad-change-pass,代码行数:26,代码来源:functions.php
示例4: changeAttribute
/**
* changeAttribute
*
* change an attribute
*
*@param string $username
*@param array $array
*@return mixed
*/
public function changeAttribute($username, $array)
{
// array need to be keyed appropriately
$immid = $this->getPortalAttribute('uid', $username);
$immid = $immid[0];
return ldap_mod_replace($this->_portal_ds, "uid={$immid}, " . $this->_ldap['root'], $array);
}
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:16,代码来源:portal.class.php
示例5: changeOpenLDAPPwd
private function changeOpenLDAPPwd($objLdapBinding, $strUserDN, $strNewPwd)
{
include_once "sambahash.php";
$entry["sambaNTPassword"] = nt_hash($strNewPwd);
$this->logwriter->debugwrite('NT Hash:' . $entry["sambaNTPassword"]);
$entry["sambaLMPassword"] = lm_hash($strNewPwd);
$this->logwriter->debugwrite('LM Hash:' . $entry["sambaLMPassword"]);
$date = time();
$this->logwriter->debugwrite('Last Set:' . $date);
$entry["sambaPwdLastSet"] = $date;
$entry["sambaPwdMustChange"] = $date + 90 * 24 * 60 * 60;
$this->logwriter->debugwrite('Must Change:' . $entry["sambaPwdMustChange"]);
mt_srand((double) microtime() * 1000000);
$salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($strNewPwd . $salt)) . $salt);
$entry["userPassword"] = $hash;
$entry["shadowLastChange"] = (int) ($date / 86400);
$this->logwriter->debugwrite('Shadow Last Change:' . $entry["shadowLastChange"]);
$res = ldap_mod_replace($objLdapBinding, $strUserDN, $entry) or $res = false;
if ($res) {
$this->success($strNewPwd);
return true;
} else {
//Failed to change user Password
$this->failure(8, array($strNewPwd, $newpass, ldap_error($objLdapBinding)));
return false;
}
}
开发者ID:adrenlinerush,项目名称:Roundcube-Plugin-OpenLDAP-Passwd,代码行数:28,代码来源:changeOpenLDAPPwd.class.php
示例6: ldap_update
function ldap_update($uid, $replace)
{
global $conn;
global $userDn;
try {
// Form the dn
$dn = "uid=" . $uid . "," . $userDn;
// Make the update
return ldap_mod_replace($conn, $dn, $replace);
} catch (Exception $e) {
return false;
}
}
开发者ID:brandonhudson,项目名称:WebDrink-2.0,代码行数:13,代码来源:ldap_utils.php
示例7: changePassword
function changePassword($connection, $dn, $user)
{
global $ldap_connection;
global $ldap_error;
$result = login("cn=root,dc=cupdata,dc=com", "test");
echo $result;
echo "<br>";
echo $ldap_error;
var_dump($user);
if (ldap_mod_replace($ldap_connection, $dn, $user)) {
echo "<br>success<br>";
return 0;
} else {
echo "<br>failed<br>";
return 1;
}
}
开发者ID:dannylsl,项目名称:CUPDSpace,代码行数:17,代码来源:openldap.php
示例8: _changePassword
/**
*/
protected function _changePassword($user, $oldpass, $newpass)
{
global $conf;
// Connect to the LDAP server.
$ds = ldap_connect($conf['kolab']['ldap']['server'], $conf['kolab']['ldap']['port']);
if (!$ds) {
throw new Passwd_Exception(_("Could not connect to LDAP server"));
}
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
// Bind anonymously, or use the phpdn user if available.
if (!empty($conf['kolab']['ldap']['phpdn'])) {
$phpdn = $conf['kolab']['ldap']['phpdn'];
$phppw = $conf['kolab']['ldap']['phppw'];
$result = @ldap_bind($ds, $phpdn, $phppw);
} else {
$result = @ldap_bind($ds);
}
if (!$result) {
throw new Passwd_Exception(_("Could not bind to LDAP server"));
}
// Make sure we're using the full user@domain format.
if (strstr($user, '@') === false) {
$user .= '@' . $conf['kolab']['imap']['maildomain'];
}
// Find the user's DN.
$result = ldap_search($ds, $conf['kolab']['ldap']['basedn'], 'mail=' . $user);
$entry = ldap_first_entry($ds, $result);
if ($entry === false) {
throw new Passwd_Exception(_("User not found."));
}
$userdn = ldap_get_dn($ds, $entry);
// Connect as the user.
$result = @ldap_bind($ds, $userdn, $old_password);
if (!$result) {
throw new Passwd_Exception(_("Incorrect old password."));
}
// And finally change the password.
$new_details['userPassword'] = '{sha}' . base64_encode(pack('H*', sha1($newpass)));
if (!ldap_mod_replace($ds, $userdn, $new_details)) {
throw new Passwd_Exception(ldap_error($ds));
}
ldap_unbind($ds);
}
开发者ID:jubinpatel,项目名称:horde,代码行数:45,代码来源:Kolab.php
示例9: change_pass
function change_pass($username)
{
global $LDAPHOST, $LDAPPORT, $ldap, $LDAPADMIN, $LDAPADMINPASS, $LDAPDATAFIELD, $LDAPLOCALDOMAIN, $LDAPDOMAIN;
if ($ldap) {
$bind = @ldap_bind($ldap, $LDAPADMIN . "@" . $LDAPLOCALDOMAIN, $LDAPADMINPASS);
if (!$bind) {
@ldap_close($ldap);
die('<p class="message">Your password is incorrect, please try again
<a href=javascript:history.back()>click here</a><br>');
}
$filter = "(sAMAccountName={$username})";
$results = ldap_search($ldap, $LDAPDOMAIN, $filter);
ldap_sort($ldap, $results, "sn");
$info = ldap_get_entries($ldap, $results);
if ($info['count'] < 1) {
@ldap_close($ldap);
die('<p class="message">Error occurred, please verify your user , <a href="javascript:history.back()">Go Back</a>');
}
$dn = $info[0]["dn"];
$stored_mail = $info[0][$LDAPDATAFIELD][0] or die('<p class="message">We could not get your info, please contact Support!');
$newPassw = genPassword("xxx0yY0yY");
$mailPass = $newPassw;
$newPassword = "\"{$newPassw}\"";
$len = strlen($newPassword);
$newPass = "";
for ($i = 0; $i < $len; $i++) {
$newPass .= "{$newPassword[$i]}";
}
$newPassword = $newPass;
$data_new["unicodePwd"][] = $newPassword;
if (ldap_mod_replace($ldap, $dn, $data_new)) {
return array(true, $stored_mail, $mailPass);
} else {
return array(false, 100, 100);
}
return array(true, $stored_mail, $mailPass);
} else {
return array(false, 0, 0);
}
// function
}
开发者ID:roopesh007,项目名称:adipart,代码行数:41,代码来源:resetcode.php
示例10: ajax_settags
/**
* Set tags for a contact
*/
function ajax_settags($dn, $tags)
{
global $conf;
global $LDAP_CON;
global $FIELDS;
if (!$FIELDS['_marker']) {
return;
}
header('Content-Type: text/html; charset=utf-8');
$tags = explode(',', $tags);
$tags = array_map('trim', $tags);
$tags = array_unique($tags);
$tags = array_diff($tags, array(''));
//strip empty ones
$entry[$FIELDS['_marker']] = $tags;
ldap_mod_replace($LDAP_CON, $dn, $entry);
foreach ($tags as $tag) {
print '<a href="index.php?marker=';
print rawurlencode($tag);
print '" class="tag">';
print htmlspecialchars($tag);
print '</a> ';
}
}
开发者ID:pneff,项目名称:contagged,代码行数:27,代码来源:ajax.php
示例11: replace
/**
* Replace an entry and return a true or false result
*
* @param string $dn The DN which contains the attribute you want to replace
* @param string $attribute The attribute values you want to replace
*
* @return mixed result of comparison (true, false, -1 on error)
*
* @since 12.1
*/
public function replace($dn, $attribute)
{
return @ldap_mod_replace($this->_resource, $dn, $attribute);
}
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:14,代码来源:ldap.php
示例12: updateAttribute
public function updateAttribute($dn, $attrib, $value)
{
$arr = array();
$arr[$attrib] = $value;
$status = ldap_mod_replace($this->conn, $dn, $arr);
if (!$status) {
$status = ldap_error($this->conn);
}
return $status;
}
开发者ID:pauldraper,项目名称:simple-ldap-manager,代码行数:10,代码来源:lucid_ldap.php
示例13: ldap_first_entry
} else {
# Get objectClass values from user entry
$entry = ldap_first_entry($ldap, $search);
$ocValues = ldap_get_values($ldap, $entry, "objectClass");
# Remove 'count' key
unset($ocValues["count"]);
if (!in_array($answer_objectClass, $ocValues)) {
# Answer objectClass is not present, add it
array_push($ocValues, $answer_objectClass);
$ocValues = array_values($ocValues);
$userdata["objectClass"] = $ocValues;
}
# Question/Answer
$userdata[$answer_attribute] = '{' . $question . '}' . $answer;
# Commit modification on directory
$replace = ldap_mod_replace($ldap, $userdn, $userdata);
$errno = ldap_errno($ldap);
if ($errno) {
$result = "answermoderror";
error_log("LDAP - Modify answer (error {$errno} (" . ldap_error($ldap) . ")");
} else {
$result = "answerchanged";
}
}
}
#==============================================================================
# HTML
#==============================================================================
?>
<div class="result <?php
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:31,代码来源:setquestions.php
示例14: changeADPWD
private function changeADPWD($objLdapBinding, $strUserDN, $strNewPwd)
{
$newpassword = "\"" . $strNewPwd . "\"";
$newpass = mb_convert_encoding($newpassword, "UTF-16LE");
$entry["unicodePwd"] = $newpass;
$res = ldap_mod_replace($objLdapBinding, $strUserDN, $entry) or $res = false;
if ($res) {
$this->success($strNewPwd);
} else {
//Failed to change user Password
$this->failure(8, array($strNewPwd, $newpass, ldap_error($objLdapBinding)));
}
}
开发者ID:adrenlinerush,项目名称:changeADPwd,代码行数:13,代码来源:changeADPwd.class.php
示例15: 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
示例16: 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
示例17: modifyUser
/**
* Definition of the function modifyUser in order to modify the password
*
* @param string $user nick of the user to be changed
* @param array $changes array of field/value pairs to be changed (password will be clear text)
* @return bool true on success, false on error
*/
function modifyUser($user, $changes)
{
// open the connection to the ldap
if (!$this->_openLDAP()) {
$this->_debug('LDAP cannot connect: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
return false;
}
// find the information about the user, in particular the "dn"
$info = $this->getUserData($user, true);
if (empty($info['dn'])) {
$this->_debug('LDAP cannot find your user dn', 0, __LINE__, __FILE__);
return false;
}
$dn = $info['dn'];
// find the old password of the user
list($loginuser, $loginsticky, $loginpass) = auth_getCookie();
if ($loginuser !== null) {
// the user is currently logged in
$secret = auth_cookiesalt(!$loginsticky, true);
$pass = auth_decrypt($loginpass, $secret);
// bind with the ldap
if (!@ldap_bind($this->con, $dn, $pass)) {
$this->_debug('LDAP user bind failed: ' . htmlspecialchars($dn) . ': ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
return false;
}
} elseif ($this->getConf('binddn') && $this->getConf('bindpw')) {
// we are changing the password on behalf of the user (eg: forgotten password)
// bind with the superuser ldap
if (!@ldap_bind($this->con, $this->getConf('binddn'), conf_decodeString($this->getConf('bindpw')))) {
$this->_debug('LDAP bind as superuser: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
return false;
}
} else {
return false;
// no otherway
}
// Generate the salted hashed password for LDAP
$phash = new PassHash();
$hash = $phash->hash_ssha($changes['pass']);
// change the password
if (!@ldap_mod_replace($this->con, $dn, array('userpassword' => $hash))) {
$this->_debug('LDAP mod replace failed: ' . htmlspecialchars($dn) . ': ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
return false;
}
return true;
}
开发者ID:janzoner,项目名称:dokuwiki,代码行数:53,代码来源:auth.php
示例18: print_r
}
if ($oldfile[$i] != "" && $file[$i] == "") {
echo "PXE Dateinamen loeschen!<br> \n\t\t\t\tAchtung: aus ihren PXE Daten wird keine PXE Datei mehr generiert.<br>\n\t\t\t\tSie sind solange nicht mehr für den PXE Bootvorgang verwendbar bis Sie einen neuen Dateinamen anlegen!<br><br>";
$filemod['filename'][$i] = $oldfile[$i];
$filedel['filename'][$j] = $oldfile[$i];
$j++;
$delfi = 1;
$seconds = 4;
}
}
#erst ändern
if ($modfi == 1) {
echo "Ändern: ";
print_r($filemod);
echo "<br>";
if (ldap_mod_replace($ds, $pxeDN, $filemod)) {
$mesg = "PXE Dateiname(n) erfolgreich geändert<br><br>";
} else {
$mesg = "Fehler beim ändern des(r) PXE Dateinamens!<br><br>";
}
$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>";
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:31,代码来源:pxe_change.php
示例19: updateAttribute
/**
* Update 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 updateAttribute($dn, $info, $user)
{
global $conf;
dol_syslog(get_class($this) . "::updateAttribute 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_replace($this->connection, $dn, $info);
if ($result) {
dol_syslog(get_class($this) . "::updateAttribute successfull", LOG_DEBUG);
return 1;
} else {
$this->error = @ldap_error($this->connection);
dol_syslog(get_class($this) . "::updateAttribute failed: " . $this->error, LOG_ERR);
return -1;
}
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:41,代码来源:ldap.class.php
示例20: get_menuentries
$meDN = $_GET['dn'];
$oldpos = $_GET['pos'];
$pxeDN = $_GET['pxedn'];
$mnr = $_GET['mnr'];
$sbmnr = $_GET['sbmnr'];
$me = get_menuentries($pxeDN, array("cn"));
$maxpos = count($me);
$oldpos = preg_replace('/0([0-9])/', '$1', $oldpos);
if ($oldpos < $maxpos) {
$newpos = $oldpos + 1;
if (strlen($newpos) == 1) {
$newpos = "0" . $newpos;
}
if (strlen($oldpos) == 1) {
$oldpos = "0" . $oldpos;
}
if ($secmeDN = get_dn_menuposition($pxeDN, $newpos)) {
#echo "other meDN:"; print_r($secmeDN); echo "<br>";
$entrysec['menuposition'] = $oldpos;
if ($result = ldap_mod_replace($ds, $secmeDN, $entrysec)) {
$entrymenu['menuposition'] = $newpos;
$result = ldap_mod_replace($ds, $meDN, $entrymenu);
}
}
}
$seconds = 0;
$url = "pxe.php?dn=" . $pxeDN . "&mnr=" . $mnr . "&sbmnr=" . $sbmnr . "&#menu";
$mesg = "";
#$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br>
# Falls nicht, klicken Sie hier <a href=".$url." style='publink'>back</a>";
redirect($seconds, $url, $mesg, $addSessionId = TRUE);
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:31,代码来源:menuposition_down.php
注:本文中的ldap_mod_replace函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论