Questions tagged [current-principal]

Question related to the .net Thread implementation about the current principal.

Question related to the .net Thread implementation about the current principal for role-based security.

See also the MSDN about Thread.CurrentPrincipal Property

18 questions
15
votes
4 answers

Setting Thread.CurrentPrincipal with async/await

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…
14
votes
2 answers

Thread.CurrentPrincipal.Identity vs HttpContext.User.Identity

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…
bevacqua
  • 43,414
  • 51
  • 157
  • 277
9
votes
1 answer

Security, Thread.CurrentPrincipal, and ConfigureAwait(false)

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…
6
votes
1 answer

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

I enabled impersonation and Windows authentication. But Thread.CurrentPrincipal.Identity.Name returns the name of authenticated user and…
3
votes
0 answers

Where should Thread.CurrentPrincipal and HttpContext.Current.User get set when using a custom Principal

I created a custom class that inherits from IPrincipal and would like to make sure this object is added to the Thread.CurrentPrincipal and HttpContext.Current.User instead of the ClaimsPrincipal object. This is for a web api application. I would…
user1790300
  • 2,245
  • 6
  • 36
  • 97
3
votes
2 answers

CurrentPrincipal.Identity.Name is blank

I'm trying to use System.Threading.Thread.CurrentPrincipal.Identity.Name to get the login of who is using an ASP.NET application. I'm not getting any build errors, but it returns a blank value. I'm using IIS 6 and here are my authentication…
user3062114
  • 119
  • 1
  • 3
  • 12
3
votes
1 answer

Thread.CurrentPrincipal is reset to default GenericPrincipal

During initializing my application I set the System.Threading.Thread.CurrentPrincial. But after the application is initialized and I want to access to this Principal, the CurrentPrincipal contains again the default GenericPrincipal. Anyone an idea…
rhe1980
  • 1,537
  • 1
  • 14
  • 34
3
votes
2 answers

In .NET, System.Threading.Thread.CurrentPrincipal is the same for different threads

I'm looking for some general approach to store my JWT token on the server side for different users. I decided to store that data in Thread.CurrentPrincipal. But when i tested it i saw, that different clients have access to the same…
aturch
  • 53
  • 2
  • 8
2
votes
1 answer

is System.Threading.Thread.CurrentPrincipal shared between all users?

I intend to use currentprincipal and I searched that the property is static , so it must be shared, Actually I need it to be different not shared. as I write some code I see the currentprincipal is different after 2 users logged in to application,…
user3565932
1
vote
1 answer

In .NET, System.Threading.Thread.CurrentPrincipal isn't updating

I'm missing something elementary here when debugging some .NET code: public static void CreateServiceSessionStore() { ServiceSessionStore serviceSessionStore = new ServiceSessionStore(); …
Beska
  • 11,976
  • 14
  • 73
  • 108
1
vote
0 answers

Identity using Thread.CurrentPrincipal vs HttpContext.Current.User

I know that this topic might have some duplicated questions here but i'm still confused. I'm having a very weird case with Thread.CurrentPrincipal.Identity and HttpContext.Current.User.Identity. I have a userIdentity.cs class where i rely on…
1
vote
1 answer

Is Thread.CurrentPrincipal reliable using OWIN authentication and Web API?

Prior to MVC5 I've heard of / been able to reproduce an issue in the past where the Thread.CurrentPrincipal is not always set correctly when using async operations. Here's one blog post that discusses the issue:…
1
vote
2 answers

Why Thread.CurrentPrincipal.Identity.IsAuthenticated is always false?

I have this WCF service and I'm trying to apply authentication and authorization mechanism in it. It's my first time to do this, what I have is this web.config serviceModel tag for the service:
Dabbas
  • 2,622
  • 6
  • 35
  • 64
1
vote
0 answers

Thread.CurrentPrincipal gets lost after upgrading to to .NET 4.5.1

I've tried to research this error, but I have not found any useful information on it. We have a ASP.NET Web Api 1.0 application that was using .Net 4. We upgraded it to .Net 4.5.1, MVC 5, Web Api 2 and found an issue where we were assigning the…
WillHart
  • 65
  • 6
0
votes
1 answer

.net core 5.0 CurrentPrincipal resets value

I have a .net core 5.0 application that requires extra certificate validation and based on the certificate I get certain roles in db. I store those as Claims in either Thread.CurrentPrincipal or HttpContext.User. But both of those get their default…
Calin956
  • 5
  • 5
1
2