Results 1 to 6 of 6

Thread: How to Revert Identity Impersonation to original user

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2021
    Posts
    23

    How to Revert Identity Impersonation to original user

    I'm using the following code to set the identity impersonation at runtime, but when it calls undoImpersonation() it sets the identity to IIS APPPOOL\DefaultAppPool. Instead of DefaultAppPool, how can I revert back to the original user identity?
    Last edited by Rhodo; Feb 26th, 2021 at 08:17 PM.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: How to Revert Identity Impersonation to original user

    I haven't tested but theoretically if you put USING in the impersonate then when the code steps out of using it will revert back.
    You can do a test, here is a sample of using (look post no #7)

    https://www.vbforums.com/showthread....(User-folders)
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2021
    Posts
    23

    Re: How to Revert Identity Impersonation to original user

    sorry I'm new to vb.net, do you mean like this:
    Last edited by Rhodo; Feb 26th, 2021 at 08:17 PM.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: How to Revert Identity Impersonation to original user

    I haven't ever tried to revert, so Just look at the example I linked to , just do not try to revert anything, put your code inside the using and when the using ends, see if it reverted to he previous context.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2021
    Posts
    23

    Re: How to Revert Identity Impersonation to original user

    I figured it out. Thank you Sapator!
    Last edited by Rhodo; Feb 26th, 2021 at 08:10 PM.

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: How to Revert Identity Impersonation to original user

    No Problem.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width