Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static MembershipUserCollection FindUsersByRole(string[] roles)
- {
- MembershipUserCollection msc = new MembershipUserCollection();
- roles.Select(role => Roles.GetUsersInRole(role))
- .Aggregate((a, b) => a.Union(b).ToArray())
- .Distinct()
- .Select( user => Membership.GetUser(user))
- .ToList().ForEach( user => msc.Add(user));
- return msc;
- }
- public static List<MembershipUser> FindUsersByRole(string[] roles)
- {
- var userList = roles.Select(role => Roles.GetUsersInRole(role))
- .Aggregate((a, b) => a.Union(b).ToArray())
- .Distinct()
- .Select( user => Membership.GetUser(user))
- .ToList();
- return userList;
- }
- public static List<string> FindUsersByRole(string[] roles)
- {
- var userList = roles.Select(role => Roles.GetUsersInRole(role))
- .Aggregate((a, b) => a.Union(b).ToArray())
- .Distinct()
- .ToList();
- return userList;
- }
- List<string> roleset_to_find = new List<string>() {"RoleA","RoleB"};
- List<string> membersFound = new List<string>();
- foreach (string role in roleset_to_find)
- {
- membersFound.AddRange(Roles.GetUsersInRole(role));
- }
- string[] roles = {"role1", "role2" };
- string[] tempusers = new string[]{};
- List<string> users = new List<string>();
- foreach (string role in roles)
- {
- string[] usersInRole = Roles.GetUsersInRole(role);
- users = tempusers.Union(usersInRole).ToList();
- tempusers = users.ToArray();
- }
- foreach (string user in users) { Response.Write(user + "<br/>"); }
Add Comment
Please, Sign In to add comment