ldap_modify_batch

(PHP 5.4 >= 5.4.26, PHP 5.5 >= 5.5.10, PHP 5.6 >= 5.6.0, PHP 7, PHP 8)

ldap_modify_batchBatch and execute modifications on an LDAP entry

Beschreibung

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

Modifies an existing entry in the LDAP directory. Allows detailed specification of the modifications to perform.

Parameter-Liste

ldap

An LDAP resource, returned by ldap_connect().

dn

The distinguished name of an LDAP entity.

modifications_info

An array that specifies the modifications to make. Each entry in this array is an associative array with two or three keys: attrib maps to the name of the attribute to modify, modtype maps to the type of modification to perform, and (depending on the type of modification) values maps to an array of attribute values relevant to the modification.

Possible values for modtype include:

LDAP_MODIFY_BATCH_ADD

Each value specified through values is added (as an additional value) to the attribute named by attrib.

LDAP_MODIFY_BATCH_REMOVE

Each value specified through values is removed from the attribute named by attrib. Any value of the attribute not contained in the values array will remain untouched.

LDAP_MODIFY_BATCH_REMOVE_ALL

All values are removed from the attribute named by attrib. A values entry must not be provided.

LDAP_MODIFY_BATCH_REPLACE

All current values of the attribute named by attrib are replaced with the values specified through values.

Note that any value for attrib must be a string, any value for values must be an array of strings, and any value for modtype must be one of the LDAP_MODIFY_BATCH_* constants listed above.

controls

Array of LDAP Controls to send with the request.

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Changelog

Version Beschreibung
8.1.0 Der Parameter ldap erwartet nun eine LDAP\Connection-Instanz; vorher wurde eine Ressource erwartet.
8.0.0 controls ist jetzt nullable (akzeptiert den null-Wert); vorher war der Standardwert [].
7.3.0 Support for controls added

Beispiele

Beispiel #1 Add a telephone number to a contact

<?php
$dn 
"cn=John Smith,ou=Wizards,dc=example,dc=com";
$modifs = [
    [
        
"attrib"  => "telephoneNumber",
        
"modtype" => LDAP_MODIFY_BATCH_ADD,
        
"values"  => ["+1 555 555 1717"],
    ],
];
ldap_modify_batch($connection$dn$modifs);
?>

Beispiel #2 Rename a user

<?php
$dn 
"cn=John Smith,ou=Wizards,dc=example,dc=com";
$modifs = [
    [
        
"attrib"  => "sn",
        
"modtype" => LDAP_MODIFY_BATCH_REPLACE,
        
"values"  => ["Smith-Jones"],
    ],
    [
        
"attrib"  => "givenName",
        
"modtype" => LDAP_MODIFY_BATCH_REPLACE,
        
"values"  => ["Jack"],
    ],
];
ldap_modify_batch($connection$dn$modifs);
ldap_rename($connection$dn"cn=Jack Smith-Jones"NULLTRUE);
?>

Beispiel #3 Add two e-mail addresses to a user

<?php
$dn 
"cn=Jack Smith-Jones,ou=Wizards,dc=example,dc=com";
$modifs = [
    [
        
"attrib"  => "mail",
        
"modtype" => LDAP_MODIFY_BATCH_ADD,
        
"values"  => [
            
"jack.smith@example.com",
            
"jack.smith-jones@example.com",
        ],
    ],
];
ldap_modify_batch($connection$dn$modifs);
?>

Beispiel #4 Change a user's password

<?php
$dn 
"cn=Jack Smith-Jones,ou=Wizards,dc=example,dc=com";
$modifs = [
    [
        
"attrib"  => "userPassword",
        
"modtype" => LDAP_MODIFY_BATCH_REMOVE,
        
"values"  => ["Tr0ub4dor&3"],
    ],
    [
        
"attrib"  => "userPassword",
        
"modtype" => LDAP_MODIFY_BATCH_ADD,
        
"values"  => ["correct horse battery staple"],
    ],
];
ldap_modify_batch($connection$dn$modifs);
?>

Beispiel #5 Change a user's password (Active Directory)

<?php
function adifyPw($pw)
{
    return 
iconv("UTF-8""UTF-16LE"'"' $pw '"');
}

$dn "cn=Jack Smith-Jones,ou=Wizards,dc=ad,dc=example,dc=com";
$modifs = [
    [
        
"attrib"  => "unicodePwd",
        
"modtype" => LDAP_MODIFY_BATCH_REMOVE,
        
"values"  => [adifyPw("Tr0ub4dor&3")],
    ],
    [
        
"attrib"  => "unicodePwd",
        
"modtype" => LDAP_MODIFY_BATCH_ADD,
        
"values"  => [adifyPw("correct horse battery staple")],
    ],
];
ldap_modify_batch($connection$dn$modifs);

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Daten einer Abfrage mit Hilfe von Thumbnails nebeneinander ausgeben

Warum soll ich float meiden? Siehe https://www.linkedin.com/pulse/css-float-vs-grid-flexbox-sachin-tiwari Falls es mit Englisch nicht so klappt: ...

Geschrieben von scatello am 18.05.2024 05:57:56
Forum: PHP Developer Forum
Daten einer Abfrage mit Hilfe von Thumbnails nebeneinander ausgeben

Also den Fehler habe ich gefunden und abgestellt. Warum soll ich float meiden?

Geschrieben von Malchor am 17.05.2024 20:54:01
Forum: PHP Developer Forum
Daten einer Abfrage mit Hilfe von Thumbnails nebeneinander ausgeben

Dein HTML-Code ist definitiv kaputt und float solltest du auch vergessen. Beschäftige dich mit Flex-Box oder Grid

Geschrieben von scatello am 17.05.2024 20:43:50
Forum: PHP Developer Forum
Daten einer Abfrage mit Hilfe von Thumbnails nebeneinander ausgeben

Da ich viele unterschiedliche Tabellen benötige mache ich das so umständlich. Aber ist das der Grund warum das Floaten nicht funktioniert?

Geschrieben von Malchor am 17.05.2024 17:15:03
Forum: PHP Developer Forum