WCF - IIS Windows 身份验证

发布于 2024-10-26 00:14:11 字数 2927 浏览 4 评论 0原文


我一直在尝试让我的 WCF 与 Windows 身份验证一起使用。当匿名打开时,以下工作正常。搜索了很多互联网文章,但无法使其发挥作用。谢谢

这是我的配置:
IIS
基本身份验证和 Windows 身份验证已打开。
匿名已关闭

客户端:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IEchoService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
                textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" establishSecurityContext="true" />
                </security>
            </binding>

        </wsHttpBinding>
    </bindings>

    <client>
        <endpoint address="http://id.unittest/Services/EchoService.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEchoService"
            contract="IEchoService" name="WSHttpBinding_IEchoService">
            <identity>
                <servicePrincipalName value="host/mikev-ws" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

服务器:

<system.serviceModel>

    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServiceTypeBehaviors">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="Project.API.Services.EchoService" behaviorConfiguration="MyServiceTypeBehaviors">
            <endpoint address="" binding="wsHttpBinding" contract="Project.API.Services.IEchoService" />
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

</system.serviceModel>

I have been trying to get my WCF to work with Windows Authentication. The following works fine when anonymous is turned on. Have searched many internet articles and cannot get this to work. Thanks

Here is my configuration:
IIS
Basic Authentication and Windows Authentication turned on.
Anonymous turned off

CLIENT:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IEchoService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
                textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" establishSecurityContext="true" />
                </security>
            </binding>

        </wsHttpBinding>
    </bindings>

    <client>
        <endpoint address="http://id.unittest/Services/EchoService.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEchoService"
            contract="IEchoService" name="WSHttpBinding_IEchoService">
            <identity>
                <servicePrincipalName value="host/mikev-ws" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

SERVER:

<system.serviceModel>

    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServiceTypeBehaviors">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="Project.API.Services.EchoService" behaviorConfiguration="MyServiceTypeBehaviors">
            <endpoint address="" binding="wsHttpBinding" contract="Project.API.Services.IEchoService" />
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

</system.serviceModel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花辞树 2024-11-02 00:14:11

在以下链接中:
WCF 错误:调用者未经过服务身份验证< /a>

寻找Sandip给出的答案,这是第二个答案。

in the following link:
WCF error: The caller was not authenticated by the service

look for the answer given by Sandip, its the second answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文