[Date Prev][Date Next] [Chronological] [Thread] [Top]

Adding new entry



Hello,
 
I'm new to LDAP and I'm trying to add a new entry using OpenLDAP 2.0.11 and Netscape Java SDK 4.0 and I keep getting this error on the ld.add call no matter what I try:
 
Error: netscape.ldap.LDAPException: error result (32); No such object
 
I've been working on this the past few days and I'm using the Add.java example that was included with the SDK.  Here is the code.  I'm basically trying to just add a person in the hierarchy.
 
public class AddGroup {
    public static void main( String[] args )
        {
                /* Specify the DN we're adding */
//               String dn = "ou=People, o=tls-us.com";   // <= This failed too and many combinations
//               String dn = "ou=People, o=tls-us, o=com";   // <= This failed too and many combinations
               String dn = "uid=wbjensen, ou=People, o=tls-us.com";   // <= *** Code that needs changing
 
               /* Specify the attributes of the entry */
               String objectclass_values[] = { "top", "person", "organizational Person", "inetOrgPerson" };
 
                LDAPAttributeSet attrs = new LDAPAttributeSet();
                LDAPAttribute attr = new LDAPAttribute( "objectclass" );
                for( int i = 0; i < objectclass_values.length; i++ ) {
                        attr.addValue( objectclass_values[i] );
                }
                attrs.add( attr );
 
                /* Create an entry with this DN and these attributes */
                LDAPEntry myEntry = new LDAPEntry( dn, attrs );
 
                LDAPConnection ld = null;
                int status = -1;
                try {
                        ld = new LDAPConnection();
                        /* Connect to server */
                        String MY_HOST = "localhost";
                        int MY_PORT = 389;
                        ld.connect( MY_HOST, MY_PORT );
 
                        /* Authenticate to the server as directory manager */
                        String MGR_DN = "cn=Manager,dc=tls-us,dc=com";
                        String MGR_PW = "secret";
                        ld.authenticate( MGR_DN, MGR_PW );
                        /* Now add the entry to the directory */
                        ld.add( myEntry );   <= ********* Call that causes exception!
                        System.out.println( "Entry added"  );
                }
                catch( LDAPException e ) {
                        if ( e.getLDAPResultCode() == LDAPException.ENTRY_ALREADY_EXISTS )
                                System.out.println( "Error: Entry already present" );
                        else
                                System.out.println( "Error: " + e.toString() );
                }
 
                /* Done, so disconnect */
                if ( (ld != null) && ld.isConnected() ) {
                        try {
                            ld.disconnect();
                        } catch ( LDAPException e ) {
                                System.out.println( "Error: " + e.toString() );
                        }
                }
                System.exit(status);
    }
 
Are there certain privileges to set in the slapd.conf file?  I'm trying to use the inetorgperson.schema with the above example.
 
Here is my slapd.conf file:
 
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/nis.schema
include         /etc/openldap/schema/redhat/rfc822-MailMember.schema
include         /etc/openldap/schema/redhat/autofs.schema
include         /etc/openldap/schema/redhat/kerberosobject.schema
 
#######################################################################
# ldbm database definitions
#######################################################################
 
database        ldbm
suffix          "dc=tls-us, dc=com"
rootdn          "cn=Manager, dc=tls-us, dc=com"
rootpw          secret
directory       /var/lib/ldap
index   objectClass,uid,uidNumber,gidNumber     eq
index   cn,mail,surname,givenname               eq,subinitial
 
defaultaccess read
access to attr=userpassword
 by self write
 by dn="cn=Manager,dc=tls-us,dc=com" write
 by * compare
access to *
 by dn="cn=Manager,dc=tls-us,dc=com" write
 by * read
 
 
Thanks, I appreciate it.
Wes Quinn
TransLogic Systems, Inc.
Apex, NC