gpt4 book ai didi

c# - 来自 WCF 请求的 IPrincipal

转载 作者:太空狗 更新时间:2023-10-30 01:12:11 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com