0

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.

Kara
  • 6,115
  • 16
  • 50
  • 57
David
  • 57
  • 1
  • 6
  • 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 Answers3

2

You can use the runas utility - setup a shortcut using it.

It:

Allows a user to run specific tools and programs with different permissions than the user's current logon provides.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
0
  1. 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");
    }

  2. 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