Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

CreateRole Method

SQL Server 2000

ReportingService.CreateRole Method

Adds a new role to the report server database.

Public Sub CreateRole( _
   ByVal Name As String, _
   ByVal Description As String, _
   ByVal Task() As [Namespace].Task _
   Member of [Namespace].ReportingService

public void CreateRole(
   string Name,
   string Description,
   [Namespace].Task[] Tasks
   Member of [Namespace].ReportingService
The name of the new role. The value of this parameter must be between 1 and 260 characters long.
A description of the new role. The value of this parameter must be between 1 and 512 characters long.
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.

Operation Description
Create Roles Required for creating a role in the report server database.


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.


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 ReportingService()
      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()
         Dim returnedTasks As Task() = rs.ListTasks()
         Dim t As Task
         For Each t In  returnedTasks
            If t.Name = "View reports" Then
               setTasks(0) = t
               If t.Name = "View folders" Then
                  setTasks(1) = t
                  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
      End Try
   End Sub 'Main
End Class 'Sample

using System;
using System.Web.Services.Protocols;

class Sample
   public static void Main()
      ReportingService rs = new ReportingService();
      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();

         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() );
See Also

ReportingService Class

Reporting Services Web Service Library

© 2015 Microsoft