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

(ITS#4684) Bind Operation Bug



Full_Name: Deepak Vohra
Version: 
OS: 
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (207.6.39.2)


The bind operation generates an exception if the cn has a space, 
for example cn=john smith.
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 
no global
> superior knowledge]; 

If a cn does not have a space in it, for example cn=johnsmith, an exception does
not get generated.



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,dc=example,dc=com";
        final static String rootpass = "";
        final static String rootContext = "cn=john smith, dc=example,dc=com";
        
        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 +
"/");
                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,cn=john smith,
dc=example,dc=com", i );
                        
                        i = new Integer( 98765 );
                        System.out.println( "i is now: " + i );
                        
                        i = (Integer) ctx.lookup(
"cn=myRandomInt,cn=bharathgowda, dc=example,dc=com" );
                        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 );
                }
        }
}