Skip to main content
Nintex Community Menu Bar

Return users from a role?

  • July 16, 2008
  • 4 replies
  • 13 views

Forum|alt.badge.img+2

Hi all!

Ok, I have created a new role called Supervisor in the workspace and have added 3 users to that role. What I want to be able to do now, is return the names of those users that belong to the Supervisor role?

 

Any help on how to go about this will be greatly appreciated!!

 

Thanks!!
 

4 replies

Forum|alt.badge.img+2
  • Author
  • July 16, 2008
Ultimate what I am trying to achieve is check if a given name exits in that role.

Forum|alt.badge.img+1
  • July 16, 2008

Hi,


This is how we getting it...hope it helps.


 The code basically populates a dropdown box with users for a specific role...


 public void GetUserRoleDropDownList(string k2Connectionstring, string role, ref DropDownList ddlReasignUser)
        {
            if (k2Connectionstring != "" && role != "")
            {


               XmlDocument doc;
               XmlElement root;

                SourceCode.Security.UserRoleManager.Management.UserRoleManager sm = new SourceCode.Security.UserRoleManager.Management.UserRoleManager();


                sm.CreateConnection();
                sm.Connection.Open(k2Connectionstring);
                SourceCode.Security.UserRoleManager.Management.Role[] RoleList = sm.GetRoles(role);


                foreach (SourceCode.Security.UserRoleManager.Management.Role Role in RoleList)
                {


                    doc = new XmlDocument();
                    doc.LoadXml(Role.GetData());
                    XmlElement root = doc.DocumentElement;
                    XmlNodeList nodes = root.SelectNodes("/role/include/users"); // You can filter elements


                    foreach (XmlNode node in nodes)
                    {


                        XmlNodeList innerNodes = node.SelectNodes("user");
                        foreach (XmlNode innerNode in innerNodes)
                        {
                            string userName = innerNode.Attributes[0].Value;


                            //Remove(0,3) needed for K2: security label trimming.
                            ddlReasignUser.Items.Add(userName.Remove(0, 3));
                        }



                    }


                }
            }


 


Forum|alt.badge.img+2
  • Author
  • July 18, 2008
Thanks!! That helped a lot!!!!

Forum|alt.badge.img+11
  • July 18, 2008
You can also do this without code by connecting a SmartObject to the User Role Manager Service.  In the User ServiceObject, invoke the Get Role Users method and pass in the name of a role to get back a list of the members.