且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取登录用户

更新时间:2022-05-14 08:10:31

Thread.CurrentPrincipal.Identity将执行与HttpContext.CurrentContext...

它将返回与当前执行线程关联的身份,在大多数情况下,该身份是登录的用户*.

It will return the identity associated with the current executing thread, which in most cases, is the logged on user*.

注意:*如果您使用委派/模拟或作为服务帐户运行,它将返回该线程所使用的身份的帐户,但是在您的情况下,听起来好像您在执行任何上下文操作身份切换.

Note: *If you are using delegation/impersonation or running as a service account, it will return the account of which ever identity the thread is under, but in your case, it doesn't sound like you are doing any context identity switching.