Pav*_*nin 5 asp.net security impersonation windows-identity current-principal
我启用了模拟和Windows身份验证.
<authentication mode="Windows" />
<identity impersonate="true" userName="name" password="passord"/>
Run Code Online (Sandbox Code Playgroud)
但返回经过身份Thread.CurrentPrincipal.Identity.Name验证的用户的名称并WindowsIdentity.GetCurrent()返回模拟身份.
这些身份不应该相同吗?
在这种情况下,代码运行的凭据是什么?
And*_*bov 10
据我所知,它Thread.CurrentPrincipal包含了线程已启动的条件信息,包括WindowsIdentity.这就是为什么Thread.CurrentPrincipal.Identity.Name返回启动该线程的用户的名称.相反,WindowsIdentity.GetCurrent()返回一个WindowsIdentity对象,该对象表示当前Windows用户,该用户已通过Impersonation进行了更改.我不是100%肯定它,但这就是我认为它的工作原理.