Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to integret JAVA for LDAP autentication?

Posted on 2008-06-22
6
Medium Priority
?
411 Views
Last Modified: 2010-05-18
We are having one internal application developed on JAVA. Now we want to Integrate autentication with existing windows 2003 Active directory. Is it possible to have ldap configured for authentication?
0
Comment
Question by:ktwoisg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 

Expert Comment

by:rameshsukka
ID: 21840135
We have open source LDAP API avaiable in market. You can use these API as Action Directory is V3 protocol. For more clarity,

Programatically you need to Bind to LDAP server with proper credentials. Let me know if you required any help on this.

Regards,
Ramesh Sukka.
0
 
LVL 4

Accepted Solution

by:
Meritor earned 500 total points
ID: 21841006
If you just need authentication from LDAP, there is a simpler way to it.
Just use JNDI. if you are able to create context then the user is authenticated, otherwise not
	Hashtable env = new Hashtable();
	env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
	env.put(Context.PROVIDER_URL, "ldap://ap.abc.com:389");//LDAP server location
	env.put(Context.SECURITY_AUTHENTICATION,"simple");
	env.put(Context.SECURITY_PRINCIPAL,"userName"); // specify the username
	env.put(Context.SECURITY_CREDENTIALS,"password"); // specify the password
	DirContext ctx = new InitialDirContext(env);
 
	System.out.println("CTX:"+ctx);

Open in new window

0
 

Author Comment

by:ktwoisg
ID: 21844061
Please let me know how to Bind to LDAP server with proper credentials.
0
 

Expert Comment

by:rameshsukka
ID: 21844389

look at the sample code from
http://java.sun.com/products/jndi/tutorial/ldap/security/ldap.html

// Set up the environment for creating the initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

// Authenticate as S. User and password "mysecret"
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=S. User, ou=NewHires, o=JNDITutorial");
env.put(Context.SECURITY_CREDENTIALS, "mysecret");

// Create the initial context
DirContext ctx = new InitialDirContext(env);

// ... do something useful with ctx


In above code,
S. user and password is "mysecret". After initializing content call ctx.bind() function

Regards,
Ramesh Sukka,
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question