aspose file tools*
The moose likes Java in General and the fly likes Using Kerberos authentication for authenticating through Domain controller in 2008 environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using Kerberos authentication for authenticating through Domain controller in 2008 environment" Watch "Using Kerberos authentication for authenticating through Domain controller in 2008 environment" New topic
Author

Using Kerberos authentication for authenticating through Domain controller in 2008 environment

Divya Deshpande
Greenhorn

Joined: Aug 13, 2013
Posts: 2
Hi all,

Currently my application is authenticating using NTLM authentication. It authenticates using a Domain Contoller which was residing on 2003 server. Now since it is migrated to 2008, my current NTLM authentication is not working.
I suppose that this would require Kerberos authentication. (Correct me if I am wrong)

My current code with NTLM authentication looks like this. If I just try to replace sPDC value with new server name, it doesnt work. I found several code on net, but did not understand the refrrence. Can anyone provide the easiest way to move to Kerberos with minimal changes in below code.

Note:- I have hard coded few values for easier understanding. Though original code take username, password in form of arguements.




import java.io.IOException;
import java.util.Hashtable;
import java.util.Properties;
import com.linar.jintegra.NTLMAuthenticate;

public class ADAuthenticate
{
private static String sPDC1;
private static String sPDC2;
private static String sPDC3;

public static void main(String[] args)
{
try
{
NTAuthenticate("domainname", "username", "password");
}
catch (SecurityException se)
{

System.out.println(se.getMessage());
}
catch (PDCNotFoundException nfe)
{
System.out.println("Cannot authenticate the user. Unable to find a domain controller.");
}

}


public static void NTAuthenticate(String sDomain, String sUsername, String sPassword) throws SecurityException, ADAuthenticate.PDCNotFoundException
{
try {
sDomain = "domainname";
NTLMAuthenticate.validate(sPDC1, sDomain, sUsername, sPassword);

}
catch (IOException ioe)
{
System.out.println(String.valueOf(new StringBuffer("The First PDC (").append(sPDC1).append(") failed to communicate.")));
try {
NTLMAuthenticate.validate(sPDC2, sDomain, sUsername, sPassword);
}
catch (IOException ioe2)
{
System.out.println(String.valueOf(new StringBuffer("The Second PDC (").append(sPDC2).append(") failed to communicate.")));
try {
NTLMAuthenticate.validate(sPDC3, sDomain, sUsername, sPassword);
}
catch (IOException ioe3)
{
System.out.println(String.valueOf(new StringBuffer("The Third and Final PDC (").append(sPDC3).append(") failed to communicate.")));
throw new PDCNotFoundException();
}
}
}
}

static
{
try
{
Properties p = new Properties();

sPDC1 = "domaincontrollername";
sPDC2 = p.getProperty("auth.pdc2");
sPDC3 = p.getProperty("auth.pdc3");
}

catch (Exception pe)
{
pe.printStackTrace();
System.out.println("Properties file </conf/authenticate/authenticate.properties> not found.");
}
}

public static class PDCNotFoundException extends Exception
{
}
}
Divya Deshpande
Greenhorn

Joined: Aug 13, 2013
Posts: 2
Hi all..Any updates on this? I did not find anything much in above url...
 
Consider Paul's rocket mass heater.
 
subject: Using Kerberos authentication for authenticating through Domain controller in 2008 environment