无法使用NTLM身份验证在sharepoint中连接

时间:2017-04-20 09:36:49

标签: java sharepoint ntlm

我试图建立与sharepoint的连接,但之前从未接触过。我发现此代码可以进行身份​​验证,但它不起作用。

我在一家拥有代理权的公司。

我相信我是SharePoint中的普通用户(不确定)。

SharePoint就像这样:https://company.sharepoint.com(替换公司的真实姓名)

我做错了什么?

CODE:

public class Main {
    public static void main(String[] args) throws Exception {
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        System.out.println(credsProvider.toString());
        credsProvider.setCredentials(new AuthScope(AuthScope.ANY),
                new NTCredentials("me@company.com",
                        JOptionPane.showInputDialog(null, "Password", ""), "https:\\company.sharepoint.com",workstation));/*--------this-------*/
        System.out.println(credsProvider.toString());
        CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
        System.out.println(httpclient.toString());
        try {
            HttpGet httpget = new HttpGet("https:\\company.sharepoint.com/_vti_bin/Lists.asmx");
            System.out.println(httpget.toString());
            System.out.println("Executing request " + httpget.getRequestLine());
            CloseableHttpResponse response = httpclient.execute(httpget);
            System.out.println(response.toString());
            try {
                System.out.println("----------------------------------------");
                System.out.println(response.getStatusLine());
                EntityUtils.consume(response.getEntity());
            } finally {
                response.close();
            }
        } finally {
            httpclient.close();
        }

    }

}

我还应该在工作站上放什么?

错误:

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connect to company.sharepoint.com:443 [company.sharepoint.com/150.151.150.152] failed: Connection timed out: connect
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at Main.main(Main.java:29)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    ... 10 more

0 个答案:

没有答案