Functions
CheckPrivilege.h File Reference

Go to the source code of this file.

Functions

CA_API UINT __stdcall CheckPrivilege (MSIHANDLE hInstall)
 Custom action to verify whether user has a certain privilege. More...
 

Function Documentation

CA_API UINT __stdcall CheckPrivilege ( MSIHANDLE  hInstall)

Custom action to verify whether user has a certain privilege.

Parameters
ComputerNameLocal computer name, inherited from MSI properties.
LOGON_USERNAMEUsername
LOGON_PRIVILEGEPrivilege, eg. SeServiceLogonRight
Returns
LOGON_HAS_PRIVILEGE 1 if user has the privilege, 0 otherwise
CA_ERROR system error when available
Example:

The following code includes the UserPrivileges custom action binary and declares the CheckPrivilege custom action.

<CustomAction Id="CheckPrivilege" BinaryKey="UserPrivileges" DllEntry="CheckPrivilege" Execute="immediate" Return="check" />
<Binary Id="UserPrivileges" SourceFile="$(var.BinDir)\UserPrivileges.dll" />

The following code checks whether a user has logon as a service privilege.

<Control Id="Test" Type="PushButton" X="40" Y="200" Width="100" Height="17" Text="&amp;Test Credentials">
<Publish Property="LOGON_USERNAME" Value="[SERVICE_USERNAME]" Order="1">1</Publish>
<Publish Property="LOGON_PRIVILEGE" Value="SeServiceLogonRight" Order="1">1</Publish>
<Publish Event="DoAction" Value="CheckPrivilege" Order="2">1</Publish>
<Publish Property="LOGON_ERROR" Value="This account does not have logon as a service right. [CA_ERROR]" Order="3"><![CDATA[LOGON_HAS_PRIVILEGE = "0"]]></Publish>
</Control>

This custom action supports impersonation, see Impersonation in Immediate Custom Actions.



© Application Security Inc. - All Rights Reserved http://msiext.codeplex.com