Click here to Skip to main content
15,887,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello there,

I have an weird Question. How can i run an part of my Programm as an different User, which is promted by the User ?
Can somebody help me ? I searched almost everywhere but i didn´t find a solution that works.

What I have tried:

I tried some solutions which were presented by google, but they didn´t work as it should.
Posted
Updated 31-Jul-20 5:39am
Comments
BillWoodruff 31-Jul-20 5:36am    
We need much more detail to assist you.
HP91 31-Jul-20 5:38am    
Is it possible to run something like an method in C# as an Administrator User and the rest with an other User?
I need to run it as an specific user from AD because i need the Permission for an specific Folder.

1 solution

You cannot run an a process as a normal user then try to execute a method as elevated admin priv's. It's the entire process runs with admin priv's or none of it. This is for security reasons.

You can, however, use impersonation to execute a method as a different user, just not elevated. See c# - How do you do Impersonation in .NET?[^] this answer on SO. It does a great job of explaining things.
 
Share this answer
 
Comments
HP91 3-Aug-20 4:32am    
Many Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900