2 years ago
#16390
deadlydog
.Net cross-platform user impersonation
I'm creating a .Net 6 console application which involves reading/writing files to user-specified file paths. Sometimes these file paths are on network shares which require separate credentials to be accessed with. If I was only worried about running on Windows I would use WindowsIdentity.RunImpersonated. As it's name implies though, and by looking at the sample code which contains the line [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
, I'm pretty certain this will only work on Windows, and not Linux or MacOS.
Is there a cross-platform function in .Net 6 (or some other 3rd party library perhaps) that can be used for user impersonation so I can do things like Directory.EnumerateFiles()
on network shares that require different credentials?
.net
cross-platform
impersonation
0 Answers
Your Answer