Visual C# Developer Center > Visual C# Forums > Visual C# General > Break out of Limited Permissions
Ask a questionAsk a question
 

QuestionBreak out of Limited Permissions

  • Tuesday, November 03, 2009 4:40 PMLuke_UK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    I am developing an application that will be executed by a third-party program to perform a very short running task (it generates a text report on demand). However, the third party application seems to execute the new process with next to no permissions granted so my program cannot perform any FileIO or database work. I also cannot use impersonation to elevate my application to a better position as calls to unmanged code are denied. How can I get around this with .NET?

All Replies

  • Wednesday, November 04, 2009 8:42 AMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I don't understand what you mean. A 3rd app creates a text file, and you want read permissions on this file, correct? What is the location of the file and is the 3rd party app closed when you are trying to access the file?
    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 10:38 AMLuke_UK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    No...

    The third party application starts my program.
    File IO generates a security exception in my program.
    Exception must be caused by limited permissions given by the third party application.

    How can I give my application the proper permissions?.......
  • Wednesday, November 04, 2009 11:00 AMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Set the manifest of requiredExecutionLevel to asAdministrator.
    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 11:14 AMLuke_UK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Geert,

    Please can you provide an example of how to do this?

    I have used Google but it only returns results for modifying MSI packages.
  • Wednesday, November 04, 2009 12:28 PMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    See this thread, which eventually links to this documentation.


    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 1:13 PMLuke_UK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    My manifest contains the following and still gets the exception.

    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
          <applicationRequestMinimum>
            <defaultAssemblyRequest permissionSetReference="Custom" />
            <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
          </applicationRequestMinimum>
        </security>
      </trustInfo>
    </asmv1:assembly>
    
  • Wednesday, November 04, 2009 3:29 PMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Try this:

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    
     <description>My Application</description> 
    
      <!-- Identify the application security requirements. -->
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
          <requestedPrivileges>
            <requestedExecutionLevel
    		      level="requireAdministrator"
    			    uiAccess="false" />	
          </requestedPrivileges>
        </security>
      </trustInfo>
    
    </assembly>
    

    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 4:19 PMLuke_UK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I've just noticed that the compiler is generating warnings saying:

    The parameter to the compiler is invalid, '/define:/win32manifest:app.manifest' will be ignored.

    Why is it doing that?

    EDIT:/

    I have also noticed that this is a .NET 3.5 compiler switch. I am using .NET 2.0
    • Edited byLuke_UK Wednesday, November 04, 2009 4:31 PMIncorrect version assumption
    •  
  • Wednesday, November 04, 2009 7:25 PMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    See this thread. It uses a command line as post-build step if the /win32manifest is not yet supported.


    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 7:30 PMScottyDoesKnow Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    See this thread. It uses a command line as post-build step if the /win32manifest is not yet supported.


    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!

    Just a warning, I've been using that method to embed a manifest and it doesn't seem to work for setup and deployment projects (manifest isn't for the setup project, but it doesn't get added to the exe when using a setup).
  • Thursday, November 05, 2009 10:06 AMLuke_UK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    All I'm getting is error code 9009.

    Is this really the way to solve my problem? It doesn't seem, to me, that changing any manifest will allow my application to gain the proper access rights if it has been executed by a third party application with limited privelages. I just need to be able to give my app the correct rights....

  • Thursday, November 05, 2009 3:44 PMScottyDoesKnow Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Setting the manifest will mean that the user will be prompted to put in an admin password when your program runs. This is definately a hack since you don't actually need admin permission, just file IO permissions. But if it's being run through a program with limited permissions, I don't know what you can do. You can't just "break out" programatically, that's the point of permissions. At the very least the user will have to be prompted in some way, but I don't know how except for the admin hack.