jndi using
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