[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
How to add LDAP entries not rooted at country via PHP3
System: RH 5.1 with Apache 1.3.3 + mod_perl (static) + mod_php (via
apxs) compiled with openldap 1.0.2
Hi, I have the following schema
dn: provider=bar
provider: bar
objectclass: top
dn: id=yusufg,provider=bar
id: yusufg
password: secret
objectclass: puser
I used ldif2ldbm from the openldap 1.0.2 to add this to my
ldapserver. Tweaked the example ldap php file to read the data from
the server. Now, when I want to add data to the server via PHP
in the form
<?php
$ds=ldap_connect("localhost",9000);
// assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$r=ldap_bind($ds,"","");
// prepare data
$info["id"]="snafu";
$info["password"] = "microsoft";
$info["objectclass"]= "puser";
// add data to directory
$dn1 = "id=" . $info["id"] . "," . "provider=bar" ;
echo $dn1 ;
$r=ldap_add($ds, $dn1 , $info);
if ($r) {
echo "Added LDAP data" ;
}
else {
echo "Unable to add LDAP data" ;
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>
My slapd.conf has the following entries
defaultaccess write.
suffix "provider=bar"
When I execute this PHP file, I get
Warning: LDAP add operation could not be completed
and the error log shows
LDAP: No such object
LDAP: matched: provider=bar
Any ideas where I might be making a mistake
Cheers, Yusuf
PS, For members on openldap-general. Info about PHP is at
http://www.php.net/
--
Yusuf Goolamabbas
yusufg@huge.net