/// <summary> /// Gets a list of roles in which a user participates for the configured application name. /// </summary> /// <param name="username">A user for which to return the list of roles.</param> /// <returns>The list of roles to which a user name belongs.</returns> public override string[] GetRolesForUser(string username) { // Create an array of roles to which the specified user name belongs using the DataView created for this purpose. List <string> roles = new List <string>(); foreach (DataRowView dataRowView in this.userView.FindRows(username)) { DataSetRoles.UserRow userRow = dataRowView.Row as DataSetRoles.UserRow; roles.Add(userRow.RoleRowParent.Role); } return(roles.ToArray()); }
/// <summary> /// Removes the specified user names from the specified roles for the configured application name. /// </summary> /// <param name="usernames">A string array of user names to be removed from the specified roles.</param> /// <param name="roleNames">A string array or roles from which the users are removed.</param> public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { // Remove each user name from each role in the configured application name. foreach (string roleName in roleNames) { foreach (string userName in usernames) { DataSetRoles.UserRow userRow = this.dataSetRoles.User.FindByApplicationRoleUser(this.applicationName, roleName, userName); if (userRow != null) { this.dataSetRoles.User.RemoveUserRow(userRow); } } } // Commit the changes to the database. this.dataSetRoles.WriteXml(this.fileName); }