c# - 来自 WCF 请求的 IPrincipal

标签 c# .net wcf security wcf-security

我可以在他使用WCF服务时获取请求者窗口IPrincipal吗?

最佳答案

使用此代码,您可以检查 WCF 服务中的当前安全上下文。

如果用户已通过身份验证,并且 WindowsPrincipal 不为空,那么您正在使用 Windows 安全模型 - 您可以访问所有相关信息:

ServiceSecurityContext current = ServiceSecurityContext.Current;

if (!current.IsAnonymous && current.WindowsIdentity != null)
{
    string userName = current.WindowsIdentity.Name;
}

关于c# - 来自 WCF 请求的 IPrincipal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/992997/

相关文章:

c# - 如何从泛型中获取 bool 值作为返回对象

c# - 帮助我在 WCF 服务中选择实例管理

c# - P2P 真的是无服务器的吗?

c# - 在.Net2.0网站中使用LinqBridge

c# - .NET 中多次调用的 StringComparer.CurrentCultureIgnoreCase 效率

c# - WPF 中的内部 'border'

c# - 重新启动具有依赖服务的服务?

.net - 从 .NET 使用 Python COM 服务器

c# - WCF如何创建连接到同一个服务实例的两个 channel

c# - 在 C# 中使用值参数模拟模板