{"id":5155,"date":"2013-06-19T19:34:23","date_gmt":"2013-06-19T17:34:23","guid":{"rendered":"https:\/\/ingmarverheij.com\/?p=5155"},"modified":"2013-11-30T12:42:56","modified_gmt":"2013-11-30T11:42:56","slug":"unattended-res-wm2012-agent-does-not-store-relay-server-configuration","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/unattended-res-wm2012-agent-does-not-store-relay-server-configuration\/","title":{"rendered":"Unattended RES WM2012 agent does not store Relay Server configuration with UAC enabled"},"content":{"rendered":"<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-Workspace-Manager-Agent-Configure-connection.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 0px 5px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"RES Workspace Manager Agent - Configure connection\" alt=\"RES Workspace Manager Agent - Configure connection\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-Workspace-Manager-Agent-Configure-connection_thumb.png\" width=\"154\" height=\"95\" align=\"right\" border=\"0\" \/><\/a>When RES Workspace Manger 2012 is installed unattended and configured to connect to a Relay Server, and User Account Control (UAC) is enabled, the configuration is not stored. As a result the agent is <em>unmanaged<\/em>.<\/p>\n<p>After extensive testing I found the solution to solve this issue.<\/p>\n<p><em>PS: This applies for both SR2 and SR3 (<\/em><a href=\"https:\/\/www.google.nl\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CC8QFjAA&amp;url=http%3A%2F%2Fresguru.com%2Fwp-content%2Fuploads%2F2013%2F06%2F9.7.3.0-RES-Workspace-Manager-2013-SR3-Release-Notes.pdf&amp;ei=x-HBUbixDZHLsgaKh4GIBw&amp;usg=AFQjCNFd1d2ERyQ6BknIwJT7NmJM8l0-Vw&amp;bvm=bv.48175248,d.Yms\" target=\"_blank\">release notes<\/a><em><\/em><em>).<\/em><\/p>\n<p><!--more--><\/p>\n<h1>User Account Control (UAC)<\/h1>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/User-Account-Control.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 0px 0px 5px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"User Account Control Settings\" alt=\"User Account Control Settings\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/User-Account-Control_thumb.png\" width=\"154\" height=\"115\" align=\"right\" border=\"0\" \/><\/a>When UAC is enabled (introduced since Windows Vista) a user has a token with only basic privileges, administrative privileges are filtered (removed). The administrative privileges are only available when a process is ran with elevated permissions. The user needs to confirm to run the process in elevated mode (and specify credentials)\u00a0 in a UAC prompt.<\/p>\n<p>In the environment where I\u2019m setting up RES Workspace Manager UAC is enabled with the default policy (notify only when programs try to make changes to the computer).<\/p>\n<p>&nbsp;<\/p>\n<h1>Windows Installer<\/h1>\n<p>Windows Installer is used to install RES Workspace Manager Agent (.msi extension). The user interface that\u2019s shown to the user (of hidden when running unattended) runs in the users context with a filtered token (without administrative privileges). Since the installation makes changes to the computer, elevation is required and the user is prompted by UAC.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/UAC-question.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: none; padding-top: 0px; padding-left: 0px; margin: 0px auto; display: block; padding-right: 0px; border-width: 0px;\" title=\"UAC question\" alt=\"UAC question\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/UAC-question_thumb.png\" width=\"354\" height=\"260\" border=\"0\" \/><\/a><\/p>\n<p>In a verbose log you\u2019ll see the following line<\/p>\n<pre>MSI (s) (B0:04) [13:54:53:463]: MSI_LUA: Elevation required to install product, will prompt for credentials<\/pre>\n<p>followed by the following lines after the user confirmed.<\/p>\n<pre>MSI (s) (B0:04) [13:54:55:865]: MSI_LUA: Credential Request return = 0x0\r\nMSI (s) (B0:04) [13:54:55:865]: MSI_LUA: Elevated credential consent provided. Install will run elevated<\/pre>\n<p>&nbsp;<\/p>\n<h1>Custom Actions<\/h1>\n<p><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa368066(v=vs.85).aspx\" target=\"_blank\">Custom Actions<\/a> are used in Windows Installer to launch executables that are on the local machine or installed by the installation. A Custom Action named \u2018res.exe\u2019 is used to configure the RES service with the specified datastore connection.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-Custom-Actions.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: none; padding-top: 0px; padding-left: 0px; margin: 0px auto; display: block; padding-right: 0px; border-width: 0px;\" title=\"RES-WM-2012-Agent-SR3 - Custom Actions\" alt=\"RES-WM-2012-Agent-SR3 - Custom Actions\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-Custom-Actions_thumb.png\" width=\"354\" height=\"132\" border=\"0\" \/><\/a><\/p>\n<p>In a verbose log you\u2019ll see the following line<\/p>\n<pre>MSI (s) (B0:04) [13:55:04:446]: Executing op: ActionStart(Name=res.exe,,)\r\nMSI (s) (B0:04) [13:55:04:446]: Executing op: CustomActionSchedule(Action=res.exe,ActionType=1618,Source=C:\\Program Files\\RES Software\\Workspace Manager\\svc\\res.exe,Target=\/msiparms=3||{18E874CB-DCEE-49F9-9EE4-D9133C58927D}||********||||NO||SAHPSXD6554;SAHPSXD6555;SAHPSXD6854;SAHPSXD6855||||YES||Hosted Private Machines||no||||||||||||||||||||,)<\/pre>\n<p>In the example above a list of Relay Servers is specified including the GUID and encryption password (********). However, as said in the introduction the configuration is not applied to the RES Workspace Manager service.<\/p>\n<p>&nbsp;<\/p>\n<h6 align=\"left\"><span style=\"font-weight: bold;\">Impersonating the invoking user<\/span><\/h6>\n<p align=\"left\">By default Custom Actions <a href=\"https:\/\/blogs.msdn.com\/b\/heaths\/archive\/2007\/07\/12\/immediate-custom-actions-always-impersonate.aspx\" target=\"_blank\">impersonate the invoking user<\/a> (having a filtered token, without administrative privileges). As a result a machine-state changing task can fail, which indeed is the case for the datastore configuration. The default behavior of a Custom Action can be changed using value in the \u2018Type\u2019 field. When the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa368069(v=vs.85).aspx\" target=\"_blank\">msidbCustomActionTypeNoImpersonate<\/a> option flag is set the user is not impersonated,\u00a0 the action is executed by the user with elevated privileges (a non-filtered token).<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-InstallExecuteSequence-WhoAmI.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 5px 0px 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"RES-WM-2012-Agent-SR3 - InstallExecuteSequence - WhoAmI\" alt=\"RES-WM-2012-Agent-SR3 - InstallExecuteSequence - WhoAmI\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-InstallExecuteSequence-WhoAmI_thumb.png\" width=\"154\" height=\"59\" align=\"right\" border=\"0\" \/><\/a>To prove this theory I added two Custom Actions that call <em>whoami <\/em>to read the users privileges.<\/p>\n<ol>\n<li><strong>WhoAmI_default<\/strong> with type 1058\n<ul>\n<li>34 [<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa372048(v=vs.85).aspx\" target=\"_blank\">EXE file having a path referencing a directory<\/a>] +<\/li>\n<li>1024 [<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa368069(v=vs.85).aspx\" target=\"_blank\">msidbCustomActionTypeInScript<\/a>]<\/li>\n<\/ul>\n<\/li>\n<li><strong><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-Custom-Actions-WhoAmI.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: right; padding-top: 0px; padding-left: 0px; margin: 0px 5px 0px 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"RES-WM-2012-Agent-SR3 - Custom Actions - WhoAmI\" alt=\"RES-WM-2012-Agent-SR3 - Custom Actions - WhoAmI\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-Custom-Actions-WhoAmI_thumb.png\" width=\"154\" height=\"59\" align=\"right\" border=\"0\" \/><\/a>WhoAmI_noimpersonate <\/strong>with type 3106\n<ul>\n<li>34 [<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa372048(v=vs.85).aspx\" target=\"_blank\">EXE file having a path referencing a directory<\/a>] +<\/li>\n<li>1024 [<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa368069(v=vs.85).aspx\" target=\"_blank\">msidbCustomActionTypeInScript<\/a>] +<\/li>\n<li>2048 [<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa368069(v=vs.85).aspx\" target=\"_blank\">msidbCustomActionTypeNoImpersonate<\/a>]<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>The result of the two custom actions clearly show the difference in the privileges of the user:<\/p>\n<p><span style=\"text-decoration: underline;\">WhoAmI_<strong>default<\/strong><\/span><\/p>\n<pre>Privilege Name                Description                          State   \r\n============================= ==================================== ========\r\nSeShutdownPrivilege           Shut down the system                 Enabled \r\nSeChangeNotifyPrivilege       Bypass traverse checking             Enabled \r\nSeUndockPrivilege             Remove computer from docking station Disabled\r\nSeIncreaseWorkingSetPrivilege Increase a process working set       Disabled\r\nSeTimeZonePrivilege           Change the time zone                 Disabled<\/pre>\n<h6><\/h6>\n<p><span style=\"text-decoration: underline;\">WhoAmI_<strong>noimpersonate<\/strong><\/span><\/p>\n<pre>Privilege Name                  Description                               State   \r\n=============================== ========================================= ========\r\nSeAssignPrimaryTokenPrivilege   Replace a process level token             Disabled\r\nSeLockMemoryPrivilege           Lock pages in memory                      Enabled \r\nSeIncreaseQuotaPrivilege        Adjust memory quotas for a process        Disabled\r\nSeTcbPrivilege                  Act as part of the operating system       Enabled \r\nSeSecurityPrivilege             Manage auditing and security log          Enabled \r\nSeTakeOwnershipPrivilege        Take ownership of files or other objects  Disabled\r\nSeLoadDriverPrivilege           Load and unload device drivers            Disabled\r\nSeProfileSingleProcessPrivilege Profile single process                    Enabled \r\nSeIncreaseBasePriorityPrivilege Increase scheduling priority              Enabled \r\nSeCreatePagefilePrivilege       Create a pagefile                         Enabled \r\nSeCreatePermanentPrivilege      Create permanent shared objects           Enabled \r\nSeRestorePrivilege              Restore files and directories             Disabled\r\nSeShutdownPrivilege             Shut down the system                      Disabled\r\nSeAuditPrivilege                Generate security audits                  Enabled \r\nSeChangeNotifyPrivilege         Bypass traverse checking                  Enabled \r\nSeImpersonatePrivilege          Impersonate a client after authentication Enabled \r\nSeCreateGlobalPrivilege         Create global objects                     Enabled<\/pre>\n<p>&nbsp;<\/p>\n<h1>Patch RES Workspace Manager installation file<\/h1>\n<p>In the installation file provided by RES Software the option flag set for the Custom Action \u2018res.exe\u2019 is set to 1618 decimal (or 0x652). To enable the NoImpersonate option flag we need to add 2048 (or 0x800) resulting in 3666.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-Custom-Actions-Patched.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: none; padding-top: 0px; padding-left: 0px; margin: 0px auto; display: block; padding-right: 0px; border-width: 0px;\" title=\"RES-WM-2012-Agent-SR3 - Custom Actions - Patched\" alt=\"RES-WM-2012-Agent-SR3 - Custom Actions - Patched\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-WM-2012-Agent-SR3-Custom-Actions-Patched_thumb.png\" width=\"354\" height=\"132\" border=\"0\" \/><\/a><\/p>\n<p>Now if the Custom Action \u2018res.exe\u2019 is executed (and UAC is enabled) the task is executed by the user with elevated permissions and changes can be made to the system.<\/p>\n<p id=\"download\">\nInstead of changing the original MSI file you can also create a transform file (MST). You can download the transform file for the Workspace Manager 2012 SR3 agent here: <a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"Version 1.0\" href=\"https:\/\/ingmarverheij.com\/en\/download\/5835\/?tmstv=1778350197\" rel=\"nofollow\" id=\"download-link-5835\" data-redirect=\"false\" >\n\tRES-WM-2012-Agent-SR3.mst<\/a>\n. <em>Thanks to <a href=\"https:\/\/twitter.com\/RemkoWeijnen\" target=\"_blank\">Remko Weijnen<\/a> for the tip!<\/em><\/p>\n<h1><\/h1>\n<h6><span style=\"font-weight: bold;\">Configure Connection<\/span><\/h6>\n<p>After the MSI file was \u201cpatched\u201d and executed the datastore configuration was applied successfully. The datastore configuration can be shown (and changed) by executing the following command line:<\/p>\n<pre>%ProgramFiles%\\RES Software\\Workspace Manager\\svc\\res.exe \/config<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-Workpsace-Manager-Agent-Configure-connection-CORRECT.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; float: none; padding-top: 0px; padding-left: 0px; margin: 0px auto; display: block; padding-right: 0px; border-width: 0px;\" title=\"RES Workpsace Manager Agent - Configure connection\" alt=\"RES Workpsace Manager Agent - Configure connection \" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/06\/RES-Workpsace-Manager-Agent-Configure-connection-CORRECT_thumb.png\" width=\"354\" height=\"217\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When RES Workspace Manger 2012 is installed unattended and configured to connect to a Relay Server, and User Account Control (UAC) is enabled, the configuration is not stored. As a result the agent is unmanaged. After extensive testing I found the solution to solve this issue. PS: This applies for both SR2 and SR3 (release [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[291],"tags":[553,39,414,372],"class_list":["post-5155","post","type-post","status-publish","format-standard","hentry","category-workpace-manager","tag-relay-server","tag-res","tag-unattended","tag-workspace-manager"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/5155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=5155"}],"version-history":[{"count":14,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/5155\/revisions"}],"predecessor-version":[{"id":5871,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/5155\/revisions\/5871"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=5155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=5155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=5155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}