Here's some OLD code (I've refined it over the years) that will basically do the trick.
If the returned value is null, then the data (url, user, password) failed to validate for some reason. Obviously you want to replace the "xxxxxx" with the actual container name in your tree. This example hard-codes the port number, but you can easily modify it to take the port as a parameter in case you want to override it. The "String credents = ..." was set up to force a password; the directory may define default access and allow users in w/out authentication. This prevents them from bypassing default authentication by putting in a dummy password [that will fail] if they don't supply one. The "DirContext" object can be used to search the directory for whatever you're looking for. If all you care about is authentication, then you can change it to return etiher "true" [if everything works] or "false" [otherwise]. It's fairly easy to modify this to support secure LDAP if that is needed. [ November 05, 2003: Message edited by: Wayne L Johnson ]
posted 16 years ago
Wayne, Thank you very much, it works perfectly. I have another question: how can I get a parameter from NDS? Should I use the ".getAttributes()" method? Thanks.