0

I am running a process to read network drive (e.g U:) but the process is running in system context and network drive is only accessible in user context. Now I want that process to switch to user context (currently logged in user) and read U drive without asking user credential. Can anyone suggest how it can be achieved in Csharp?

Thanks in Advance!!!

  • 1
    That should not be possible because it would break security imo. You cannot impersonate another user. What You can do is have a user with access to all user folders on the network drive, i'd recommend trying to do that instead ... or report the bug if you succeed at what you describe ;) – T. Nielsen Feb 04 '22 at 11:14
  • To impersonate a user, you need a login token. You can pass a token between processes, but that would depend on how you are "running in system context". – Jeremy Lakeman Feb 07 '22 at 04:30
  • @JeremyLakeman I am running a service which is running in system context and this service is trying to read U drive. Can you suggest how and from where I can get token for logged in user? I have gone through https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-impersonateloggedonuser but not sure how to implement this. – Dhananjay kumar Singh Feb 08 '22 at 06:42

0 Answers0