authentication using JNDI
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   varun_dhir
Posted On:   Tuesday, December 11, 2001 04:48 AM


I need to authenticate users from ADSI using JNDI. But in my application, the user enters his mail-id ("mail" in ADSI terms) and his password to enter the application and not the "cn" . Is there a way to authenticate a user using his mail-id and the password?


I have tried using "sAMAccountName" or "mail" along with the password for authentication but it throws an exception.

Re: authentication using JNDI

Posted By:   Jayaram_S  
Posted On:   Sunday, February 3, 2002 11:16 PM

While authenticating , give the DN of the user and the password.

Re: authentication using JNDI

Posted By:   Kullervo_Kala  
Posted On:   Monday, January 28, 2002 04:07 AM

If mail-id is unique attribute just seach user object from directory whose mail-id
is equivalent. Then get the distinguished name according to that.


There are plenty of unique attributes in AD (userPrincipalName, samAccountName,...) that you can use
as login id.


To get user's relative distinguished name when you know eq. samAccountName
call following function.


String userRDN = getUSerRDN("samAccountName","Raipe");


Note that m_Ctx is your existing LdapContext...



public String getUserRDN(String uniqueAtt,String user) throws NamingException{
String ret;
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
constraints.setReturningAttributes(new String[0]); // we are interested in rdn only
String searchCondition = "(" + uniqueAtt + "=" + user + ")";

NamingEnumeration results = m_Ctx.search("", searchCondition, constraints);
if (results != null && results.hasMoreElements()) {

// returning first (and only)
SearchResult si = (SearchResult)results.nextElement();
ret = si.getName();

} else
throw new NamingException(" Cannot find RDN ");


return ret;
}

What java VM your using,from SUN or MS?

Posted By:   Xin_Li  
Posted On:   Wednesday, December 12, 2001 01:11 PM

I want to authenticate people against Active Directory for user in Windows 2000 domain. User login from web page and get authenticate if they have their user name and password in Windows 2000 domain
About | Sitemap | Contact