Can I turn off impersonation just in a couple instances

后端 未结 4 537
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 18:53

I have an app that has impersonation used throughout. But when a user is logged in as an admin, a few operation require them to write to the server itself. Now if these us

4条回答
  •  执笔经年
    2020-11-27 19:39

    I am not sure if this is the preferred approach but when I wanted to do this I new'd up an instance of a WindowsIdentity and called the Impersonate method. This allows subsequent code to impersonate a different Windows user. It returns a WindowsImpersonationContext that has an Undo method which reverts the impersonation context back again.

提交回复
热议问题