At work we have a program that is a data entry program. This program moves files as data is being entered, so read/write permissions has to be available for this to occur. Is there a way to make a C# program run under an account that has these permissions while keeping the users' account more restrictive? I'm using VS 2010.
Asked
Active
Viewed 110 times
0
-
Possible duplicate of http://stackoverflow.com/questions/559719/windows-impersonation-from-c-sharp – Slugart Nov 05 '12 at 16:58
-
You want an application on a client machine in a network/domain to run with elevated network/domain permissions without specific user action (IE: runas)? – Quintin Robinson Nov 05 '12 at 16:59
3 Answers
0
You can add PrincipalPermission attribute to control permissions of a single method.
[PrincipalPermission(SecurityAction.Demand, Role ="Administrators")]
static void CheckAdministrator()
{
Console.WriteLine("User is an administrator");
}Or use Application Manifest to elevate UAC
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

RAS
- 3,375
- 15
- 24
0
@Oded,
When using the runas utility, do you need to enter the password for the account you're trying to run the program as?

David
- 57
- 1
- 6