1 Reply Latest reply on Sep 17, 2007 11:55 AM by vickraman ganesan

    NullPointerException thrown from LDAP Context

    vickraman ganesan Newbie

      Hi There,
      I'm trying to configure LDAP setup in my local JBoss 4.2.1 server. I've added

      <application-policy name = "MY-LDAP">

      <login-module code = "org.jboss.security.auth.spi.LdapExtLoginModule" flag = "required">
      <module-option name="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</module-option>
      <module-option name="java.naming.provider.url">ldap://myserver:389/</module-option>
      <module-option name="java.naming.security.authentication">simple</module-option>
      <module-option name="java.naming.security.credentials">password</module-option>
      <module-option name="java.naming.security.principal">uid=admin,ou=Administrators,ou=TopologyManagement,o=NetscapeRoot</module-option>
      <module-option name="userDN">ou=People, dc=company,dc=co,dc=uk</module-option>
      <module-option name="bindCredential">password</module-option>
      <module-option name="rolesCtxDN">ou=Groups, dc=company,dc=co,dc=uk</module-option>
      <module-option name="uidAttributeID">person</module-option>
      <module-option name="searchScope">SUBTREE_SCOPE</module-option>
      <module-option name="restore-login-identity">true</module-option>
      <module-option name="baseFilter">((uniquemember={0})(objectclass=groupofuniquenames))</module-option>
      </login-module>


      and, added the following in my class file.

      LoginContext lc = new LoginContext("MY-LDAP",
      new CustomCallbackHandler(userId, password));

      when I tried to access the application, getting the following error.

      java.lang.NullPointerException
      at javax.naming.InitialContext.getURLScheme(InitialContext.java:228)
      at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:277)
      at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:87)
      at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:267)
      at org.jboss.security.auth.spi.LdapExtLoginModule.bindDNAuthentication(LdapExtLoginModule.java:375)
      at org.jboss.security.auth.spi.LdapExtLoginModule.createLdapInitContext(LdapExtLoginModule.java:336)
      at org.jboss.security.auth.spi.LdapExtLoginModule.validatePassword(LdapExtLoginModule.java:229)
      at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:210)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
      at javax.security.auth.login.LoginContext.login(LoginContext.java:579)

      Can anybody help me??

      Thanks.

        • 1. Re: NullPointerException thrown from LDAP Context
          vickraman ganesan Newbie

          Problem solved..config issue only..I've changed my entries as follows and it's working fine...


          <login-module code = "org.jboss.security.auth.spi.LdapLoginModule" flag = "required">
          <module-option name="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</module-option>
          <module-option name="java.naming.provider.url">ldap://myserver:389/</module-option>
          <module-option name="java.naming.security.authentication">simple</module-option>
          <module-option name="java.naming.security.principal">uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot</module-option>
          <module-option name="java.naming.security.credentials">password</module-option>
          <module-option name="baseDN">dc=company,dc=co,dc=uk</module-option>
          <module-option name="principalDNPrefix">uid=</module-option>
          <module-option name="principalDNSuffix">,ou=people,dc=company,dc=co,dc=uk</module-option>
          <module-option name="uidAttributeID">uid</module-option>
          <module-option name="searchScope">SUBTREE_SCOPE</module-option>
          </login-module>

          </application-policy>