Skip to content
Advertisement

Windows User Impersonation in .NET Core on Linux?

I’m writing a .NET Core application in C# that will run on a Linux server, but I need to impersonate a Windows user in order to access some remote resources on a Windows Server. I have credentials to authenticate there, but all the implementations I see rely on the “Advanced Windows 32 Base API” (advapi32.dll), which is a shared Windows library not available on Linux.

How do I make this work?

Advertisement

Answer

I was able to get a solution by thinking outside the box a bit. I discovered that I could use SharpCifs.Core for CIFS access and the Microsoft PowerShell SDK to gain a remote PowerShell session, and get environment variables. I do wish that Microsoft would write some better cross-platform tooling.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement