JNDI 로 ldap 에 관한 예제 소스를 테스트중 아래와 같은 에러는 만났습니다. 도움 부탁드립니다.
Adding 28420 to directory...
javax.naming.directory.InvalidAttributeIdentifierException: [LDAP: error code 17 - javaSerializedData: attribute type undefined]; remaining name 'cn=myRandomInt'
위와 같은 에러는 왜 나오는 건가요?
소스는 다음과 같습니다.
**************************************************************
/*
TestLDAP.java -- basic JNDI application used for
testing adding/retrieving objects from the server.
*/
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.NameAlreadyBoundException;
import javax.naming.directory.*;
import java.util.*;
public class TestLDAP {
final static String ldapServerName = "localhost";
final static String rootdn = "cn=Manager, o=JNDITutorial";
final static String rootpass = "secret";
final static String rootContext = "o=JNDITutorial";
public static void main( String[] args ) {
// set up environment to access the server
Properties env = new Properties();
env.put( Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.PROVIDER_URL, "ldap://" + ldapServerName + "/" + rootContext );
env.put( Context.SECURITY_PRINCIPAL, rootdn );
env.put( Context.SECURITY_CREDENTIALS, rootpass );
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 ) {
System.err.println( e );
}
}
}
// end TestLDAP.java
**************************************************************
이것은 http://www.cris.com/~adhawan/tutorial/ 에 나오는 예제를 실행하면서 나온것입니다.
참고로, 저의 slapd.conf는 다음과 같습니다.
include /usr/local/etc/openldap/schema/core.schema
include /usr/local/etc/openldap/schema/cosine.schema
include /usr/local/etc/openldap/schema/java.schema
include /usr/local/etc/openldap/schema/inetorgperson.schema
pidfile /usr/local/var/slapd.pid
argsfile /usr/local/var/slapd.args
#######################################################################
# ldbm database definitions
#######################################################################
database ldbm
suffix "o=JNDITutorial"
#suffix "o=jndiTest"
#suffix "o=My Organization Name,c=US"
rootdn "cn=Manager,o=JNDITutorial"
#rootdn "cn=Manager,o=jndiTest"
#rootdn "cn=Manager,o=My Organization Name,c=US"
# Cleartext passwords, especially for the rootdn, should
# be avoid. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw secret
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd/tools. Mode 700 recommended.
directory /usr/local/var/openldap-ldbm
schemacheck off
# Indices to maintain
index objectClass eq
감사합니다.
|