ReportingService2005.CreateRole(String, String, Task[]) ReportingService2005.CreateRole(String, String, Task[]) ReportingService2005.CreateRole(String, String, Task[]) Method

Definition

Adds a new role to the report server database.

public:
 void CreateRole(System::String ^ Name, System::String ^ Description, cli::array <ReportService2005::Task ^> ^ Tasks);
public void CreateRole (string Name, string Description, ReportService2005.Task[] Tasks);
Public Sub CreateRole (Name As String, Description As String, Tasks As Task())
Parameters
Name
String String String

The name of the new role. The value of this parameter must be between 1 and 260 characters long.

Description
String String String

A description of the new role. The value of this parameter must be between 1 and 512 characters long.

Tasks
Task[]

An array of Task objects that represents the tasks to set for the role. Only the TaskID property of the Task object is submitted to create a role.

Examples

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. 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 ReportingService2005()  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials  

      Dim name As String = "Report Browser"  
      Dim desc As String = "View folders and reports."  
      Dim setTasks(2) As Task  
      setTasks(0) = New Task()  
      setTasks(1) = New Task()  
      setTasks(2) = New Task()  

      Try  
         Dim returnedTasks As Task() = rs.ListTasks()  

         Dim t As Task  
         For Each t In  returnedTasks  
            If t.Name = "View reports" Then  
               setTasks(0) = t  

            Else  
               If t.Name = "View folders" Then  
                  setTasks(1) = t  

               Else  
                  If t.Name = "View resources" Then  
                     setTasks(2) = t  
                  End If  
               End If  
            End If   
         Next t  
         rs.CreateRole(name, desc, setTasks)  

      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()  
   {  
      ReportingService2005 rs = new ReportingService2005();  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  

      string name = "Report Browser";  
      string desc = "View folders and reports.";  
      Task[] setTasks = new Task[3];  
      setTasks[0] = new Task();  
      setTasks[1] = new Task();  
      setTasks[2] = new Task();  

      try  
      {  
         Task[] returnedTasks = rs.ListTasks();  

         foreach( Task t in returnedTasks )  
         {  
            if ( t.Name == "View reports" )  
            {  
               setTasks[0] = t;  
            }  

            else if ( t.Name == "View folders" )  
            {  
               setTasks[1] = t;  
            }  

            else if ( t.Name == "View resources" )  
            {  
               setTasks[2] = t;  
            }  
         }  

         rs.CreateRole( name, desc, setTasks );  
      }  

      catch ( SoapException e )  
      {  
         Console.WriteLine( e.Detail.InnerXml.ToString() );  
      }  
   }  
}  

Remarks

The table below shows header and permissions information on this operation.

SOAP Headers (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
Required Permissions CreateRoles (System)

The Name and Description parameters are required and should not be set to null (Nothing in Visual Basic). 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.

Applies to