As I had promised… this is a post about windows authentication in java.
We will use the JCIFS and u can download it here.

The authentication class
import java.net.UnknownHostException;
import jcifs.*;
import jcifs.smb.*;

public class Logon {
public boolean validaLogin(String host
, String dominio
, String usuario
, String senha) throws UnknownHostException {

UniAddress mydomaincontroller = UniAddress.getByName(host);
NtlmPasswordAuthentication mycreds = new NtlmPasswordAuthentication(dominio
+ “;”
+ usuario
+ “:”
+ senha);

try {
SmbSession.logon(mydomaincontroller, mycreds);
return true;
} catch (SmbAuthException sae) {
return false;
} catch (SmbException se) {
se.printStackTrace();
return false;
}
}
}

The main class
public class Main {
public static void main(String[] args) throws Exception {
Logon l = new Logon();
System.out.println(l.validaLogin(“hostip”,”domain”,”user”,”pass”));
}
}

It works very well…