Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Authonticate against Active Directory

Status
Not open for further replies.

Rajesh99

Programmer
Mar 17, 2003
43
0
0
US
I have my application on Solaris with Tomcat. Now I want to do following things:

when this application starts prompt user for his user name/password, if they typed these matching the ones in Active Directory (the users run this application on window XP on company's hosted active directory) then user should be allowed in to run the application. This is an extra layer of protection - as if someone left his computer on, no one in his absence should be able to use it since he was logged in first at the begin of day etc.

Really I am looking for a way to authintiacte a user against Active Directory usernames/password then creating another list of Oracle users in our database. I have following code but does not work, do I need to do some changes in Tomcat to make it work. I am totally in new area here,help.:


<%@ page import="javax.naming.*" %>
<%@ page import="javax.directory.*" %>
<p><h1>Network Windows USERNAME without any login (ie)</h1></p>
<%
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL,
"ldap://" + getProperty("SERVER") + ":" +
getProperty("PORT"));

env.put(Context.SECURITY_PRINCIPAL,
getProperty("USER_RDN") + "," +
getProperty("BASE_DN"));
env.put(Context.SECURITY_CREDENTIALS,
getProperty("USER_PASSWORD"));

DirContext ctx = new InitialDirContext(env);

ctx.getAttributes(getProperty("BASE_DN"));

ctx.close();

info("connection_succeeded");
}
catch (CommunicationException comEx)
{
error(MessageResource.getMessage("communication_exception",
comEx.getMessage()));
return false;
}
catch (AuthenticationException authEx)
{
error(MessageResource.getMessage("authentication_exception",
authEx.getMessage()));
return false;
}
catch (NamingException nameEx)
{
error(MessageResource.getMessage("naming_exception",
nameEx.toString()));
return false;
}

return true;

%></BODY>

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top