PHP.mk документација

ldap_mod_replace

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.ldap-mod-replace.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.ldap-mod-replace.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
ldap_mod_replace

Референца за `function.ldap-mod-replace.php` со подобрена типографија и навигација.

function.ldap-mod-replace.php

ldap_mod_replace

(PHP 4, PHP 5, PHP 7, PHP 8)

ldap_mod_replace(PHP 7 >= 7.3.0, PHP 8)

= NULL

ldap_mod_replace(
         LDAP\Connection $ldap,
         string $dn,
         array $entry,
         ?array $controls = null
): bool

Замени ги вредностите на атрибутите со нови dnЗаменува еден или повеќе атрибути од наведените

Параметри

ldap

Еден LDAP\Connection инстанца, вратена од ldap_connect().

dn

. Може исто така да додава или отстранува атрибути.

entry

Разликуваното име на LDAP ентитет.

controls

Низа од LDAP контроли сега е nullable; претходно, стандардно беше

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true на успех или false при неуспех.

Дневник на промени

Верзија = NULL
8.1.0 На ldap параметарот очекува LDAP\Connection инстанца сега; претходно, валидна ldap link resource се очекуваше.
8.0.0 controls Пример #1 LDAP пребарување [].
7.3.0 Поддршка за controls added

Белешки

Забелешка: Пример #4 Користење на контексти на потоци

Види Исто така

  • ldap_mod_replace_ext() Асоцијативен список што ги наведува атрибутите што треба да се заменат. Испраќањето празен список како вредност ќе го отстрани атрибутот, додека испраќањето атрибут што сè уште не постои на овој запис ќе го додаде.
  • ldap_mod_del() - Замени ги вредностите на атрибутите со нови
  • ldap_mod_add() - Избриши ги вредностите на атрибутите од тековните атрибути
  • ldap_modify_batch() - Додај вредности на атрибути на тековните атрибути

Белешки од корисници 14 белешки

- Групирај и изврши модификации на LDAP запис
пред 18 години
You can use arrays for multiple attributes example:

<?php
$entry[mail] = array("[email protected]","[email protected]");
$results = ldap_mod_add($ldapConnID,$dn, $entry);
?>
or as i did for creating anew user:
<?php
$adduserAD["objectClass"] = array("top","person","organizationalPerson","user");
?>
chris at mr2madness dot com
figroc at gmail dot com
To modify an attribute with a single value: 
  $entry[mail] = "[email protected]"; 
  $results = ldap_mod_add($ldapConnID,$dn, $entry); 

To modify an attribute with multiple values: 
  $entry[mail][] = "[email protected]"; 
  $entry[mail][] = "[email protected]"; 
  $results = ldap_mod_add($ldapConnID,$dn, $entry);

To modify multiple attributes
  $entry[mail][] = "[email protected]"; 
  $entry[mail][] = "[email protected]"; 
  $entry[c]      = "US";
  $results = ldap_mod_add($ldapConnID,$dn, $entry);
Анонимен
пред 13 години
this can not be used to change a password on an AD server that requires you to send the old and new password.

in order to do this use on shuts an sever make an admin-account that allows to change other ppl pw without suppling the old password first.
dynamik
пред 13 години
Using this function to 'replace' an Active Directory password requires the "Reset Password" security permission as opposed to the "Change Password" permission (which is assigned by default to SELF)
JoshuaStarr at aelana dot com
21 години пред
Changing a user password in Active Directory.
Securely connect (using ldaps) to the Active Directory and bind using an administrator account.

In this example, $userDn contains the dn of the user I want to modify, and $ad is the Active Directory ldaps connection)

$newPassword = "MyPassword";
$newPassword = "\"" . $newPassword . "\"";
$len = strlen($newPassword);
for ($i = 0; $i < $len; $i++)
        $newPassw .= "{$newPassword{$i}}\000";
$newPassword = $newPassw;
$userdata["unicodepwd"] = $newPassword;
$result = ldap_mod_replace($ad, $userDn, $userdata);
if ($result) echo "User modified!" ;
else echo "There was a problem!";

I found it hard to get a proper encoding for the unicodepwd attribute so this piece of code might help you ;-)
frederic dot jacquot at insa-lyon dot fr
figroc at gmail dot com
in openldap 2.0.x you can use method with mod_del/mod_add only if the attribute have defined EQUALITY rule.
plex909
пред 17 години
Here's an easy way to encode AD "unicodepwd" values from linux... 

Download and install recode... 
http://www.gnu.org/software/recode/recode.html

Then write something like this...
<?php
function ADUnicodePwdValue($plain_txt_value)
{
    return str_replace("\n", "", shell_exec("echo -n '\"" . $plain_txt_value . "\"' | recode latin1..utf-16le/base64"));
}

$user["unicodepwd"] = ADUnicodePwdValue("my_password");

?>

[EDITOR thiago NOTE: The following text was sent by boyvanderlaak at gmail dot com as an important complement]

if you do not have access to your linux box but have Multibyte String enabled you could try the following for AD 2008:

<?php
$info["unicodePwd"] = mb_convert_encoding('"' . $newPassword . '"', 'utf-16le');
?>
ondrej at sury dot cz
пред 18 години
Here is some great information from the OpenLDAP FAQs regarding changing a userPassword attribute with PHP:

http://www.openldap.org/faq/data/cache/347.html

$userpassword = "{SHA}" . base64_encode( pack( "H*", sha1( $pass ) ) );
mike dot rosile at interzonegames dot com
yasuo_ohgaki at hotmail dot com
ldap_mod_replace() and ldap_modify() are _exactly_ the same.  So, the comment that ldap_mod_replace() "performs the modification at the attribute level as opposed to the object level", has no root in reality.
oyvindmo at initio dot no
19 години пред
Before you modify values in your ldap directory, first make sure that you have permission to do so.  In openldap adding the following acl in slap.conf will allow the user to modify their own userpassword.

access to attr=userPassword
        by self write
        by anonymous auth
        by * none
aaronfulton at softhome dot net
yasuo_ohgaki at hotmail dot com
if i want to replace the special attribute but i don't replace other attribute ,i just use "ldap_mod_del" and "ldap_mod_add" ,the function seems to that
yife at myrice-ltd dot com
19 години пред
If you do not wish to set up SSL on your active directory, and you are running on Windows, you can use COM and ADSI to set the new password for a user, or to active a user:

<?PHP
// to set a user password
  // server is the ldap server
  // newuser_dn is the full dn of the user you want to modify
  // newuser_password is the password you wish to set for the user

    $ADSI = new COM("LDAP:");
    $user = $ADSI->OpenDSObject("LDAP://".$server."/".$newuser_dn, $adminuser, $adminpassword, 1);
    $user->SetPassword($newuser_password);
    $user->SetInfo();

// to activate a user
    $ADSI = new COM("LDAP:");
    $user = $ADSI->OpenDSObject("LDAP://".$server."/".$newuser_dn, $adminuser, $adminpassword, 1);
    $user->AccountDisabled = false;
    $user->SetInfo();

?>
erwann at zeflip dot com
пред 6 години
An bettter method to create the unicodePwd Active Directory LDAP field from PHP is:

$unicodePwd = iconv("UTF-8", "UTF-16LE", "\"".$password."\"");

It works when $password is coming from a UTF-8 page. If your $password is not utf-8, change the 1st parameter of iconv.
Анонимен
пред 23 години
Sometime,we cannot replace ldap_mod_replace  function  with ldap_mod_del function and ldap_mod_add fuction .We  don't have permission to delete an attribute but  we can replace it.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.