gpt4 book ai didi

.net - 获取运行正在执行的 AppPool 的用户名

转载 作者:行者123 更新时间:2023-12-04 06:50:56 28 4
gpt4 key购买 nike

在 ASP.NET 或 WCF 中使用是否安全 ServiceSecurityContext.Current.WindowsIdentity.Name获取执行当前线程的当前用户名?

我想确保在我的 WCF 服务中模拟了正确的用户。

最佳答案

WindowsIdentity.GetCurrent().Name

可能是更好的选择,因为我不认为 ServiceSecurityContext.Current在 ASP.NET 中可用。

您可能还想考虑
Thread.CurrentPrincipal.Identity.Name

如果您关心用户而不是进程身份。

关于.net - 获取运行正在执行的 AppPool 的用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3141685/

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