How to access roles through API

  • 16 February 2008
  • 2 replies
  • 1 view

Badge +8

Hey Everyone,


                      Can anyone tell me how to access black pearl "roles" through code. ?. I need to create a function which accepts role name and then gives back collection of username?


 


Thanks in advance


 


2 replies

Badge +6
Try SourceCode.Workflow.Management API..?
Badge +5

Hi,


I would recommend you to do this through a SmartObject using the URM(UserRoleManager) ServiceObject, but you could also do this through the URM API as described below.


You need to reference the following assemblies :



  • SourceCode.Security.UserRoleManager.Client
  • SourceCode.HostServerInterfaces which contains the IUsers collection and IUser
  • SourceCode.HostClientAPI

The following is a very simple example on how to use the API:


            UserRoleManagerServer urm = new UserRoleManagerServer();
            urm.Connection = urm.CreateConnection();
            //To build up the connection string.
            SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder csb = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
            csb.Host = "blackpearl";
            csb.Integrated = true;
            csb.IsPrimaryLogin = true;
            csb.Port = 5555;
           
//Open the connection using the constr built
            urm.Connection.Open(csb.ToString());
           
//Get a collection of users belonging to a Role
            SourceCode.Hosting.Server.Interfaces.IUserCollection users = urm.ResolveQueue("MyRole");
            //...Rest of code here


Hope this helps.


Gert

Reply