Search code examples
active-directorywixwindows-installeradfs

WiX CustomAction to Register Custom ADFS Authentication Provider


I'm following Microsoft's Build a Custom Authentication Method for AD FS in Windows Server guide to build a custom authentication provider for ADFS and I'm at the deployment step, which states that:

Adapter providers must provide an installer which performs the necessary installation actions including installation in the GAC, and the installer must support registration in AD FS.

I was successfully able to install the adapter to the GAC using WiX and manually register it with ADFS using PowerShell, but I'm getting an error from Windows Installer when trying to have WiX handle registering the provider with ADFS automatically via a CustomAction: Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor.

The full logs are shown below:

MSI (s) (E4:78) [10:02:27:412]: Executing op: ActionStart(Name=RegisterAdfsProvider,,)
MSI (s) (E4:78) [10:02:27:413]: Executing op: CustomActionSchedule(Action=RegisterAdfsProvider,ActionType=3106,Source=C:\,Target=Register-AdfsAuthenticationProvider -TypeName "MyAuthenticationAdapter.MyAdapter, MyAuthenticationAdapter, version=1.0.0.0, culture=neutral, publicKeyToken=D006C127CE4A16A7, processorArchitecture=MSIL" -Name MyAuthenticationProvider,)
MSI (s) (E4:78) [10:02:27:416]: Note: 1: 1721 2: RegisterAdfsProvider 3: C:\ 4: Register-AdfsAuthenticationProvider -TypeName "MyAuthenticationAdapter.MyAdapter, MyAuthenticationAdapter, version=1.0.0.0, culture=neutral, publicKeyToken=D006C127CE4A16A7, processorArchitecture=MSIL" -Name MyAuthenticationProvider 
MSI (s) (E4:78) [10:02:27:416]: Note: 1: 2205 2:  3: Error 
MSI (s) (E4:78) [10:02:27:416]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1721 
MSI (c) (0C:B0) [10:02:27:429]: Font created.  Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: RegisterAdfsProvider, location: C:\, command: Register-AdfsAuthenticationProvider -TypeName "MyAuthenticationAdapter.MyAdapter, MyAuthenticationAdapter, version=1.0.0.0, culture=neutral, publicKeyToken=D006C127CE4A16A7, processorArchitecture=MSIL" -Name MyAuthenticationProvider 
MSI (s) (E4:78) [10:02:28:198]: Note: 1: 2205 2:  3: Error 
MSI (s) (E4:78) [10:02:28:198]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 
MSI (s) (E4:78) [10:02:28:198]: Product: MyAuthenticationAdapter -- Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: RegisterAdfsProvider, location: C:\, command: Register-AdfsAuthenticationProvider -TypeName "MyAuthenticationAdapter.MyAdapter, MyAuthenticationAdapter, version=1.0.0.0, culture=neutral, publicKeyToken=D006C127CE4A16A7, processorArchitecture=MSIL" -Name MyAuthenticationProvider 

Action ended 10:02:28: InstallFinalize. Return value 3.

If I copy the command from the logs and manually run it in PowerShell, it will complete successfully. My code in the .wxs file is as follows:

<SetProperty  Id="ADFS_PROVIDER_TYPE_NAME"
              Value="MyAuthenticationAdapter.MyAdapter, !(bind.assemblyFullName.MyAuthenticationAdapter)"
              Before="RegisterAdfsProvider"
              Sequence="execute"/>
<CustomAction Id="RegisterAdfsProvider"
              Directory="TARGETDIR"
              ExeCommand="Register-AdfsAuthenticationProvider -TypeName &quot;[ADFS_PROVIDER_TYPE_NAME]&quot; -Name MyAuthenticationProvider"
              Execute="deferred"
              Impersonate="no"/>
<InstallExecuteSequence>
  <Custom Action="RegisterAdfsProvider" Before="InstallFinalize">NOT Installed AND NOT REMOVE~="ALL"</Custom>
</InstallExecuteSequence>

What is wrong with my WiX file that causes this error during installation?


Solution

  • The original error was correct. I worked through several different methods of executing a command before I realized that the command I was trying to run was actually a PowerShell Cmdlet, which cannot be executed though the ExeCommand attribute of a CustomAction. I discovered this by running gcm "Register-AdfsAuthenticationProvider" in PowerShell and getting this output:

    CommandType   Name                                  Version   Source
    -----------   ----                                  -------   ------
    Cmdlet        Register-AdfsAuthenticationProvider   1.0.0.0   ADFS