ldap_add
(PHP 4, PHP 5, PHP 7)
ldap_add — Add entries to LDAP directory
Description
$link_identifier
, string $dn
, array $entry
[, array $serverctrls
= array()
] ) : boolAdd entries in the LDAP directory.
Parameters
-
link_identifier
-
An LDAP link identifier, returned by ldap_connect().
-
dn
-
The distinguished name of an LDAP entity.
-
entry
-
An array that specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0.
<?php
$entry["attribute1"] = "value";
$entry["attribute2"][0] = "value1";
$entry["attribute2"][1] = "value2";
?> -
serverctrls
-
Array of LDAP Controls to send with the request.
Examples
Example #1 Complete example with authenticated bind
<?php
$ds = ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$r = ldap_bind($ds, "cn=root, o=My Company, c=US", "secret");
// prepare data
$info["cn"] = "John Jones";
$info["sn"] = "Jones";
$info["objectclass"] = "person";
// add data to directory
$r = ldap_add($ds, "cn=John Jones, o=My Company, c=US", $info);
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>
See Also
- ldap_add_ext() - Add entries to LDAP directory
- ldap_delete() - Delete an entry from a directory
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-ldap-add.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.