[jcifs] Failed to negotiate with a suitable domain controller
Manikandan Chandrasekaran
mani.chandrasekaran at gmail.com
Tue Aug 22 08:56:18 GMT 2006
Hi,
I am new to jcifs. When I try connect using the following code, it
throws an exception saying
Failed to negotiate with a suitable domain controller for MYDOMAIN
at jcifs.smb.SmbSession.getChallengeForDomain(SmbSession.java:126)
at Jcifs.main(Jcifs.java:26)
But this doesn't happens always. Some times the same code connects to the
server without any changes. Can you please explain me the reason.
jcifs version : 1.2.9
My Code:
public class Jcifs {
public static void main(String args[]) {
boolean isSuccessful = false;
String domain = "MYDOMAIN";
String username = "MyUserName";
String password = "MyPassword";
try {
System.setProperty("jcifs.netbios.wins",
"192.168.151.151");
System.setProperty("jcifs.smb.client.domain", domain);
// method 1
//UniAddress dc = new UniAddress( NbtAddress.getByName(domain,
0x1c, null));
// method 2 (better)
NtlmChallenge chal = SmbSession.getChallengeForDomain();
UniAddress dc = chal.dc;
System.out.println("Test: found a domain controller:
hostaddress="
+ dc.getHostAddress() + ", hostname=" + dc.getHostName
());
SmbSession.logon(dc, new NtlmPasswordAuthentication(domain,
username, password));
isSuccessful = true;
} catch (SmbException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
}
System.out.println("Login : " + isSuccessful);
} // main
}
--
~~~~~~~~~~~~~~~~~~~~~~~~~
http://manikandanc.blogspot.com
-------------- next part --------------
HTML attachment scrubbed and removed
More information about the jcifs
mailing list