-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
We are currently moving a project that was written in .NET Full Framework to .NET Core 3.1. Our project has Windows services, signalr, a web part etc... Choosing for .NET Core feels to be the right thing to do and will hopefully make it future proof (cf. .NET 5)
We intercept print jobs and in the Full Framework project we used impersonation without having to know the users password (policy: "act as part of the operating system").
However we are currently stuck in .NET Core 3.1 as we can't find a way to make the impersonation code working without having to provide a user password. (print jobs need to be processed regarding specific users, not e.g. system).
Impersonation without password in .NET Full Framework:
if (string.IsNullOrEmpty(sPassword)) {
string upn = string.Format("{0}@{1}", sUsername, sDomain);
var id = return new WindowsIdentity(upn, null)
id.Impersonate();
...
}
How can this be done using .NET Core?