到与服务器端用域用户进行身份验证:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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