[jcifs] Failed to negotiate with a suitable domain controller

Michael B Allen mba2000 at ioplex.com
Tue Aug 22 13:29:36 GMT 2006


getChallengeForDomain uses NetBIOS to lookup the list of domain
controllers using WINS. It then tries to connect and get a challenge
from each. If none of these requests succeed you get "Failed to
negotiate" message. The list returned can be different each time so
you might get different behavior depending on the health of your domain
controllers. Unfortunately NetBIOS and WINS are somewhat deprecated so
the technique is becomming somewhat unreliable. Either get a capture
[1] to figure out what WINS entries / DCs are responsible and talk to
your admins or use an explicit domain controller.

Also, if you're planning on using this code in some kind of HTTP filter
beware that it's not as simple as it looks because of the statelessness
of HTTP and you'll want to copy the existing Filter as much as possible.

Mike

[1] http://jcifs.samba.org/capture.html

On Tue, 22 Aug 2006 14:26:18 +0530
"Manikandan Chandrasekaran" <mani.chandrasekaran at gmail.com> wrote:

> 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
> 


-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/


More information about the jcifs mailing list