Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Service 如何在以用户帐户安装服务时验证用户?_Service_Wix - Fatal编程技术网

Service 如何在以用户帐户安装服务时验证用户?

Service 如何在以用户帐户安装服务时验证用户?,service,wix,Service,Wix,我正在使用wix创建一个安装程序。我需要以安装过程中给定的用户帐户安装服务。但是,在安装服务之前,我如何验证用户和密码是否有效,以及是否有足够的权限安装服务。有没有办法做到这一点 wix中的以下代码帮助我安装服务 <ServiceInstall Id="AServiceInstall" DisplayName="myservice" Name="myservice" ErrorControl="normal" Start="auto" Vital="yes" Type="ownPr

我正在使用wix创建一个安装程序。我需要以安装过程中给定的用户帐户安装服务。但是,在安装服务之前,我如何验证用户和密码是否有效,以及是否有足够的权限安装服务。有没有办法做到这一点

wix中的以下代码帮助我安装服务

<ServiceInstall Id="AServiceInstall" DisplayName="myservice"     Name="myservice" ErrorControl="normal" Start="auto" Vital="yes" Type="ownProcess" Account="[ACCOUNT]" Password="[PASSWORD]">
            <ServiceDependency Id="x"></ServiceDependency>
          </ServiceInstall>

为了验证复杂的用户输入,我通常需要创建一个自定义操作来完成

下面是一个示例对话框,用于验证web服务的URL并确保其可访问:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
    <CustomAction Id="ValidateProxyService" BinaryKey="XXX.CommServer.CustomActions.dll" DllEntry="ValidateProxyService" Return="check" />

    <UI>
      <Dialog Id="XxxInquiryServiceDlg" Width="370" Height="270" Title="CommService Setup">
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="2" />
        <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Configure the settings for the xxx." />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="210" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Configure xxx" />
        <Control Type="Text" Id="ProxyServiceLabel" Width="95" Height="10" X="11" Y="60" Text="XXX Proxy Service URL:" />
        <Control Type="Edit" Id="ProxyServiceTextBox" Width="244" Height="15" X="112" Y="58" Property="XXX_PROXY_SERVICE_URL" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
          <Publish Event="DoAction" Value="ValidateProxyService" Order="1">1</Publish>
        </Control>
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />        
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>          
        </Control>
      </Dialog>
    </UI>
  </Fragment>
</Wix>
该对话框要求一个URL并将其放入XXX\u PROXY\u SERVICE\u URL属性中,这是对当前情况的总体概述。当您按下对话框上的“下一步”按钮时,它将运行自定义操作。然后,自定义操作读取XXX_PROXY_SERVICE_URL并测试其是否有效并尝试加载页面。如果无效或失败,它将取消XXX\u PROXY\u SERVICE\u VALID属性

在安装程序的主UI中,我有:

<Publish Dialog="XXXServiceDlg" Control="Next" Event="NewDialog" Value="OtherDlg" Order="2">XXX_PROXY_SERVICE_VALID</Publish>
XXX\u代理\u服务\u有效
因此,如果服务无效,它将无法进入下一页

有几点需要注意:

  • 我只是显示一个警告对话框,询问他们是否希望继续(是/否),即使输入无效,但在现在无法访问服务但他们仍需要完成安装的情况下
  • 我真的很想使用WIX对话框处理消息对话框。因为我无法获得安装程序窗口的句柄,所以在我还不知道的某些情况下,使用MessageBox类往往会在安装程序下弹出。我还认为在WIX中处理所有UI会更干净
  • 某些需要验证的有用内容需要管理员访问。这会在生成MSI时产生恼人的可用性影响。要以管理员身份运行MSI的UI部分,需要通过具有管理员访问权限的命令行启动它,或生成引导程序(.exe),该引导程序由用户告知以管理员身份运行,或配置为具有管理员访问权限启动
需要填写的一些空白:

  • 在WIX中使用自定义操作所缺少的所有详细信息
  • 检查用户凭据是否有效及其权限的确切方法

一旦你弄明白了这两件事,调整上述策略来验证任意用户输入应该不会太困难。

你可能需要重新表述这个问题。您所说的凭据需要足够的特权才能作为服务运行—正如您的问题所暗示的,它们不用于安装服务。安装本身将(或应该!)请求UAC系统上的提升,并为您安装服务

验证的第一部分基于调用LogonUser(),类似的内容是API使用指南

这里也有一些讨论:

<Publish Dialog="XXXServiceDlg" Control="Next" Event="NewDialog" Value="OtherDlg" Order="2">XXX_PROXY_SERVICE_VALID</Publish>