Functions

src/CustomActions/UserPrivileges/UserInfo.h File Reference

Go to the source code of this file.

Functions

CA_API UINT __stdcall GetUserInfo (MSIHANDLE hInstall)
 Get current user information, including SID and DNS name.
CA_API UINT __stdcall GetUserNameFormatted (MSIHANDLE hInstall)
 Get current user name in a specific format.
CA_API UINT __stdcall GetAccountSid (MSIHANDLE hInstall)
 Looks up the account and returns the SID.
CA_API UINT __stdcall TranslateNameFormatted (MSIHANDLE hInstall)
 Translate an account name to a specific format.

Function Documentation

CA_API UINT __stdcall GetAccountSid ( MSIHANDLE  hInstall)

Looks up the account and returns the SID.

Parameters:
ACCOUNT_NAMEAccount name to look up. Can be in DNS, FQDN or UPN format
ACCOUNT_SID_FORMATformat of the returned SID. This can be one of

  • SidString the string representation of the SID. This is the default value if ACCOUNT_SID_FORMAT is not specified.
  • SidStringHex the hexadecimal representation of the binary SID.
Returns:
ACCOUNT_SID Account SID in the specified format
CA_API UINT __stdcall GetUserInfo ( MSIHANDLE  hInstall)

Get current user information, including SID and DNS name.

Returns:
USER_FQN DNS domain name followed by a backward-slash and the SAM username
USER_NAME full username, includes the domain for domain users
USER_DOMAIN qualified domain from LookupAccountName
USER_SID user SID

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

CA_API UINT __stdcall GetUserNameFormatted ( MSIHANDLE  hInstall)

Get current user name in a specific format.

Parameters:
USERNAME_FORMATusername format, one of EXTENDED_NAME_FORMAT, see http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx

  • NameFullyQualifiedDN The fully-qualified distinguished name (for example, CN=Jeff Smith,OU=Users,DC=Engineering,DC=Microsoft,DC=Com).
  • NameSamCompatible A legacy account name (for example, Engineering\JSmith). The domain-only version includes trailing backslashes (\\).
  • NameDisplay A "friendly" display name (for example, Jeff Smith). The display name is not necessarily the defining relative distinguished name (RDN).
  • NameUniqueId A GUID string that the IIDFromString function returns (for example, {4fa050f0-f561-11cf-bdd9-00aa003a77b6}).
  • NameCanonical The complete canonical name (for example, engineering.microsoft.com/software/someone). The domain-only version includes a trailing forward slash (/).
  • NameUserPrincipal The user principal name (for example, someone@example.com).
  • NameCanonicalEx The same as NameCanonical except that the rightmost forward slash (/) is replaced with a new line character (
    ), even in a domain-only case (for example, engineering.microsoft.com/software\nJSmith).
  • NameServicePrincipal The generalized service principal name (for example, www/www.microsoft.com.com).
  • NameDnsDomain The DNS domain name followed by a backward-slash and the SAM username.
Returns:
USER_FQN fully qualified username

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

Obtaining Full DNS Username

When trying to obtain the complete username for a user, call GetUserInfo. If you want to get the DNS username instead of the SAM username, also call GetUserNameFormatted with NameDnsDomain. The latter call will fail for a local user, ignore its return code.

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

<!-- general username properties -->
<Publish Event="DoAction" Value="GetUserInfo" Order="1">1</Publish>
<!-- username in the DNS domain format -->
<Publish Property="USERNAME_FORMAT" Value="NameDnsDomain" Order="2">1</Publish>
<Publish Event="DoAction" Value="GetUserNameFormatted" Order="3">1</Publish>
<Publish Property="USERNAME_DNSDOMAIN" Value="[USER_FQN]" Order="4">1</Publish>
<!-- either keep USER_NAME or USERNAME_DNSDOMAIN -->
<Publish Property="USERNAME_FULL" Value="[USERNAME_DNSDOMAIN]" Order="5">1</Publish>
<Publish Property="USERNAME_FULL" Value="[USER_NAME]" Order="6">NOT USERNAME_FULL</Publish>
CA_API UINT __stdcall TranslateNameFormatted ( MSIHANDLE  hInstall)

Translate an account name to a specific format.

Parameters:
ACCOUNT_NAMEthe account name to translate. This can be in any of the EXTENDED_NAME_FORMATs.
ACCOUNT_NAME_FORMATname format, one of EXTENDED_NAME_FORMAT, see http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx

  • NameFullyQualifiedDN The fully-qualified distinguished name (for example, CN=Jeff Smith,OU=Users,DC=Engineering,DC=Microsoft,DC=Com).
  • NameSamCompatible A legacy account name (for example, Engineering\JSmith). The domain-only version includes trailing backslashes (\\).
  • NameDisplay A "friendly" display name (for example, Jeff Smith). The display name is not necessarily the defining relative distinguished name (RDN).
  • NameUniqueId A GUID string that the IIDFromString function returns (for example, {4fa050f0-f561-11cf-bdd9-00aa003a77b6}).
  • NameCanonical The complete canonical name (for example, engineering.microsoft.com/software/someone). The domain-only version includes a trailing forward slash (/).
  • NameUserPrincipal The user principal name (for example, someone@example.com).
  • NameCanonicalEx The same as NameCanonical except that the rightmost forward slash (/) is replaced with a new line character (
    ), even in a domain-only case (for example, engineering.microsoft.com/software\nJSmith).
  • NameServicePrincipal The generalized service principal name (for example, www/www.microsoft.com.com).
  • NameDnsDomain The DNS domain name followed by a backward-slash and the SAM username.
Returns:
ACCOUNT_NAME the account name translated to the specified format.


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