我可以允许用户选择 applicationPoolIdentity 或使用 WiX-IIS 扩展指定用户吗? [英] Can I allow a user to choose either applicationPoolIdentity or specify a user using WiX-IIS extension?
问题描述
我的 Web 应用程序通常会安装为使用 applicationPoolIdentity:
My web application typically will be installed to use applicationPoolIdentity:
<iis:WebAppPool Id="MyAppPool" Identity="applicationPoolIdentity" Name="MyAppPool"/>
但我有一类用户想要使用特定的域用户,我通常会像这样编写:
but I have a class of users that will want to use a specific domain user instead, which I would typically author like this:
<util:User Id="MyUser" Name="[MY_USER]" Domain="[MY_DOMAIN]" Password="[MY_PASSWORD]" CreateUser="no"/>
<iis:WebAppPool Id="MyAppPool" Identity="other" User="MyUser" Name="MyAppPool" />
为此制作用户界面很简单,但有没有办法在 Identity="applicationPoolIdentity"
和 Identity="other"
之间有条件地切换,而无需编写自定义操作?
Making the user interface for this is simple enough, but is there a way to conditionally switch between Identity="applicationPoolIdentity"
and Identity="other"
without writing a custom action?
推荐答案
是的,这是可能的,但您需要创建一个包含两个具有条件的组件的组件组.由于这个解决方案有点冗长,我建议将它放在一个单独的文件中.
Yes, it is possible but you will need to create a component group with two components that have conditionals. As this solution is a bit verbose, I recommend having it in a separate file.
这里是一个例子,基于 https://www.codeproject.com/Articles/115036/Creating-WIX-Installer-for-ASP-NET-Web-Application.
Here is an example, based on https://www.codeproject.com/Articles/115036/Creating-WIX-Installer-for-ASP-NET-Web-Application.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<Property Id="IIS_WEBSITE" Value="root"/>
<Property Id="VIRTUAL_DIR_VAL" Value="myappdir" />
<!-- +++++++++++++++++++ web app name properties initialize ++++++++++++++++++++ -->
<Property Id="WEB_APP_NAME" Value="myapp" />
<Property Id="WEB_APP_USE_CUSTOM_APP_POOL_IDENTITY" Value="1" />
<!-- +++++++++++++++++++ app pool identity properties initialize +++++++++++++++ -->
<Property Id="WEB_APP_POOL_IDENTITY_DOMAIN" Value="domain" />
<Property Id="WEB_APP_POOL_IDENTITY_NAME" Value="user" />
<Property Id="WEB_APP_POOL_IDENTITY_PWD" Hidden="yes" />
<!-- Reference to IIS Website to install to, but not create -->
<iis:WebSite Id='rootwebsite'
Description='[IIS_WEBSITE]'
Directory='INSTALLFOLDER'>
<!-- This element has to be here or WiX does not compile. It’s ignored
in this case. -->
<iis:WebAddress Id="AllUnassignedHTTP" Port="80" />
<iis:WebAddress Id="AllUnassignedHTTPS" Port="443" />
</iis:WebSite>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="InstallWebsiteCustomUser" Guid="[guid]" KeyPath="yes" Win64="yes">
<Condition><![CDATA[WEB_APP_USE_CUSTOM_APP_POOL_IDENTITY = 1]]></Condition>
<util:User Id="WebAppPoolUser"
CreateUser="no"
Name="[WEB_APP_POOL_IDENTITY_NAME]"
Password="[WEB_APP_POOL_IDENTITY_PWD]"
Domain="[WEB_APP_POOL_IDENTITY_DOMAIN]" />
<iis:WebAppPool Id="WebAppPoolCustom"
Name="[WEB_APP_NAME]"
Identity="other"
User="WebAppPoolUser"
ManagedPipelineMode="Integrated"
ManagedRuntimeVersion="v4.0"
RecycleMinutes="200" />
<iis:WebVirtualDir Id="WebVirtualDirCustom"
Alias="[VIRTUAL_DIR_VAL]"
Directory="INSTALLFOLDER"
WebSite="rootwebsite">
<!-- Turn the Virtual Directory into a web application. -->
<iis:WebApplication Id="WebApplicationCustom"
Name="[WEB_APP_NAME]"
WebAppPool="WebAppPoolCustom" />
</iis:WebVirtualDir>
</Component>
<Component Id="InstallWebsite" Guid="[guid]" KeyPath="yes" Win64="yes">
<Condition><![CDATA[WEB_APP_USE_CUSTOM_APP_POOL_IDENTITY <> 1]]></Condition>
<iis:WebAppPool Id="WebAppPool"
Name="[WEB_APP_NAME]"
Identity="applicationPoolIdentity"
ManagedPipelineMode="Integrated"
ManagedRuntimeVersion="v4.0"
RecycleMinutes="200"/>
<iis:WebVirtualDir Id="WebVirtualDir"
Alias="[VIRTUAL_DIR_VAL]"
Directory="INSTALLFOLDER"
WebSite="rootwebsite">
<!-- Turn the Virtual Directory into a web application. -->
<iis:WebApplication Id="WebApplication"
Name="[WEB_APP_NAME]"
WebAppPool="WebAppPool" />
</iis:WebVirtualDir>
</Component>
</DirectoryRef>
<ComponentGroup Id="IisConfiguration">
<ComponentRef Id="InstallWebsiteCustomUser" />
<ComponentRef Id="InstallWebsite" />
</ComponentGroup>
</Fragment>
</Wix>
这篇关于我可以允许用户选择 applicationPoolIdentity 或使用 WiX-IIS 扩展指定用户吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!