0 Replies Latest reply on Dec 12, 2005 11:15 AM by 807573

    proxy authorization with JNDI

    807573
      Hi,

      I want to use proxy authorization unsing Java JNDI. I used the following program:

      import java.util.*;
      import javax.naming.*;
      import javax.naming.directory.*;
      import javax.naming.ldap.*;
      import com.sun.jndi.ldap.ctl.*;
      import static javax.naming.Context.*;

      class TestProxyAuthorization
      {
      public static void main(String[] args) throws Exception
      {
           LdapContext ldap=null;
           Hashtable<String,Object> props = new Hashtable<String,Object>();
           props.put(INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
           props.put(SECURITY_PROTOCOL, "ssl");
           props.put(SECURITY_AUTHENTICATION, "simple");
           props.put(SECURITY_PRINCIPAL, "uid=telschow,ou=rt,ou=people,dc=wias-berlin,dc=de");
           props.put(SECURITY_CREDENTIALS, "xxxxxxxx");
           props.put(PROVIDER_URL, "ldap://bolzano.wias-berlin.de/dc=wias-berlin,dc=de");
           try
           {
                ldap = new InitialLdapContext(props, null);
                ldap.setRequestControls(new Control[]{new ProxiedAuthorizationControl("dn:uid=vdsand,ou=fg5,ou=people,dc=wias-berlin,dc=de")});
                Attributes attrs = new BasicAttributes();
                attrs.put("objectClass", "organizationalUnit");
                attrs.put("ou", "aaaaaa");
                ldap.bind("ou=aaaaaa,ou=talk,ou=2004,ou=Literatur",null,attrs);
           }
           catch (javax.naming.NamingException ne){ne.printStackTrace();}
      }
      }

      Running this program I get the error:

      javax.naming.CommunicationException: [LDAP: error code 2 - Protocol Error]; remaining name 'ou=aaaaaa,ou=talk,ou=2004,ou=Literatur'
      at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
      at com.sun.jndi.ldap.LdapCtx.c_bind(Unknown Source)
      at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bind(Unknown Source)
      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(Unknown Source)
      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(Unknown Source)
      at javax.naming.directory.InitialDirContext.bind(Unknown Source)
      at TestProxyAuthorization.main(TestProxyAuthorization.java:42)


      What is wrong?
      Can anybody help me?

      Ciao, Gerhard