Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何使用windows身份验证和注册自定义身份验证管理器_.net_Iis 7.5_Asp.net 4.0_Windows Authentication_Impersonation - Fatal编程技术网

.net 如何使用windows身份验证和注册自定义身份验证管理器

.net 如何使用windows身份验证和注册自定义身份验证管理器,.net,iis-7.5,asp.net-4.0,windows-authentication,impersonation,.net,Iis 7.5,Asp.net 4.0,Windows Authentication,Impersonation,我正在努力确保一个RESTFul服务 所有客户端都是windows intranet客户端,我想使用windows集成身份验证。作为初始实现,我希望对最终用户的凭据执行授权检查,并允许用户访问服务上的“读取”方法,以及允许用户访问服务到服务帐户上的“写入”方法。我正在经历一系列不同的问题,以使这些工作。我在不同的地方读过大量的文章,但到目前为止没有一篇占上风。 下面是web.config中应用程序的配置 <configuration> <system.web>

我正在努力确保一个RESTFul服务

所有客户端都是windows intranet客户端,我想使用windows集成身份验证。作为初始实现,我希望对最终用户的凭据执行授权检查,并允许用户访问服务上的“读取”方法,以及允许用户访问服务到服务帐户上的“写入”方法。我正在经历一系列不同的问题,以使这些工作。我在不同的地方读过大量的文章,但到目前为止没有一篇占上风。 下面是web.config中应用程序的配置

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Windows" />
    <identity impersonate="true" />
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
  </system.webServer>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <protocolMapping>
      <add scheme="http" binding="webHttpBinding" />
    </protocolMapping>
    <services>
      <service name ="SecureREST" behaviorConfiguration="RESTAuthorisationBehaviour">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="default" contract="Service.ISecureService">
        </endpoint>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="default">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="RESTAuthorisationBehaviour">
          <serviceAuthorization serviceAuthorizationManagerType="Security.RESTAuthorisationManager"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
我还尝试在windowsIndentity对象上调用Impersonate方法,但没有成功


那么,如何模拟经过身份验证的用户呢?

关于匿名身份验证的异常,请尝试在服务行为中禁用http get元数据,如下所示:

    <behavior name="MyServiceBehavior">
      <serviceMetadata httpGetEnabled="false" />
    </behavior>

    <behavior name="MyServiceBehavior">
      <serviceMetadata httpGetEnabled="false" />
    </behavior>