ldap / active directory

F

Franck

Hi,

I can authenticate a user in Active directory with this code :

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://thales:389/");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL,
"CN=flefebure,OU=Informatique,OU=MS,OU=GP,DC=OC,DC=GP");
env.put(Context.SECURITY_CREDENTIALS, "xxxxxx");
env.put("java.naming.ldap.version", "3");
env.put(Context.REFERRAL, "follow");

context = new InitialContext(env);

It works,
But it supposes that I know the exact dn of the user I want to authenticate

On many tools (ldap browser) I just need to put base ta part of the base DN
: DC=OC,DC=GP
and a user dn like this : "oc\flefebure" (my domain is OC)

And the authentification is OK ...

I can't find the java code to authenticate myself programmaticaly just with
"oc\flefebure"

Some help ?

Thanks
 
M

mike

It probably binds with a system/anonumous user, and the does a lookup
where uid=flefebure. WHat you're doing is the std way to do it.
 
F

Franck

mike said:
It probably binds with a system/anonumous user, and the does a lookup
where uid=flefebure. WHat you're doing is the std way to do it.

I don't think, because when I connect as anonymous to this AD, I can't
access
the branch where users are listed.

And the tools I mentionned are standard (not microsoft)
like http://www.iit.edu/~gawojar/ldap/

.... I will try to read this browser code to understand the binding
procedure.

Bye
 
F

Franck

Found a solution :
env.put(Context.PROVIDER_URL, "ldap://thales:389/");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "oc\\flefebure");
env.put(Context.SECURITY_CREDENTIALS, "xxxxxx");

where "oc" is my domaine name

and it's ok ...
so easy ......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top