LDAP_ADD(3) 1 LDAP_ADD(3)ldap_add - Add entries to LDAP directorySYNOPSIS
bool ldap_add (resource $link_identifier, string $dn, array $entry)
DESCRIPTION
Add entries in the LDAP directory.
PARAMETERS
o $link_identifier
- An LDAP link identifier, returned by ldap_connect(3).
o $dn
- The distinguished name of an LDAP entity.
o $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";
?>
RETURN VALUES
Returns TRUE on success or FALSE on failure.
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";
}
?>
NOTES
Note
This function is binary-safe.
SEE ALSO ldap_delete(3).
PHP Documentation Group LDAP_ADD(3)
Check Out this Related Man Page
LDAP_COMPARE(3) 1 LDAP_COMPARE(3)ldap_compare - Compare value of attribute found in entry specified with DNSYNOPSIS
mixed ldap_compare (resource $link_identifier, string $dn, string $attribute, string $value)
DESCRIPTION
Compare $value of $attribute with value of same attribute in an LDAP directory entry.
PARAMETERS
o $link_identifier
- An LDAP link identifier, returned by ldap_connect(3).
o $dn
- The distinguished name of an LDAP entity.
o $attribute
- The attribute name.
o $value
- The compared value.
RETURN VALUES
Returns TRUE if $value matches otherwise returns FALSE. Returns -1 on error.
EXAMPLES
The following example demonstrates how to check whether or not given password matches the one defined in DN specified entry.
Example #1
Complete example of password check
<?php
$ds=ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind
if (ldap_bind($ds)) {
// prepare data
$dn = "cn=Matti Meikku, ou=My Unit, o=My Company, c=FI";
$value = "secretpassword";
$attr = "password";
// compare value
$r=ldap_compare($ds, $dn, $attr, $value);
if ($r === -1) {
echo "Error: " . ldap_error($ds);
} elseif ($r === true) {
echo "Password correct.";
} elseif ($r === false) {
echo "Wrong guess! Password incorrect.";
}
} else {
echo "Unable to bind to LDAP server.";
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server.";
}
?>
NOTES
Warning
ldap_compare(3) can NOT be used to compare BINARY values!
PHP Documentation Group LDAP_COMPARE(3)
Has anyone successfully authenticated unix users via Active Directory using
LDAP client on AIX v5.2 or v5.3?? ldapsearch from our unix box retrieves
info from AD but having trouble authenticating unix id when I logon - get a msg ': 3004-318 Error obtaining the user's password information'. Not... (0 Replies)
i have another question..
i have this file:
John Jones
John Smith
Jack Smith
100100 13
Helen Bold
100200 5
how can i use sort to make it look like :
Helen Bold
John Jones
Jack Smith
John Smith
100100 13
100200 5 (4 Replies)
ihave a file in the following format...
Company:abc
Cid Cname
1 Wal
2 Buy
Company:def
mkl
Cid Cname
10 Bank
11 XX
Company:mnk
234
Cid Cname
10 bank
1 Wal
The O/p should be (3 Replies)
I have a requirement like below.I need to Comment some lines in a file.
File contains following information.
{
attribute1
attribute2
atrribute3
attribute4
attribute5
attribute6
attribute7
}
I have a requirement like some times i need to comment lines 3 to before '}' and some... (1 Reply)
Hello,
i have a file with this row:
item1
attribute1 item1
attribute2 item1
attribute3 item1
item2
attribute1 item2
attribute2 item2
attribute3 item2
.....
itemn
attribute1 itemn
attribute2 itemn
attribute3 itemn
I would change in a new file so:
item1,attribute1... (4 Replies)