修改启用 Silverlight 的 WCF 服务以使用 Windows 身份验证进行协作

发布于 2024-08-08 18:18:11 字数 2102 浏览 1 评论 0原文

我有一个 Silverlight 应用程序,并添加了启用 Silverlight 的 WCF 服务。我想使用 Windows 身份验证将其部署为 Intranet 解决方案,无需匿名访问。

开箱即用,WCF 服务将以下设置添加到 web.config:

<system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior name="WindowsAuthTest.Web.Service1Behavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
  <bindings>
   <customBinding>
    <binding name="customBinding0">
     <binaryMessageEncoding />
     <httpTransport />
    </binding>
   </customBinding>
  </bindings>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <services>
   <service behaviorConfiguration="WindowsAuthTest.Web.Service1Behavior"
    name="WindowsAuthTest.Web.Service1">
    <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
     contract="WindowsAuthTest.Web.Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>
 </system.serviceModel>

将此服务引用添加到 silverlight 项目时,这些设置将添加到 ServiceReferences.ClientConfig:

<system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="CustomBinding_Service1">
                    <binaryMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:3568/Service1.svc" binding="customBinding"
                bindingConfiguration="CustomBinding_Service1" contract="ServiceReference1.Service1"
                name="CustomBinding_Service1" />
        </client>
    </system.serviceModel>

如何修改这些设置以允许其使用Windows 身份验证和是否可以?

I have a Silverlight application, and added a Silverlight-enabled WCF service. I would like to deploy this as an intranet solution using Windows authentication without anonymous access.

Out of the box, the WCF service adds the following settings to the web.config:

<system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior name="WindowsAuthTest.Web.Service1Behavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
  <bindings>
   <customBinding>
    <binding name="customBinding0">
     <binaryMessageEncoding />
     <httpTransport />
    </binding>
   </customBinding>
  </bindings>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <services>
   <service behaviorConfiguration="WindowsAuthTest.Web.Service1Behavior"
    name="WindowsAuthTest.Web.Service1">
    <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
     contract="WindowsAuthTest.Web.Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>
 </system.serviceModel>

When adding this service reference to the silverlight project, these settings are added to the ServiceReferences.ClientConfig:

<system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="CustomBinding_Service1">
                    <binaryMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:3568/Service1.svc" binding="customBinding"
                bindingConfiguration="CustomBinding_Service1" contract="ServiceReference1.Service1"
                name="CustomBinding_Service1" />
        </client>
    </system.serviceModel>

How do I modify these settings to allow it to work with Windows authentication & is it possible?

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

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

发布评论

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

评论(1

凉墨 2024-08-15 18:18:11

尝试添加:

security mode="TransportCredentialOnly

例如,

<binding name="BasicHttpBinding_IUserWebService" maxBufferSize="2147483647"
           maxReceivedMessageSize="2147483647">
       <security mode="TransportCredentialOnly" />
</binding>

在 web.config 中我们使用 basicHttpBinding 例如

 <bindings>
      <basicHttpBinding>
        <binding name="customBasicHttpBinding" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>      
 </bindings>

Try adding:

security mode="TransportCredentialOnly

e.g.

<binding name="BasicHttpBinding_IUserWebService" maxBufferSize="2147483647"
           maxReceivedMessageSize="2147483647">
       <security mode="TransportCredentialOnly" />
</binding>

And in the web.config we use basicHttpBinding e.g.

 <bindings>
      <basicHttpBinding>
        <binding name="customBasicHttpBinding" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>      
 </bindings>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文