Hi ,


please let me know as to how to set the classpath for the system...when
using LDAP with java...I have LDAP installed LDAP cleint on my machine and
the server is on a different machine...


I am giving the code below...it is not getting compiled as the copilor is
not able to recognize the netscape.ldap.* package and also the LDAPException
class...

how do we import netscapes...ldap packages into java?

please tell me the solution for this,...

satish


import javax.servlet.*;
import javax.servlet.http.*;
import netscape.ldap.*;
import java.util.*;



public class ldap1 extends HttpServlet
{


boolean authed = false ;

String str = "SPakki " ;

String authpw = "admin" ;



public void init(ServletConfig sc) throws ServletException

{


super.init(sc);

}






public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, LDAPException
{


res.setContentType("text/html");
PrintWriter out = res.getWriter();



LDAPConnection ld = new LDAPConnection() ;

try
{

ld.connect("localhost", 386);


LDAPSearchConstraints cons = ld.getSearchConstraints()
;

cons.seyBatchSize(0);


LDAPSearchResults results = ld.search(baseDN, ld.SCOPE_SUB,
"uid = " + str , new String[ ] {ld.NO_ATTRS}, false, cons );


if( ! results.hasMoreElements() )
{

out.println(" uid not found");

}

else if(results.getCount() > 1)
{

out.println(" more than one matching
UID ");


}

else

{

LDAPEntry entry = results.next();

String authDN = entry.getDN();


out.println(" UID maps to " + authDN
);

ld.authenticate(authDN, authpw) ;

authed = true ;


}
}

catch(LDAPException e) { out.println( e.toString()
) ; }


if(ld != null && ld.isConnected())
{

try
{

ld.disConnect();

}

catch(LDAPException e) { out.println( e.toString()
) ; }


}


int rc = 0 ;

if( authed)
{
out.println(" Authenticated");

}
else
{
out.println(" Not Authenticated "
);

rc = 1 ;



}


}

}