Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 仅在Windows上的NTLM连接期间IOException身份验证失败_Java_Windows_Ntlm - Fatal编程技术网

Java 仅在Windows上的NTLM连接期间IOException身份验证失败

Java 仅在Windows上的NTLM连接期间IOException身份验证失败,java,windows,ntlm,Java,Windows,Ntlm,我有一段简单的代码试图通过NTLM身份验证连接到Windows Server。它可以在Linux、MacOS上运行,但不能在Windows 10上运行。在Windows上,它总是抛出java.io.IOException身份验证失败 public static void main(String[] args) throws IOException { Authenticator myAuth = new Authenticator() { @Override

我有一段简单的代码试图通过NTLM身份验证连接到Windows Server。它可以在Linux、MacOS上运行,但不能在Windows 10上运行。在Windows上,它总是抛出java.io.IOException身份验证失败

public static void main(String[] args) throws IOException {
    Authenticator myAuth = new Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication("domain\\myusername", "password".toCharArray());
        }
    };

    Authenticator.setDefault(myAuth);

    URL url = new URL("http://url.to.server");
    InputStream ins = url.openConnection().getInputStream();
    System.out.println("done");
}
这在url.openConnection()期间发生,并引发以下异常:

Exception in thread "main" java.io.IOException: Authentication failure
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1696)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at de.agentes.soap.client.demo.SoapClientDemoApp.main(SoapClientDemoApp.java:24)

有没有人有过这方面的经验?

您找到答案了吗?我也在想同样的。。。