ReportingService2010.CreateRole(String, String, String[]) 方法

定义

将新的角色添加到报表服务器数据库。 此方法仅适用于本机模式。

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);
[<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")>]
member this.CreateRole : string * string * string[] -> unit
Public Sub CreateRole (Name As String, Description As String, TaskIDs As String())

参数

Name
String

新角色的名称。 此参数值的长度必须介于 1 到 260 个字符之间。

Description
String

对新角色的描述。 此参数值的长度必须介于 1 到 512 个字符之间。

TaskIDs
String[]

一个任务 ID 的数组,这些任务 ID 表示要为角色设置的任务。

属性

示例

若要编译此代码示例,必须引用Reporting Services WSDL 并导入某些命名空间。 有关详细信息,请参阅 编译和运行代码示例。 下面的代码示例使用 CreateRole 方法创建有权查看文件夹和报表的用户角色:

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());  
      }  
  }  
}  

注解

下表显示了有关此操作的标头和权限信息。

SOAP 标头用法 (In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue
本机模式所需权限 CreateRoles (系统)
SharePoint 模式所需权限 不支持

此方法在 OperationNotSupportedSharePointMode SharePont 模式下调用时引发异常。

NameDescription 参数是必需的,不应在 Visual Basic) 中设置为 null (Nothing。 的值必须是唯一的 Name

必须向角色分配至少一个任务。 不能在单个角色中合并系统级和项级任务。 有关任务的详细信息,请参阅 任务和权限

适用于