0 Replies Latest reply on Jul 22, 2004 10:24 AM by MINGO Matthieu

    Jboss-service.xml External Context Configuration, JNDI, LDAP

    MINGO Matthieu Newbie

      Hi everybody,

      I'm trying to work LDAP under Jboss via JNDI

      so I've completed the jboss-service.xml file under my server configuration with this :

      <mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=external/ldap/jboss">
       <attribute name="JndiName">external/ldap/jboss</attribute>
       <attribute name="Properties">jboss.ldap</attribute>
       <attribute name="InitialContext">javax.naming.ldap.InitialLdapContext</attribute>
       <attribute name="RemoteAccess">true</attribute>
       </mbean>


      And also I've got the jboss.ldap file :
      java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
      java.naming.provider.url=ldap://localhost:391/xxxxx
      java.naming.security.principal=xxxxx
      java.naming.security.authentication=simple
      java.naming.security.credentials=xxxxx


      I try to access to my ldap via a simple jsp like this :

      <%@ page language="Java" import="javax.naming.*"
       import="javax.naming.ldap.*"
       import="javax.naming.directory.*"
      %>
      
      <%
      InitialContext iniCtx = new InitialContext();
      LdapContext ldapCtx = (LdapContext) iniCtx.lookup("external/ldap/jboss");
      Attributes answer = ldapCtx.getAttributes("ou=personnes");
      for(NamingEnumeration ae=answer.getAll();ae.hasMore();) {
       Attribute attr = (Attribute)ae.next();
       out.println("attribute : " + attr.getID());
       for(NamingEnumeration e = attr.getAll();e.hasMore();out.println("value : " + e.next()));
      }
      %>



      On the first time I try to work it, I've got the message which indicate me that my configuration of my external bean is wrong.....
      the problem comes from the attribute Properties which does not retrieve my data from my jboss.ldap file, but just the name of the file

      However, if I specify under the jmx console, the name of my file jboss.ldap under the field PropertyURL, and then I apply the changes, everything works, and I find my parameters in the property field...

      So what I want, is to know how configure my jboss-service file in order to retrieve my data directly, without going under jmx console and make manipulations.

      Thanks in advance

      Matt