我可以在他使用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/