jndi using

A

ameyas

All,

I am a newbie to ldap. I have ADAM (Active Directory Application Mode)
as our LDAP server. I am using netscape's LDAP service provider SDK.

i was just trying the following snippet of code.
this should create the directory entry but i am gettin
NoSuchAttributeException at the bind statement.

what am i missing here ? also do i need to create something in the
schema in order to store Integer objects i nthe directory ?

also i have created an application specific partition while creating
ADAM instance. do i need to provide that in the PROVIDER_URL ?


import javax.naming.*;
import javax.naming.directory.*;
import java.util.*;


public class ADAMDemo {

final static String ldapServerName = "localhost";
final static int ldapPort = 389;

public static void main( String[] args ) {
// set up environment to access the server
Hashtable<String, String> env = new Hashtable<String,
String>();
env.put( Context.INITIAL_CONTEXT_FACTORY,
"com.netscape.jndi.ldap.LdapContextFactory" );
env.put( Context.PROVIDER_URL, "ldap://" + ldapServerName
+ ":" + ldapPort);
try {
// obtain initial directory context using the
environment
DirContext ctx = new InitialDirContext( env );

// create some random number to add to the
directory
Integer i = new Integer( 28420 );

System.out.println( "Adding " + i + " to
directory..." );
ctx.bind("cn=myRandomInt", i);

i = new Integer( 98765 );

System.out.println( "i is now: " + i );
i = (Integer) ctx.lookup( "cn=myRandomInt" );
System.out.println( "Retrieved i from directory
with value: " + i );
} catch ( NameAlreadyBoundException nabe ) {
System.err.println( "value has already been
bound!" );
} catch ( Exception e ) {
e.printStackTrace();
}
}


thanks in advance. any kind of help is appreciated.


regards
amey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top