如何创建对 SQL Server 实例的登录? [英] How to create a login to a SQL Server instance?

查看:51
本文介绍了如何创建对 SQL Server 实例的登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 WiX 3.8 制作了一个引导程序项目.作为安装 SQL Server Express 2012 的先决条件,将SQLExpress"设置为新 SQL Server 实例的名称.然后在 MSI 我想创建一个新的 SQL 用户登录.我用用户元素试过这个,但它似乎不起作用.当我查看 SQL Server 管理工具中的登录信息时,我看不到我的新用户,但我的 MSI 日志告诉我,他是创建的.

I have made a bootstrapper-project with WiX 3.8. As a prerequisite SQL Server Express 2012 is installed, setting "SQLExpress" as name of the new SQL Server instance. Then in the MSI i want to create a new SQL user login. I tried this with the User-element, but it doesn't seem to work. When i take a look to the logins in the SQL Server Management tool, i can't see my new user, but the log from my MSI tells me, that he was created.

我的用户元素版本有问题还是需要我换一种方式?

Is there something wrong with my version of the User-element or have i to take another way?

<Component Id ="CreateUserAccount"
           Guid="AEE91491-99FA-40A9-AB47-1E9FC2DDEF2A"
           Directory="TARGETDIR">
    <util:User Id ="SQLUser"
               Name="[DBUSER_PROP]"
               Password="[DBPW_PROP]"
               UpdateIfExists="no"
               CreateUser="yes"
               PasswordNeverExpires="yes"
               PasswordExpired="no"
               RemoveOnUninstall="no"
               Domain="[ComputerName]">
    </util:User>
</Component>

推荐答案

在 Windows-installer-xml-wix-toolset 的 Phill Hogland 的帮助下,我找到了解决方案.这取决于 PC 上使用的语言.在我的情况下,这是德语,这意味着无法通过名称Users"找到用户组,而是Benutzer".

With the help of Phill Hogland from Windows-installer-xml-wix-toolset i have found the solution. It depends on the language used on the PC. In my case that's german, which means, the group Users cannot be found by the name "Users" but "Benutzer".

这里是正确的代码:

<util:Group Id="Users"
            Name ="Benutzer"
            Domain="[ComputerName]" />
<Component Id ="CreateUserAccount"
           Guid="AEE91491-99FA-40A9-AB47-1E9FC2DDEF2A"
           Directory="TARGETDIR">
    <util:User Id ="SQLUser"
               Name="[DBUSER_PROP]"
               Password="[DBPW_PROP]"
               UpdateIfExists="no"
               CreateUser="yes"
               PasswordNeverExpires="yes"
               PasswordExpired="no"
               RemoveOnUninstall="no">
        <util:GroupRef Id ="Users" />
    </util:User>
</Component>

进一步您可以用包变量替换硬编码的名称.然后你将独立于操作系统语言.

Further You can replace the hardcoded name by a bundle-variable. Then You will be independent from the OS language.

这篇关于如何创建对 SQL Server 实例的登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆