Directory Studio
  1. Directory Studio
  2. DIRSTUDIO-182

[Ldap][studio] Use property file to designate ldap context factory etc. instead of hard code

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0
    • Component/s: studio-connection
    • Labels:
      None

      Description

      In the current studio implementation. Connections classes such as JndiConnectionContext hard code ldap environment variables:

      public void connect( String host, int port, boolean useLdaps, boolean useStartTLS, Control[] connCtls,
      ExtendedProgressMonitor monitor ) throws NamingException

      { this.environment = new Hashtable<String, String>(); this.environment.put( Context.INITIAL_CONTEXT_FACTORY, " com.sun.jndi.ldap.LdapCtxFactory" ); //$NON-NLS-1$ this.environment.put( "java.naming.ldap.version", "3" ); //$NON-NLS-1$ //$NON-NLS-2$ // more logic here...... }

      Using a jndi.properties file would make the service provider configurable. An advice is to use a preference dialog to enter the right provider.

        Activity

        spark shen created issue -
        Stefan Seelmann made changes -
        Field Original Value New Value
        Assignee Stefan Seelmann [ seelmann ]
        Fix Version/s 1.3.0 [ 12313309 ]
        Hide
        Stefan Seelmann added a comment -

        Fixed here:
        http://svn.apache.org/viewvc?rev=691723&view=rev

        o Added preference for the JNDI LDAP context factory to use
        o Added auto-detection for Sun and ApacheHarmony factories

        Another question: To detect which context factory is available I used the following code. It works but I wonder if there's a better way to find out which class is available in the class loader?
        -------------------------------------------------------------
        public String getDefaultLdapContextFactory()
        {
        String defaultLdapContextFactory = "";

        try

        { String sun = "com.sun.jndi.ldap.LdapCtxFactory"; Class.forName( sun ); defaultLdapContextFactory = sun; }

        catch ( ClassNotFoundException e )
        {
        }
        try

        { String apache = "org.apache.harmony.jndi.provider.ldap.LdapContextFactory"; Class.forName( apache ); defaultLdapContextFactory = apache; }

        catch ( ClassNotFoundException e )
        {
        }

        return defaultLdapContextFactory;
        }
        -------------------------------------------------------------

        Show
        Stefan Seelmann added a comment - Fixed here: http://svn.apache.org/viewvc?rev=691723&view=rev o Added preference for the JNDI LDAP context factory to use o Added auto-detection for Sun and ApacheHarmony factories Another question: To detect which context factory is available I used the following code. It works but I wonder if there's a better way to find out which class is available in the class loader? ------------------------------------------------------------- public String getDefaultLdapContextFactory() { String defaultLdapContextFactory = ""; try { String sun = "com.sun.jndi.ldap.LdapCtxFactory"; Class.forName( sun ); defaultLdapContextFactory = sun; } catch ( ClassNotFoundException e ) { } try { String apache = "org.apache.harmony.jndi.provider.ldap.LdapContextFactory"; Class.forName( apache ); defaultLdapContextFactory = apache; } catch ( ClassNotFoundException e ) { } return defaultLdapContextFactory; } -------------------------------------------------------------
        Stefan Seelmann made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Pierre-Arnaud Marcelot made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Stefan Seelmann
            Reporter:
            spark shen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development