wcf wsHttpBinding 和禁用匿名访问

标签 wcf iis-6

http://blogs.msdn.com/drnick/archive/2007/03/23/preventing-anonymous-access.aspx

有人可以澄清是否可以在 WCF 中使用 wsHttpBinding 并在不需要传输 (ssl) 或消息安全性的情况下禁用 IIS 中的匿名访问?

最佳答案

你是对的,afaik 在你描述的场景中 wsHttpBinding 要求我们使用内部 WCF 安全堆栈。所以你通常会做的是

  • 启用匿名访问
  • 使用 创建 serviceBehavior
  • 使用 PrincipalPermissionAttribute 注释服务方法的每个具体实现,这是一个非常强大的工具,具有许多不同的选项来控制访问

  • 这对您来说是一个可以接受的解决方案吗,或者还有其他需要考虑的事情吗?

    基本示例:
    public class TestService : ITestService
    {
      [PrincipalPermission(SecurityAction.Demand, Name = "testdomain\\administrator")]
      public string DoWork()
      {   
        return "Hello World " + Thread.CurrentPrincipal.Identity.Name;
      }
    }
    
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WcfSecurity.Www.TestServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
              <serviceAuthorization principalPermissionMode="UseWindowsGroups" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service behaviorConfiguration="WcfSecurity.Www.TestServiceBehavior" name="WcfSecurity.Www.TestService">
            <endpoint address="" binding="wsHttpBinding" contract="WcfSecurity.Www.ITestService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>    
      </system.serviceModel>
    

    关于wcf wsHttpBinding 和禁用匿名访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/228268/

    相关文章:

    c# - 将字节数组从 PHP 发布到 .NET WCF 服务

    c# - 使用反射从 Soap Client 获取 Web 服务方法

    asp.net - 在 iis 6 上使用 .net 4 和 .net 2 出现 "Server Application Unavailable"错误

    iis - msdeploy IIS 6 到 7 迁移问题

    asp.net - IIS 回收与 ASP .NET 缓存

    .net - WCF 错误 MTOM 编码 + 从客户端向服务发送大数据

    c# - Monotouch 和 WCF : difference of SVCUTIL. EXE 和 SLSVCUTIL.EXE 以及如何避免不受支持的通用 ChannelFactory?

    asp.net-mvc - Autofac 错误 - 从请求实例的范围中看不到具有匹配 'AutofacWebRequest' 的标签的范围

    c# - WCF 中同一服务的两个端点,一个安全,一个不安全

    localization - asp 和 iis 6.0 从哪里得到它的日期格式