Skip to content

Impersonation without password in .NET Core #5021

@wstaelens

Description

@wstaelens

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions