Custom Scope Activity with impersonation

Garcia, Jose Sebastian 1 Reputation point
2021-10-28T18:54:44.043+00:00

Hi guys!
I'm trying to create an activity of type scope, where everything inside is executed in an impersonal context. I already tried the schedule but it doesn't impersonate. That is, outside the schedule I can impersonate, but when I enter the schedule, it is as if the execution of the content (writeline) was performed outside the scope.

144675-image.png

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Look 1 Reputation point
    2022-01-04T20:49:27.613+00:00

    I want to do the same. Is there a solution already???

    And in my opinion the question is not only an UIPath-related topic:
    There is a class which allows to Enter/Leave a specified user context over WindowsIdentity with a token generated by the unmanaged function LogonUser(...) from advapi32.dll.
    In the custom activity i enter the user context in ExecuteAsync(...) and leave it in Cleanup(...) expecting the code contained in ExecuteAsync(...) is executed before Cleanup(...).
    But it seems that Cleanup(...) is executed before the ExecuteAsync-Method.
    What can make the trick to execute code in the order i expect it to work?
    Can I simply use Execute-Method instead of ExecuteAsync?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.