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

时间:2010-06-29 14:34:52

标签: .net asp.net wcf

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

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

1 个答案:

答案 0 :(得分:3)

WindowsIdentity.GetCurrent().Name

可能是一个更好的选择,因为我认为ASP.NET中没有ServiceSecurityContext.Current

您可能还想考虑

Thread.CurrentPrincipal.Identity.Name

如果您关心用户而不是进程标识。