Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Liutauras Vilda
Paul Clapham
paul wheaton
Sheriffs:
Tim Cooke
Devaka Cooray
Rob Spoor
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Forum:
Servlets
Websphere & LDAP servlet
Joe Bond
Greenhorn
Posts: 5
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Does anyone have any introspection on where to start with a
servlet
using websphere to connect to ldap? Thanks in advance.
JOE
Anonymous
Ranch Hand
Posts: 18944
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I use ldapjdk.jar or ldap40.jar of netscape to connect my
jsp
to Directory Server.
Sample to authenticate
import java.util.Hashtable; import java.util.Enumeration; import javax.naming.*; import javax.naming.directory.*; import netscape.ldap.*; ... public static boolean authenticate(String uid,String pwd) { boolean status = false; LDAPConnection ld = new LDAPConnection(); LDAPEntry findEntry = null; String dn = null; String MY_HOST = "MyMachine"; int MY_PORT = 389; String MY_SEARCHBASE = "ou=People,o=wokup"; String MY_FILTER = "uid=" + uid; try { ld.connect( MY_HOST, MY_PORT ); String[] myAttrs = null; LDAPSearchResults res = ld.search(MY_SEARCHBASE,LDAPConnection.SCOPE_SUB,MY_FILTER,myAttrs,false); // more than 1 user matching filter, fail. System.out.println("getCount is "+res.getCount()); if (res.getCount() != 1) { return false;} if (res.hasMoreElements()) { findEntry = res.next(); dn = findEntry.getDN(); System.out.println("dn is " + dn); //prevent anonymous connections if ((dn == "") | | (pwd == "")) { return false;} //now attempt to bind to server ld.authenticate(dn,pwd); //if ld.authenticate doesn't throw an exception we passed status = true; } } catch(LDAPException e) { System.out.println(e.toString()); } catch(Exception x) { x.printStackTrace(); } return status; } ...
[This message has been edited by Pierre-Fran�ois Lemosquet (edited August 24, 2001).]
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Alternate LDAP for WebSphere
Ldap Qs
SECJ0153E: Invalid LDAP user ID
LDAP in form based authentication
Is LDAP integrated with WebSphere5.1 already?
More...