Hi,

I am trying to access an LDAP server using JNDI. I managed to get the
code to work standalone. But when i try to run it as a servlet (
i am using JavaWebServer with JDK1.2.2 and JSDK 2.1) i get the
following NamingException.

Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory

The snippet of code is given below.

Thanks for your time
Sai

---------------------Code Snippet --------------------------------
public void init() {
       env = new Hashtable(5, 0.75f);
      env.put(Context.INITIAL_CONTEXT_FACTORY,
                "com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.PROVIDER_URL, "ldap://directory.company.com:389");
      nineYards = new Vector(10);
      spacer = "";

      try {
        ctx = new InitialDirContext(env);
        constraints = new SearchControls();
        constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
        }
      catch (NamingException e) {
        System.err.println("NamingException: " + e.getExplanation());
         e.printStackTrace();
      }
   }

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to