07-23-2023, 09:11 AM
I had the following in a .NET Framework 4.0 assembly:
```cs
var newId = new WindowsIdentity(duplicateTokenHandle);
WindowsImpersonationContext newId = ImpersonatedIdentity.Impersonate();
```
I'm porting it to ASP.Core, but `WindowsImpersonationContext` and `WindowsIdentity.Impersonate()` aren't found.
I've tried adding the following:
| Type | Version |
| ----------------------------------- | ------- |
| `System.Security.Claims` | `4.3.0` |
| `System.Security.Principal` | `4.3.0` |
| `System.Security.Principal.Windows` | `4.3.0` |
How do I perform impersonation in ASP.Core?
**Update**
It looks like it's not supported in .NET Core or .NET Standard - is there a work-around or do I have to resign to targeting the framework?
```cs
var newId = new WindowsIdentity(duplicateTokenHandle);
WindowsImpersonationContext newId = ImpersonatedIdentity.Impersonate();
```
I'm porting it to ASP.Core, but `WindowsImpersonationContext` and `WindowsIdentity.Impersonate()` aren't found.
I've tried adding the following:
| Type | Version |
| ----------------------------------- | ------- |
| `System.Security.Claims` | `4.3.0` |
| `System.Security.Principal` | `4.3.0` |
| `System.Security.Principal.Windows` | `4.3.0` |
How do I perform impersonation in ASP.Core?
**Update**
It looks like it's not supported in .NET Core or .NET Standard - is there a work-around or do I have to resign to targeting the framework?