Functions

src/CustomActions/UserPrivileges/CheckCredentials.h File Reference

Go to the source code of this file.

Functions

CA_API UINT __stdcall CheckCredentials (MSIHANDLE hInstall)
 Custom action to verify whether user logon credentials are valid via ::LogonUser.

Function Documentation

CA_API UINT __stdcall CheckCredentials ( MSIHANDLE  hInstall)

Custom action to verify whether user logon credentials are valid via ::LogonUser.

Parameters:
LOGON_USERNAMEUsername
LOGON_PASSWORDPassword
LOGON_TYPEType of logon, default is LOGON32_LOGON_NETWORK
Returns:
LOGON_VALID 1 if logon is valid, 0 otherwise
LOGON_ERROR an OS-formatted error string when available
Example:

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

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

The following code checks user credentials.

<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_PASSWORD" Value="[SERVICE_PASSWORD]" Order="1">1</Publish>
 <Publish Event="DoAction" Value="CheckCredentials" Order="2">1</Publish>
 <Publish Property="LOGON_VALID" Value="[LOGON_VALID]" Order="3">1</Publish>
 <Publish Property="LOGON_ERROR" Value="Invalid Logon" Order="3"><![CDATA[LOGON_ERROR = "" AND LOGON_VALID = "0"]]></Publish>
</Control>

The LOGON_VALID and LOGON_ERROR properties are helpful to trigger an error dialog where appropriate.

<Dialog Id="InvalidLogonDlg" Width="260" Height="85" Title="Invalid Logon">
 <Control Id="Return" Type="PushButton" X="102" Y="57" Width="56" Height="17" Default="yes" Cancel="yes" Text="OK">
  <Publish Event="EndDialog" Value="Return">1</Publish>
 </Control>
 <Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="30" Text="[LOGON_ERROR]" />
 <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24" FixedSize="yes" IconSize="32" Text="WixUI_Ico_Exclam" />
</Dialog>
<Control Id="Test" Type="PushButton" X="40" Y="200" Width="100" Height="17" Text="&amp;Test Credentials">
 ...
 <Publish Event="SpawnDialog" Value="InvalidLogonDlg" Order="8"><![CDATA[LOGON_VALID = "0"]></Publish>
</Control>

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



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