public override void DeleteUserFromRole(User user, Role role) { using (var transaction = new TransactionScope(mConfiguration)) { var uirDS = new UserInRoleDataStore(transaction); IList <UserInRole> userInRoles = uirDS.FindForUserAndRole(mApplicationName, user, role); if (userInRoles.Count > 0) { foreach (UserInRole uir in userInRoles) { uirDS.Delete(uir.Id); } transaction.Commit(); } } }
public override string[] FindUsersInRole(string roleName, string usernameToMatch) { var userNames = new List <string>(); using (var transaction = new TransactionScope(mConfiguration)) { var rDS = new RoleDataStore(transaction); Role role = rDS.FindByName(mApplicationName, roleName); var uDS = new UserDataStore(transaction); User user = uDS.FindByName(mApplicationName, usernameToMatch); var userInRoleDataStore = new UserInRoleDataStore(transaction); IList <UserInRole> listUserInRole = userInRoleDataStore.FindForUserAndRole(ApplicationName, user, role); foreach (UserInRole ur in listUserInRole) { userNames.Add(ur.User.Name); } } return(userNames.ToArray()); }