我正在尝试使用自定义 ASP.NET MembershipProvider 和 RoleProvider 来处理我的服务的安全性。该服务自托管在控制台应用程序中,而不是在 IIS 中。我使用带有基本身份验证的 webHttpBinding。我将 serviceCredentials 和 serviceAuthorization 配置为使用提供程序。提供者真的被初始化了。但是 WCF 似乎忽略了我的设置并尝试将用户登录到 Windows。我从事件日志中发现了这一点,并通过将我的 Windows 凭据发送到服务来证明这一点。下面你可以看到我的配置和调试截图。为什么使用 windows 进行身份验证?也许没有 IIS 就不可能使用 ASP.NET 身份验证提供程序?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<roleManager
enabled="true"
defaultProvider="CustomRoleProvider">
<providers>
<clear/>
<add
name="CustomRoleProvider"
type="CustomRoles.CustomRoleProvider, CustomRoles"/>
</providers>
</roleManager>
<membership defaultProvider="CustomMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="CustomMembershipProvider"
type="CustomRoles.CustomMembershipProvider, CustomRoles"/>
</providers>
</membership>
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttp">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Service">
<serviceAuthorization principalPermissionMode="UseAspNetRoles"
roleProviderName="CustomRoleProvider" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="CustomMembershipProvider" />
</serviceCredentials>
<serviceSecurityAudit auditLogLocation="Application" serviceAuthorizationAuditLevel="SuccessOrFailure"
messageAuthenticationAuditLevel="SuccessOrFailure" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Service" name="CustomRoles.Service">
<endpoint address="http://127.0.0.1:8060" binding="webHttpBinding"
bindingConfiguration="webHttp" contract="CustomRoles.IService" />
</service>
</services>
</system.serviceModel>
</configuration>
这就是我在调试时看到的。为什么使用 windows 进行身份验证?