简体   繁体   English

使用基本身份验证调试本地WCF服务始终返回401-未经授权

[英]Debug local WCF service with Basic Authentication always returns 401 - Unauthorized

I have a problem accessing a .Net WCF Service that uses Basic authentication. 访问使用基本身份验证的.Net WCF服务时遇到问题。 The server's web.config file has the service configured as such: 服务器的web.config文件具有如下配置的服务:

<services>
  <service behaviorConfiguration="serviceBehavior" name="api.GlobalService">
    <endpoint address="" behaviorConfiguration="restBehavior" binding="basicHttpBinding"
      bindingConfiguration="Basic" contract="api.IGlobalService" />
  </service>
</services>

with the binding: 与绑定:

<bindings>
  <basicHttpBinding>
    <binding name="Basic">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Basic"/>
      </security>
    </binding>
  </basicHttpBinding>      
</bindings>

In my IIS Express config file I enabled basic authentication as such: 在我的IIS Express配置文件中,我启用了基本身份验证,如下所示:

<basicAuthentication enabled="true" />

I am running it in debug mode, on localhost, and I don't want a custom basic authentication, I want it to authenticate against Windows credentials. 我在本地主机上以调试模式运行它,并且我不需要自定义基本身份验证,而是希望它针对Windows凭据进行身份验证。 I access the server directly, from the browser, and enter my windows credentials when prompted, or from Postman using basic authentication and credentials, however I always get a 401. I am not authorized to access a server I run on my own machine with my own credentials. 我可以直接从浏览器访问服务器,并在出现提示时输入Windows凭据,也可以使用基本身份验证和凭据从Postman输入Windows凭据,但是我总是收到401。我无权访问我在自己的计算机上运行的服务器自己的凭证。 Any help on what I'm doing wrong? 对我做错了什么有帮助吗?

You can try the following, in the application that consumes the WCF Service 您可以在使用WCF服务的应用程序中尝试以下操作

WCFServiececlient.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
WCFServiececlient.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure App Service的本地调试版本中的身份验证导致401未经授权 - Authentication in local debug build of Azure App Service results in 401 Unauthorized 使用 HttpClient.GetAsync() 使用具有基本身份验证的 WCF REST 服务导致 (401) 未经授权 - Consuming a WCF REST service with Basic authentication using HttpClient.GetAsync() results in (401) Unauthorized 从自定义基本身份验证WCF中显示401未经授权的错误 - Show 401 unauthorized error from custom basic authentication wcf ASP.NET WebAPI 基本身份验证始终因 401/未授权而失败 - ASP.NET WebAPI Basic Authentication always fails as 401/Unauthorized 使用 JwtBearer 的 Ocelot 身份验证总是返回 401 Unauthorized - Ocelot Authentication using JwtBearer always returns 401 Unauthorized WCF Rest 自托管证书安全服务返回 401 未经授权 - WCF Rest self hosted certificate secured service returns 401 unauthorized 使用基本身份验证调用web api始终从IIS中获取401未授权 - Call web api with basic authentication always get 401 unauthorized from IIS Web API (.NET Framework) Azure AD 身份验证始终返回 401 Unauthorized - Web API (.NET Framework) Azure AD Authentication always returns 401 Unauthorized OData服务的Windows身份验证在C#应用程序中返回“ 401-未经授权”,但可在浏览器中使用 - Windows Authentication for OData service returns “401 - Unauthorized” in C# app, but works in browser Web API 基本身份验证始终未经授权 - Web API Basic authentication always unauthorized
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM