且构网

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

HTTP 请求未经授权使用客户端身份验证方案“Ntlm" 从服务器收到的身份验证标头是“NTLM"

更新时间:2021-11-24 00:42:56

经过多次尝试和错误,然后我等待机会与我们的服务器人员交谈的停滞期,我终于有机会讨论并询问他们是否不介意将我们的 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.