2012-06-20 125 views
0

我正在尝试通过使用 ServiceSecurityContext.Current.WindowsIdentity.Name来获取客户端的服务凭据。 但是,ServiceSecurityContext.Current作为null出现。在客户端获取服务凭据

该服务和客户端正在使用Windows身份验证,消息安全模式和wsHttpBinding。你的帮助是非常appriciated ..谢谢。

+0

你们是不是在服务器或服务器证书获取客户端证书获得来自客户和当前服务实例的安全 信息在客户端? – Anand

回答

0

如果你试图在客户端获得服务器的证书,那么你可能会做一些错误的事情。 如果你正在做它的其他明智的,你必须使用以下设置

BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);    
basicHttpBinding.Security.Transport.ClientCredentialType =HttpClientCredentialType.Windows;     
reportService = new ReportingService2005SoapClient(basicHttpBinding, new EndpointAddress(reportServerUrl)); 
reportService.ClientCredentials.Windows.AllowNtlm = false; 
reportService.ClientCredentials.Windows.AllowedImpersonationLevel =   TokenImpersonationLevel.Impersonation; 
reportService.ChannelFactory.Credentials.Windows.ClientCredential = 
        CredentialCache.DefaultNetworkCredentials; 

编辑

MSDN

使用这个类来获得关于在运行一个远程安全上下文 信息。当客户端 成功通过身份验证并授权访问方法时,会创建安全上下文。当成功验证和授权的 消息,可以 从这个类的一个实例

+0

谢谢阿南德的及时回复。 – Mallya

+0

现在我感到困惑了......我可能已经理解了这个概念完全错误。虽然不知道.. 让我解释我的理解是什么.. 在WCF中,当我们谈论身份验证时,它总是相互身份验证。客户端将自身认证为服务,服务将自身认证给客户端。当相互认证成功时,ServiceSecurityContext对象将被填充在客户端和服务端。在客户端,它将拥有服务器凭证,在服务端将拥有客户端凭证。 – Mallya

+0

所以要购买这个,我应该能够访问客户端的服务凭据。 请让我知道如果我工作... – Mallya

相关问题