GenerateDatabaseRightsScript Method (WMI MSReportServer_ConfigurationSetting Class)
Generates an SQL Script that can be used to grant a user rights to the report server database.
Syntax
Public Sub GenerateDatabaseRightsScript(UserName as String,_
IsWindowsUser as Boolean, ByRef Script as String,
ByRef HRESULT as Int32)
public void GenerateDatabaseRightsScript (string UserName,
boolean IsWindowsUser, out string Script, out sint32 HRESULT);
Parameters
- UserName
The user name or Windows security identifier (SID) of the user to which the script will grant rights.
- IsWindowsUser
A Boolean value indicating whether the specified user name is a Windows user or a SQL Server user.
- Script
[out] A string containing the generated SQL Server script.
- HRESULT
[out] Value indicating whether the call succeeded or failed.
Return Value
Returns an HRESULT indicating success or failure of the method call. A value of 0 indicates that the method call was successful. A non-zero value indicates that an error has occurred.
备注
If IsWindowsUser is set to true, UserName should be in the format "domain\username".
When IsWindowsUser is set to true, the generated script grants login rights to the user for the SQL Server, setting the report server database as the default database, and grants the RSExec role on the report server database, the report server temporary database, the master database and the MSDB system database.
When IsWindowsUser is set to true, the method accepts standard Windows SIDs as input. When a standard Windows SID or service account name is supplied, it is translated to a user name string. If the database is local, the account is translated to the correct localized representation of the account. If the database is remote, the account is represented as the computer’s account.
The following table shows accounts that are translated and their remote representation.
Account / SID that is translated | Common Name | Remote Name |
---|---|---|
(S-1-5-18) |
Local System |
<Domain>\<ComputerName>$ |
.\LocalSystem |
Local System |
<Domain>\<ComputerName>$ |
ComputerName\LocalSystem |
Local System |
<Domain>\<ComputerName>$ |
LocalSystem |
Local System |
<Domain>\<ComputerName>$ |
(S-1-5-20) |
Network Service |
<Domain>\<ComputerName>$ |
NT AUTHORITY\NetworkService |
Network Service |
<Domain>\<ComputerName>$ |
(S-1-5-19) |
Local Service |
Error – see below. |
NT AUTHORITY\LocalService |
Local Service |
Error – see below. |
On Windows 2000, if you are using a built-in account and the report server database is remote, an error is returned.
If the LocalService built-in account is specified and the report server database is remote, an error is returned.
When IsWindowsUser is true and the value supplied in UserName needs to be translated, the WMI provider determines whether the report server database is located on the same computer or on a remote computer. To determine if the installation is local, the WMI provider evaluates the DatabaseServerName property against the following list of values. If a match is found, the database is local. Otherwise, it is remote. The comparison is case-insensitive.
Value of DatabaseServerName | Example |
---|---|
“.” |
. |
“(local)” |
(local) |
“LOCAL” |
LOCAL |
localhost |
localhost |
<Machinename> |
testlab14 |
<MachineFQDN> |
example.redmond.microsoft.com |
<IPAddress> |
180.012.345,678 |
When IsWindowsUser is set to true, the WMI provider calls LookupAccountName to get the SID for the account and then calls LookupAccountSID to get the name to put in the SQL Server script. This ensures that the account name used will pass SQL Server validation.
When IsWindowsUser is set to false, the generated script grants the RSExec role on the report server database, the report server temporary database, and the MSDB database.
When IsWindowsUser is set to false, the SQL user must already exist on the SQL Server for the script to run successfully.
If the report server does not have a report server database specified, calling GrantRightsToDatabaseUser returns an error.
The generated script supports SQL Server 2000 and SQL Server 2005.
Requirements
Namespace:root\Microsoft\SqlServer\ReportServer\v9\Admin
Platform: Windows Server 2003, Datacenter Edition;Windows Server 2003, Enterprise Edition;Windows Server 2003, Standard Edition;Windows Vista;Windows XP Professional Service Pack 2 (SP2) 或 Service Pack 1 (SP1);或者 Windows 2000(所有版本)
请参阅
参考
MSReportServer_ConfigurationSetting Members
MSReportServer_ConfigurationSettingForSharePoint Members