Solved

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

Posted on 2008-06-26
6
928 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
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:LordOfPorts
Comment Utility
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
Comment Utility
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 28

Author Comment

by:pepr
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 86

Expert Comment

by:jkr
Comment Utility
Well, create a filecalled MyModule.dll.manifest and add that as a manifest resource.
0
 
LVL 28

Author Comment

by:pepr
Comment Utility
Still not able to get it. I have to do other things now, but I promis to try later.
0
 
LVL 28

Author Closing Comment

by:pepr
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now