Solved

VC++ 8, CppUnit, Vista: How to do unit testing with elevated permissions?

Posted on 2008-06-26
6
944 Views
Last Modified: 2012-08-13
unit tests fail when registering COM Dll components...

Hi experts,

My old unit tests fail when testing registration of COM Dll components on Windows Vista machine. The reason probably is more general. It may not be specific to the registering the component. I think the reason could be that the process does not get the elevated permissions. Can you share your experience with such cases? I am ready to add any details that you need to know for the answer.

I am using CppUnit for Windows from http://cppunit.sourceforge.net (I believe that it is version 1.12.0). It was integrated to VS 2005 C++ using the recommended way => the test is run automatically after building and its output is redirected to he Output window of the IDE. The IDE with C++ is started with elevated permissions.

Thanks,
   Petr
0
Comment
Question by:pepr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 21875347
The issue might be related to the User Account Control (UAC), the new security feature in Windows Vista, whereby processes do not automatically run with administrator privileges even if the current user belongs to the administrators group. The following article might be useful as it describes how to add an application manifest that will ask for elevated privileges when the application is started or when needed depending on how you configure it:

http://msdn.microsoft.com/en-us/magazine/cc163486.aspx
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 21875667
Add a manifest to your module that requests elevated permissions on startup by setting 'requestedExecutionLevel' to 'requireAdministrator', see also http://www.microsoft.com/downloads/details.aspx?FamilyID=BA73B169-A648-49AF-BC5E-A2EEBB74C16B&displaylang=en ("Windows Vista Application Development Requirements for User Account Control Compatibility")
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="MyModule"
     type="win32"/>
  <description>Description</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>

Open in new window

0
 
LVL 29

Author Comment

by:pepr
ID: 21951966
Sorry for my delay. jkr, thanks for pointing out the MS document (sorry, I have not read it yet). I am very new to using manifests. The project already generates some manifest in the directory for the configuration (i.e. Debug, Release, ...). The executable is also generated there.

For example (I use only Debug configuration for the tests), Debug/testFunction.exe exists and I can find Debug/testFunctions.exe.embed.manifest and Debug/testFunctions.exe.intermediate.manifest. I can also find Debug/testFunctions.exe.embed.manifest.res there. However, the Debug directory is generated. This means that the files are also generated.

In Project -- testFunction Properties... (Alt+F7) I can find something related to manifests -- see the pictures below.

How should I modify the project properties to information related to application security requirements there? Is the manifest linked to the .exe or must it be always placed neare the .exe?

Thanks,
   Petr
img1.png
img2.png
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 86

Expert Comment

by:jkr
ID: 21958274
Well, create a filecalled MyModule.dll.manifest and add that as a manifest resource.
0
 
LVL 29

Author Comment

by:pepr
ID: 22013938
Still not able to get it. I have to do other things now, but I promis to try later.
0
 
LVL 29

Author Closing Comment

by:pepr
ID: 31470890
I do not know when I get to solve the problem (having other things to do now). Anyway, thanks for enlighting the problem. It seems I have new things to study ;)
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

So who is this article for? If you are like most of the computer users out there, you probably only realize the meaning of 'System maintenance' after something goes wrong. This article is for you if you care about keeping your system working opti…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question