current-principal

Why do Thread.CurrentPrincipal.Identity and WindowsIdentity.GetCurrent() differ when impersonation is turned on?

自闭症网瘾萝莉.ら 提交于 2019-12-09 00:01:24
问题 I enabled impersonation and windows authentiaction. <authentication mode="Windows" /> <identity impersonate="true" userName="name" password="passord"/> But Thread.CurrentPrincipal.Identity.Name returnes the name of authenticated user and WindowsIdentity.GetCurrent() returns impersonated identity. Shouldn't these identities be the same? And under wich credentials does the code run in this case? 回答1: As far as I can understand the Thread.CurrentPrincipal contains the information of conditions

Security, Thread.CurrentPrincipal, and ConfigureAwait(false)

点点圈 提交于 2019-12-04 11:20:43
问题 Would using Thread.CurrentPrincipal's claims in a referenced library that uses ConfigureAwait(false) pose any problems or will the flowing of ExecutionContext's logical call context take care of me there? (my reading and testing so far indicates that it will). Example WebAPI Controller Action: [CustomAuthorizeThatSetsCurrentUsersClaimsToThreadCurrentContextAndHttpContextCurrentUser] public async Task<Order> Get(int orderId) { return await _orderBusinessLogicLibrary.LoadAsync(orderId); //

Thread.CurrentPrincipal.Identity vs HttpContext.User.Identity [duplicate]

拟墨画扇 提交于 2019-12-04 03:01:44
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: difference between http.context.user and thread.currentprincipal and when to use them? What's the difference between these two in an ASP.NET application? I know the HttpContext.User.Identity is set when the user is authenticated through FormsAuthentication . But when is the Thread.CurrentPrincipal.Identity set? Do they always hold the same value? Does that still hold true for other layers of the application that

Setting Thread.CurrentPrincipal with async/await

雨燕双飞 提交于 2019-12-04 00:59:07
问题 Below is a simplified version of where I am trying to set Thread.CurrentPrincipal within an async method to a custom UserPrincipal object but the custom object is getting lost after leaving the await even though it's still on the new threadID 10. Is there a way to change Thread.CurrentPrincipal within an await and use it later without passing it in or returning it? Or is this not safe and should never be async? I know there are thread changes but thought async/await would handle synching this

Security, Thread.CurrentPrincipal, and ConfigureAwait(false)

只谈情不闲聊 提交于 2019-12-03 08:02:26
Would using Thread.CurrentPrincipal's claims in a referenced library that uses ConfigureAwait(false) pose any problems or will the flowing of ExecutionContext's logical call context take care of me there? (my reading and testing so far indicates that it will). Example WebAPI Controller Action: [CustomAuthorizeThatSetsCurrentUsersClaimsToThreadCurrentContextAndHttpContextCurrentUser] public async Task<Order> Get(int orderId) { return await _orderBusinessLogicLibrary.LoadAsync(orderId); // defaults to .ConfigureAwait(true) } Example load functions from external, referenced library:

Thread.CurrentPrincipal.Identity vs HttpContext.User.Identity [duplicate]

冷暖自知 提交于 2019-12-01 15:08:41
Possible Duplicate: difference between http.context.user and thread.currentprincipal and when to use them? What's the difference between these two in an ASP.NET application? I know the HttpContext.User.Identity is set when the user is authenticated through FormsAuthentication . But when is the Thread.CurrentPrincipal.Identity set? Do they always hold the same value? Does that still hold true for other layers of the application that do not have access to a HttpContext ? HttpContext.User.Identity is the current logged in user in your web app. Thread.CurrentPrincipal applies only when the

Why do Thread.CurrentPrincipal.Identity and WindowsIdentity.GetCurrent() differ when impersonation is turned on?

痞子三分冷 提交于 2019-11-30 15:35:34
I enabled impersonation and windows authentiaction. <authentication mode="Windows" /> <identity impersonate="true" userName="name" password="passord"/> But Thread.CurrentPrincipal.Identity.Name returnes the name of authenticated user and WindowsIdentity.GetCurrent() returns impersonated identity. Shouldn't these identities be the same? And under wich credentials does the code run in this case? Andrei Zubov As far as I can understand the Thread.CurrentPrincipal contains the information of conditions the thread has been started with, including the WindowsIdentity. That's why Thread