<?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <refentry xml:id="function.ldap-modify-batch" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ldap_modify_batch</refname> <refpurpose>Batch and execute modifications on an LDAP entry</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>ldap_modify_batch</methodname> <methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam> <methodparam><type>string</type><parameter>dn</parameter></methodparam> <methodparam><type>array</type><parameter>entry</parameter></methodparam> </methodsynopsis> <para> Modifies an existing entry in the LDAP directory. Allows detailed specification of the modifications to perform. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>link_identifier</parameter></term> <listitem> <para> An LDAP link identifier, returned by <function>ldap_connect</function>. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>dn</parameter></term> <listitem> <para> The distinguished name of an LDAP entity. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>entry</parameter></term> <listitem> <para> An array that specifies the modifications to make. Each entry in this array is an associative array with two or three keys: <literal>attrib</literal> maps to the name of the attribute to modify, <literal>modtype</literal> maps to the type of modification to perform, and (depending on the type of modification) <literal>values</literal> maps to an array of attribute values relevant to the modification. </para> <para> Possible values for <literal>modtype</literal> include: <variablelist> <varlistentry> <term><constant>LDAP_MODIFY_BATCH_ADD</constant></term> <listitem> <para> Each value specified through <literal>values</literal> is added (as an additional value) to the attribute named by <literal>attrib</literal>. </para> </listitem> </varlistentry> <varlistentry> <term><constant>LDAP_MODIFY_BATCH_REMOVE</constant></term> <listitem> <para> Each value specified through <literal>values</literal> is removed from the attribute named by <literal>attrib</literal>. Any value of the attribute not contained in the <literal>values</literal> array will remain untouched. </para> </listitem> </varlistentry> <varlistentry> <term><constant>LDAP_MODIFY_BATCH_REMOVE_ALL</constant></term> <listitem> <para> All values are removed from the attribute named by <literal>attrib</literal>. A <literal>values</literal> entry must not be provided. </para> </listitem> </varlistentry> <varlistentry> <term><constant>LDAP_MODIFY_BATCH_REPLACE</constant></term> <listitem> <para> All current values of the attribute named by <literal>attrib</literal> are replaced with the values specified through <literal>values</literal>. </para> </listitem> </varlistentry> </variablelist> </para> <para> Note that any value for <literal>attrib</literal> must be a string, any value for <literal>values</literal> must be an array of strings, and any value for <literal>modtype</literal> must be one of the LDAP_MODIFY_BATCH_* constants listed above. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>Add a telephone number to a contact</title> <programlisting role="php"> <![CDATA[ <?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); ?> ]]> </programlisting> </example> <example> <title>Rename a user</title> <programlisting role="php"> <![CDATA[ <?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", NULL, TRUE); ?> ]]> </programlisting> </example> <example> <title>Add two e-mail addresses to a user</title> <programlisting role="php"> <![CDATA[ <?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); ?> ]]> </programlisting> </example> <example> <title>Change a user's password</title> <programlisting role="php"> <![CDATA[ <?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); ?> ]]> </programlisting> </example> <example> <title>Change a user's password (Active Directory)</title> <programlisting role="php"> <![CDATA[ <?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); ]]> </programlisting> </example> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"~/.phpdoc/manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->