Solved

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

Posted on 2008-06-26
6
934 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
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 28

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 86

Expert Comment

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

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 28

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

919 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

19 Experts available now in Live!

Get 1:1 Help Now