ReportingService2010.CreateRole(String, String, String[]) ReportingService2010.CreateRole(String, String, String[]) ReportingService2010.CreateRole(String, String, String[]) Method

定义

将新的角色添加到报表服务器数据库。 Adds a new role to the report server database. 此方法仅适用于本机模式。 This method only applies to native mode.

public:
 void CreateRole(System::String ^ Name, System::String ^ Description, cli::array <System::String ^> ^ TaskIDs);
[System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateRole", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
[System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)]
[System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")]
public void CreateRole (string Name, string Description, string[] TaskIDs);
Public Sub CreateRole (Name As String, Description As String, TaskIDs As String())
参数
Name
String String String

新角色的名称。 The name of the new role. 此参数值的长度必须介于 1 到 260 个字符之间。 The value of this parameter must be between 1 and 260 characters long.

Description
String String String

对新角色的描述。 A description of the new role. 此参数值的长度必须介于 1 到 512 个字符之间。 The value of this parameter must be between 1 and 512 characters long.

TaskIDs
String[]

一个任务 ID 的数组,这些任务 ID 表示要为角色设置的任务。 An array of task IDs that represent the tasks to set for the role.

示例

若要编译此代码示例,必须引用 Reporting 服务 WSDL,并导入某些命名空间。To compile this code example, you must reference the Reporting Services WSDL and import certain namespaces. 有关详细信息,请参阅编译和运行代码示例For more information, see Compiling and Running Code Examples. 下面的代码示例使用CreateRole方法来创建有权查看文件夹和报表的用户角色:The following code example uses the CreateRole method to create a user role that has permissions to view folders and reports:

Imports System  
Imports System.Web.Services.Protocols  

Class Sample  
   Public Shared Sub Main()  
      Dim rs As New ReportingService2010()  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials  

      Try   
         Dim name As String = "Report Browser"   
         Dim desc As String = "View folders and reports."   

         Dim tasks As Task() = rs.ListTasks("All")    
         Dim taskIDs As New List(Of String)()    

         For Each t As Task In tasks    
            taskIDs.Add(t.TaskID)    
         Next   

         rs.CreateRole(name, desc, taskIDs.ToArray())  
      Catch e As SoapException  
         Console.WriteLine(e.Detail.InnerXml.ToString())  
      End Try  
   End Sub 'Main  
End Class 'Sample  
using System;  
using System.Web.Services.Protocols;  

class Sample  
{  
   public static void Main()  
   {  
     ReportingService2010 rs = new ReportingService2010();  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  

      try  
      {  
         string name = "Report Browser";  
       string desc = "View folders and reports.";  

         Task[] tasks = rs.ListTasks("All");  
         List<string> taskIDs = new List<string>();  

         foreach (Task t in tasks)  
         {  
            taskIDs.Add(t.TaskID);  
         }  

         rs.CreateRole(name, desc, taskIDs.ToArray());  
      }  
      catch (SoapException e)  
      {  
         Console.WriteLine(e.Detail.InnerXml.ToString());  
      }  
  }  
}  

注解

下表显示了有关此操作的标头和权限信息。The table below shows header and permissions information on this operation.

SOAP 标头使用情况SOAP Header Usage (In) TrustedUserHeaderValue(In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue(Out) ServerInfoHeaderValue
纯模式所需的权限Native Mode Required Permissions CreateRoles (系统)CreateRoles (System)
SharePoint 模式所需的权限SharePoint Mode Required Permissions 不支持Not supported

此方法将引发OperationNotSupportedSharePointMode异常时在 SharePont 模式下调用。This method throws an OperationNotSupportedSharePointMode exception when invoked in SharePont mode.

NameDescription参数需要,但不应设置为null(Nothing在 Visual Basic 中)。The Name and Description parameters are required and should not be set to null (Nothing in Visual Basic). Name必须是唯一的。The value for Name must be unique.

必须将至少一个任务分配给该角色。You must assign at least one task to the role. 不能合并单个角色中的系统级和项级任务。You cannot combine system-level and item-level tasks within a single role. 有关任务的详细信息,请参阅任务和权限For more information about tasks, see Tasks and Permissions.

适用于