-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impersonation with async tasks #32
Comments
Hmmm... Despite the discussion on the corefx issue, I can't repro this. I've added a test at |
yes, it passes. This occured on my side when leaving the ASP.NET MVC application idle for a while. First, everything works as expected. After a while the connection to SQL-Server gets dropped and after that the error comes up. The following connection to SQL-Server is not under the impersonated user but using the ApplicationPoolIdentity (or whatever user the AppPool is using). |
Can we confirm few things. Where this doesn't work? Full .Net Framework or .Net Core only? ASP.NET or Desktop applications? In case of ASP.NET, if I remember correctly, there are few more settings that may cause you issues. |
I would just like to add that when I was using 2.0.1 I ran into this issue. I was using async methods SQL connections to execute SQL commands within the impersonation block. Only when multiple different users were using the service at the same time did I run into the log showing others connecting to SQL connections using other people's impersonated threads. FWIW, this is what I was using before (simplified) that presented the issue:
Tried all things mentioned in Readme and threads (flaw in the ointment, etc). I remember trying the padding trick on the connection string, different LogonTypes, etc... I ended up just making a comment block I am doing a rewrite of my service now, and am upgrading to 3.0 and it looks like the issue is still around... after reading dotnet/corefx#24977 it doesn't look like its anything within this library, but the underlying nature of Impersonation. |
This might be related: aspnet/AspNetWebStack#260. |
I hadn't noticed until now, but looks like we got I'll work on an update that targets .NET 5+ to address this issue and use the new API. |
Turns out that |
Considering code such as:
While this looks correct, it appears that the task sometimes runs as if not impersonated. This is being discussed further in dotnet/corefx#24977.
I'll leave this item open for tracking, and discussion of alternatives. In the meantime, I recommend against using impersonation with asynchronous tasks.
The text was updated successfully, but these errors were encountered: