locked
requireAdministrator ExecutionLevel terminates Outlook access? RRS feed

  • Question

  • I'm working a windows application that uses C# managed code and Win32 pinvoke.

    Also, application uses Outlook (2007) references for sending mail.

    Application must use administrative permitions because it hooks to keyboard and mouse (Win32 pinvoke).

    So, I added in app.manifest "requestedPrivileges" node and manifest looks like:

     

    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urnTongue Tiedchemas-microsoft-com:asm.v1" xmlns:asmv1="urnTongue Tiedchemas-microsoft-com:asm.v1" xmlns:asmv2="urnTongue Tiedchemas-microsoft-com:asm.v2" xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance">
      <trustInfo xmlns="urnTongue Tiedchemas-microsoft-com:asm.v2">
        <security>
          <applicationRequestMinimum>
            <defaultAssemblyRequest permissionSetReference="Custom" />
            <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
          </applicationRequestMinimum>
          <requestedPrivileges>
            <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
          </requestedPrivileges>

        </security>
      </trustInfo>
    </asmv1:assembly>

     

    At the first, when I start application, Vista shows dialog:

     

    Caption: User Account Control

    An unidentified program wants to access to your computer

    Buttons: Cancel Allow

     

    After I click Allow button, application is working well, but, when I try to send mail it fails to start Outlook objects.

    If I clear "requestedPrivileges" from app.manifest I can send mail, but, (of course) Win32 hooking stops to work.

     

    Thanks

     

    P.S. My user account is at the local Administrative group

    Just before I use Outlook application object following methods:

    Environment.UserName

    Environment.UserDomainName

    points to my correct current account.

    Tuesday, May 15, 2007 8:57 AM