0

我正在尝试使用 ServiceSecurityContext.Current.WindowsIdentity.Name 在客户端获取服务凭据。但是,ServiceSecurityContext.Current 显示为空。

服务和客户端使用 Windows 身份验证、消息安全模式和 wsHttpBinding。非常感谢您的帮助..谢谢。

4

1 回答 1

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

使用此类在运行时获取有关远程安全上下文的信息。当客户端成功验证并授权访问方法时,将创建安全上下文。当消息成功认证和授权后,可以从该类的实例中获取来自客户端和当前服务实例的安全信息

于 2012-06-20T05:46:53.407 回答