我有一个具有以下配置的 WCF 服务
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="CommonWindowsBinding" maxReceivedMessageSize="40000000">
<security mode="TransportWithMessageCredential" >
<transport clientCredentialType="None"/>
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="CommonBehavior" name="Megatec.MasterTourService.AdminService">
<endpoint address="Windows" binding="netTcpBinding" bindingConfiguration="CommonWindowsBinding" name="Megatec.MasterTourService.Contracts.IAdminServiceWindows" contract="Megatec.MasterTourService.Contracts.IAdminService">
<identity>
<dns value="WCFServer" />
</identity>
</endpoint>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="10000000" />
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="WCFServer" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Megatec.MasterTourService.Security.CustomUserNameValidator, Megatec.MasterTourService.Security" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
代码
public class AdminService : BaseAuthService, IAdminService
{
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public bool HasRole(string roleName)
{
//work with database
}
}
我在 IIS 7 上托管此服务,对于我设置域用户 (Master\MyLogin) 的应用程序池。我需要域用户进行委派(根据步骤 4)。
当我从本地客户端(同一台计算机,在 Master\MyLogin 或其他域用户下)使用服务时,它工作正常。但是当我尝试从另一台网络计算机使用服务时,它失败了。ApplicationPoolIdentity 一切正常。
Master\MyLogin 是具有服务的计算机上的管理员(但他不是域管理员)。
也许,应该授予 Master\MyLogin 的权限?
更新。客户端异常。
起初,有 SecurityNegotiationException。接下来,我添加了部分
<identity>
<userPrincipalName value="myLogin@Mydomain" />
</identity>
新异常是 MessageSecurityException。
The identity check failed for the outgoing message. The expected identity is "identity(http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn)" for the 'net.tcp://dev4-10:5012/IISTest/AdminService.svc/Windows' target endpoint.
我应该如何配置<identity>
客户端和服务?