到与服务器端用域用户进行身份验证:
代码
try {
UniAddress dc = UniAddress.getByName("192.168.10.229");
jcifs.smb.NtlmPasswordAuthentication auth = new jcifs.smb.NtlmPasswordAuthentication(
"192.168.10.229", "user", "password");
// jcifs.smb.SmbSession.getChallengeForDomain().
jcifs.smb.SmbSession.logon(dc, auth);
System.out.print("OK");
} catch (jcifs.smb.SmbAuthException e) {
String url = "domainlogin.jsp";
String msg = e.toString();
// request.setAttribute("errMsg", "密码或用户名错误");
// request.getRequestDispatcher(url).forward(request, response);
// json="{result:0}";
e.printStackTrace();
} catch (jcifs.smb.SmbException e) {
e.printStackTrace();
} catch(UnknownHostException e)
{
e.printStackTrace();
}
UniAddress dc = UniAddress.getByName("192.168.10.229");
jcifs.smb.NtlmPasswordAuthentication auth = new jcifs.smb.NtlmPasswordAuthentication(
"192.168.10.229", "user", "password");
// jcifs.smb.SmbSession.getChallengeForDomain().
jcifs.smb.SmbSession.logon(dc, auth);
System.out.print("OK");
} catch (jcifs.smb.SmbAuthException e) {
String url = "domainlogin.jsp";
String msg = e.toString();
// request.setAttribute("errMsg", "密码或用户名错误");
// request.getRequestDispatcher(url).forward(request, response);
// json="{result:0}";
e.printStackTrace();
} catch (jcifs.smb.SmbException e) {
e.printStackTrace();
} catch(UnknownHostException e)
{
e.printStackTrace();
}
要下载一个jcifs的jar文件。 jcifs-1.2.9.jar