title: WIX database deployment, installation
body: <p>During my setup I give an option to use "windows authentication" OR "server authetication". Everything works fine and db gets installed as long as I do "server authentication" and provide db userId and password.</p>
  
  <p>What do I need to do in order install db using "windows authentication" (in wix)?
  thanks</p>
  
  <p>My product.wxs file:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;Product Id="*" Name="MySetup2" Language="1033" Version="1.0.0.0" Manufacturer="Hewlett-Packard Company" UpgradeCode="bf1da750-c2fe-4026-9d2b-9d291a61a8b5"&gt;
      &lt;Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /&gt;
  
      &lt;Binary Id="success_bmp" SourceFile="$(sys.SOURCEFILEDIR)success.bmp" /&gt;
      &lt;Binary Id="error_bmp" SourceFile="$(sys.SOURCEFILEDIR)error.bmp" /&gt;
  
      &lt;MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /&gt;
      &lt;MediaTemplate /&gt;
  
      &lt;Feature Id="ProductFeature" Title="MySetup2" Level="1" ConfigurableDirectory="INSTALLDIR"&gt;
          &lt;ComponentGroupRef Id="ProductComponents" /&gt;
          &lt;ComponentGroupRef Id='MvcApp'/&gt;
          &lt;ComponentRef Id='SqlComponent' /&gt;
      &lt;/Feature&gt;
      &lt;Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /&gt;
  
      &lt;Binary Id="CreateTableScript"  SourceFile="c:\Temp\MyDb.sql" /&gt;
  
      &lt;!-- Specify UI --&gt;
      &lt;UIRef Id="MyWebUI" /&gt;
  
      &lt;!-- .NET Framework 3.0 SP 1 must be installed --&gt;
      &lt;Property Id="FRAMEWORKBASEPATH"&gt;
          &lt;RegistrySearch Id="FindFrameworkDir" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework" Name="InstallRoot" Type="raw"/&gt;
      &lt;/Property&gt;
  
     &lt;util:User Id="SQLUser" Name="[DATABASE_USERNAME]" Password="[DATABASE_PASSWORD]" /&gt;   
  &lt;/Product&gt;
  
  
  &lt;Fragment&gt;
      &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
          &lt;Directory Id="ProgramFilesFolder"&gt;
              &lt;Directory Id="INSTALLDIR" Name="MySetup2" &gt;
                  &lt;!--&lt;Component Id="Web.config" Guid="2ED81B77-F153-4003-9006-4770D789D4B6"&gt;
                      &lt;File Id="Web.config" Name="Web.config" Source="$(var.SolutionDir)MvcApplication4\Web.config" DiskId="1" KeyPath="yes" /&gt;
                      &lt;util:XmlFile Id="AppSettingsAddNode" File="[INSTALLDIR]Web.config" Action="createElement" ElementPath="/configuration/appSettings" Name="add" Sequence="1" /&gt;
                      &lt;util:XmlFile Id="AppSettingsKeyAttribute" Action="setValue" File="[INSTALLDIR]Web.config" ElementPath="/configuration/appSettings/add" Name="key" Value="AddedDuringInstall" Sequence="2" /&gt;
                      &lt;util:XmlFile Id="AppSettingsValueAttribute" Action="setValue" File="[INSTALLDIR]Web.config" ElementPath="/configuration/appSettings/add" Name="value" Value="This text was added during installation." Sequence="3" /&gt;
                  &lt;/Component&gt;
                  &lt;Directory Id="binFolder" Name="bin"&gt;
                      &lt;Component Id="MvcApplication4.dll" Guid="7FC6DA37-12E5-463d-8E7E-08F73E40CCF2"&gt;
                          &lt;File Id="MvcApplication4.dll" Name="MvcApplication4.dll" Source="$(var.SolutionDir)MvcApplication4\Bin\MvcApplication4.dll" DiskId="1" KeyPath="yes" /&gt;
                      &lt;/Component&gt;
                  &lt;/Directory&gt;--&gt;
  
              &lt;/Directory&gt;            
          &lt;/Directory&gt;
  
  
          &lt;Component Id="SqlComponent" Guid="C50999A0-02FD-42d5-9F65-7375318DD328"&gt;
              &lt;sql:SqlDatabase Id="SqlDatabase" 
                              Database="[DATABASE_NAME]" 
                              Server="[DATABASE_SERVER]" 
                              CreateOnInstall="yes" 
                              DropOnUninstall="yes" 
                              User="SQLUser"&gt;
                  &lt;sql:SqlScript Id="CreateTableScript" ExecuteOnInstall="yes" BinaryKey="CreateTableScript" /&gt;
              &lt;/sql:SqlDatabase&gt;  
          &lt;/Component&gt;
  
  
  
      &lt;/Directory&gt;
  
  &lt;/Fragment&gt;
  
  &lt;Fragment&gt;
      &lt;ComponentGroup Id="ProductComponents" Directory="INSTALLDIR"&gt;
          &lt;!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. --&gt;
          &lt;!-- &lt;Component Id="ProductComponent"&gt; --&gt;
          &lt;!-- TODO: Insert files, registry keys, and other resources here. --&gt;
          &lt;!-- &lt;/Component&gt; --&gt;
      &lt;/ComponentGroup&gt;
  &lt;/Fragment&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I modified this section and removed "User" tag it works using windows authentication. How do I add this tag OR remove it (Condition) based on UI's selection.</p>
  
  <pre><code>        &lt;sql:SqlDatabase Id="SqlDatabase" 
                          Database="[DATABASE_NAME]" 
                          Server="[DATABASE_SERVER]" 
                          CreateOnInstall="yes" 
                          DropOnUninstall="yes" 
                          User="SQLUser"&gt;
  </code></pre>