Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Trying to get a list of users NOT in a specific security roleTrying to get a list of users NOT in a specific security role
Previous
 
Next
New Post
6/28/2007 11:23 AM
 

OK, I am stumped here.  I am using the code below to loop through the users collection and then check to see it that user is a member of a specific role.  This seems simple enough, however the IsInRole method is returning false for everyone no matter if they are in the role or not.  Any assistance here would be great.

private void BindList()
{
    //Get all users
    ArrayList ar = UserController.GetUsers(PortalId);

    //New arraylist to hold the users that
    //are identified
    ArrayList newAr = new ArrayList();

    //Loop through users to check role membership
    foreach (object o in ar)
    {
      //lblRoleName.Text holds the name of the selected role
      //Example: Administrators
      if (!((UserInfo) o).IsInRole(lblRoleName.Text))
      {
          //If not a member of the role, add them to the list
          newAr.Add(o);
      }
    }

    //Bind list of users not in role
    GridView1.DataSource = newAr;
    GridView1.DataBind();
}


Best Regards,

Robert J Collins | Co-Founder & President

Netlogic Corporation

 
New Post
6/28/2007 3:22 PM
 

Well, I found a workaround that seems to accomplishing what I want (though it is a little less than elegant):

        private void BindList()
        {
            //Get all users
            ArrayList ar = UserController.GetUsers(PortalId);

            //rc.GetRolesByUser()

            //New arraylist to hold the users that
            //are identified
            ArrayList newAr = new ArrayList();

            //Loop through users to check role membership
            foreach (object o in ar)
            {
                //lblRoleName.Text holds the name of the selected role
                //Example: Administrators
                //if (!((UserInfo) o).IsInRole(lblRoleName.Text))
                //{
                //    //If not a member of the role, add them to the list
                //    newAr.Add(o);
                //}

                string[] roles = rc.GetRolesByUser(((UserInfo) o).UserID, PortalId);
                bool NotInRole = true;

                foreach (string s in roles)
                {
                    if(s == lblRoleName.Text)
                    {
                        NotInRole = false;
                        break;
                    }
                }

                //If not a member of the role, add them to the list
                if (NotInRole)
                newAr.Add(o);
            }

            //Bind list of users not in role
            GridView1.DataSource = newAr;
            GridView1.DataBind();
        }


Best Regards,

Robert J Collins | Co-Founder & President

Netlogic Corporation

 
New Post
6/29/2007 10:25 AM
 

Robert - I am glad that you got this working, I too had to do something like this a while back...


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
6/30/2007 8:26 AM
 

Robert,

the issue of your first code is caused by the fact, that the roles property is not populated except for the current user.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Trying to get a list of users NOT in a specific security roleTrying to get a list of users NOT in a specific security role


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out