Hi,
I have setup an ldap server and am trying to add to it with php.
I am able to connect to the server and bind to it, but I can't add
I get the error ldap_add() [function.ldap-add]: Add: Naming violation in ....
here is a portion of my slapd.conf file in linux
database bdb
suffix "dc=example,dc=org"
rootdn "cn=Manager,dc=example,dc=org"
rootpw password
directory /var/lib/ldap/filter
index uid eq
This is my ldif file
dn: dc=example,dc=org
dc: example
o: example.org
objectClass: top
objectClass: dcObject
objectClass: organization
dn: ou=people,dc=example,dc=org
ou: people
objectClass: top
objectClass: organizationalUnit
dn: cn=Robert Smith,ou=people,dc=example,dc=org
objectClass: inetOrgPerson
cn: Robert Smith
sn: smith
uid: smith123
userpassword: password
Here is what I am using to access ldap with php
<?php
/* Connect and bind to the LDAP server.... */
$ldapHost = "ldap://192.168.2.50";
$ldapPort = "389";
$ldapUser = "cn=Manager, dc=example, dc=org";
$ldapPswd = "password";
$ldapconn = ldap_connect($ldapHost, $ldapPort) or die("Can't establish LDAP connection");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
ldap_bind($ldapconn, $ldapUser, $ldapPswd) or die("Can't bind to the server.");
/* Specify the distinguished name. */
$dn = "ou=people, dc=example, dc=org";
/* Specify the ldap entry */
$entry["objectclass"] = "inetOrgPerson";
$entry["cn"] = "Julius Caesar";
$entry["sn"] = "Roman";
$entry["uid"] = "julius123";
$entry["userpassword"] = "password";
/* Add the entry. */
ldap_add($ldapconn, $dn, $entry) or die("Could not add new entry!");
/* Close the connection. */
ldap_unbind($ldapconn);
?>
I am sure it is something to the way I am using my syntax to add to the ldap server but I have tried many different ways and still can't get it.
Thanks for any help