且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用客户端身份验证方案"Ntlm"对HTTP请求进行了未授权.从服务器收到的身份验证标头为"NTLM"

更新时间:2023-09-12 18:03:28

经过反复的尝试,然后停滞了一段时间,而我等待机会与我们的服务器人员交谈,我终于有机会讨论了他们的问题,问他们是否不介意将我们的Sharepoint身份验证切换到Kerberos.

After a lot of trial and error, followed by a stagnant period while I waited for an opportunity to speak with our server guys, I finally had a chance to discuss the problem with them and asked them if they wouldn't mind switching our Sharepoint authentication over to Kerberos.

令我惊讶的是,他们说这不是问题,实际上很容易做到. 他们启用了Kerberos ,我按如下所示修改了我的app.config:

To my surprise, they said this wouldn't be a problem and was in fact easy to do. They enabled Kerberos and I modified my app.config as follows:

<security mode="Transport">
    <transport clientCredentialType="Windows" />
</security>

作为参考,我在app.config中的完整serviceModel条目如下所示:

For reference, my full serviceModel entry in my app.config looks like this:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="TestServerReference" closeTimeout="00:01:00" openTimeout="00:01:00"
             receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
             bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
             maxBufferSize="2000000" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
             messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
             useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                 maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://path/to/site/_vti_bin/Lists.asmx"
         binding="basicHttpBinding" bindingConfiguration="TestServerReference"
         contract="TestServerReference.ListsSoap" name="TestServerReference" />
    </client>
</system.serviceModel>

在此之后,一切都变得像魅力.现在,我可以(终于!)利用Sharepoint Web服务.因此,如果其他任何人都无法使他们的Sharepoint Web服务与NTLM一起使用,请查看您是否可以说服系统管理员切换到Kerberos.

After this, everything worked like a charm. I can now (finally!) utilize Sharepoint Web Services. So, if anyone else out there can't get their Sharepoint Web Services to work with NTLM, see if you can convince the sysadmins to switch over to Kerberos.