Skip to main content
Nintex Community Menu Bar

How to fetch users from roles programatically

  • July 16, 2009
  • 4 replies
  • 26 views

Forum|alt.badge.img+3

Dear All,


I have a requirement to fetch the users from a role defined in K2 workspace programatically i.e. using K2 APIs.


 I could not get the code to do this. It would be great help if anyone could have done it earlier and share the sample code with me.


Thanks a lot in advance.


 Thanks & Regards


Ajay Gangwar

4 replies

Forum|alt.badge.img+8
  • July 16, 2009

Ajay, here is a code snippet on how it can be done:


(This Code is used in a Server Event, depending on where you use the code, you might get the Connection String from somewhere else)


using SourceCode.Security.UserRoleManager.Management;


.


.


.


.


string conStr = K2.StringTable["SmartObject Server"].Replace(" ","");


Role role = new Role();


UserRoleManager roleManager = new UserRoleManager();


 roleManager.CreateConnection();


roleManager.Connection.Open(conStr);


role = roleManager.GetRole("HR Manager");


verifyUser = role.Include[0].Name.ToUpper();


 


Forum|alt.badge.img+3

Dear Deon,


 Thanks a lot. It really helped me a lot.


 Thank you very much.


Thanks & Regards


Ajay Gangwar


Forum|alt.badge.img+3
  • August 20, 2009

Hi there,


How to fetch the email address from the roles?


Regards


Amarnath


Forum|alt.badge.img+8
  • August 21, 2009

You can query the AD to get the email addresses using the AD user service object.


Can you state why you need the email address ? when u assign the role as the destination to an activity. their email are resolved at runtime and emails are sent to appropriate users choosing destination user in the mail event