hi,
You can use classes in the javax.naming.directory package to access Active Directory.
The following code is taken from our app which checks an AD server. You can adapt it to your needs. You must import javax.naming.* and javax.naming.directory.*
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;
take a look this commercial solution : http://www.datadirect.com/developer/jdbc/topics/winauth/index.ssp
hth
Thank you for your reply. Unfortunately, I still have questions.
Are the tokens written in red caps to be altered based on my setup? I would assume so, but I would be worried about storing cleartext passwords in the class files.
Once the authentication via AD (I think that's just a glorified LDAP, right?), I should be able to connect to the database like normal, right?
Thanks again for your help. Unfortunately, I think I'm biting off more than I can chew.