1

Windows認証を有効にしてIIS7セットアップでWebサイトを持っています。

私のサービスには 3 つの方法があり、2 つの方法では Windows 認証が必要で、1 つは必要ありません。使わない方が使っています

[OperationBehavior(Impersonation = ImpersonationOption.Allowed)]

他の2人が使っている

[OperationBehavior(Impersonation = ImpersonationOption.Required)]

私の web.config は次のようになります。

<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>
<security>
  <authentication>
    <anonymousAuthentication enabled="true"/>
    <windowsAuthentication enabled="true" />
  </authentication>
</security>


 </system.webServer>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceAuthorization impersonateCallerForAllOperations="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json" maxBufferPoolSize="2147483647"
                          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </standardEndpoint>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

[許可] に設定されているメソッドを実行しようとして、資格情報を渡さないと、認証されていないエラーで失敗します。私は何が欠けていますか?

4

1 に答える 1

0

使用するときは、資格情報を提供する必要があります [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]

許可: 資格情報が使用可能で、ImpersonateCallerForAllOperations が true の場合、偽装が実行されます。

ImpersonateCallerForAllOperations を false に設定してみましたか?

于 2012-07-09T23:13:20.430 に答える