Skip to Content

Accessing LDAP in a custom JAAS login module


I have developed a custom jaas login module in CE 7.1. I created a java dc which contains a class extending AbstractLoginModule. This DC is deployed on to the server using an EAR DC. I am trying to access LDAP in the custom login module. I am trying to establish an SSL connection to LDAP. For this purpose i have created a custom socket factory class which extends SSLSocketFactory. I used the code below to establish the connection.

		Hashtable<String,String> env=new Hashtable<String,String>();
		DirContext dirContext=null;
                env.put("java.naming.ldap.factory.socket", "com.test.ldap.MySSLSocketFactory");
                dirContext=new InitialDirContext(env);

MySSLSocketFactory is the name of custom socket factory.

During a login process, the above code results in error because the connection to LDAP server could not be established. However the same code when executed in a webdynpro DC is working without any problem. What could be the reason for this?

This is the error i could see in defaultTrace

javax.naming.CommunicationException: [Root exception is java.lang.ClassNotFoundException: com.test.ldap.MySSLSocketFactory


Loader Info -

ClassLoader name: [service:security]

Living status: alive

Direct parent loaders:










at com.sun.jndi.ldap.Connection.<init>(

at com.sun.jndi.ldap.LdapClient.<init>(

at com.sun.jndi.ldap.LdapClient.getInstance(

at com.sun.jndi.ldap.LdapCtx.connect(

at com.sun.jndi.ldap.LdapCtx.<init>(

at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(

at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(

at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(

at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(




at javax.naming.spi.NamingManager.getInitialContext(

at javax.naming.InitialContext.getDefaultInitCtx(

at javax.naming.InitialContext.init(

at javax.naming.InitialContext.<init>(


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 05, 2011 at 06:38 PM


    I used an EJB to perform the LDAP search and called the EJB from the login module. It is working as expected.



    Add comment
    10|10000 characters needed characters exceeded