//Get all the groups a user belongs to public GroupList GetUsersGroups(string user) { if (DefaultUsers.IsAnonymous(user)) { return new GroupList() { GetUserGroup(DefaultGroups.AnonymousUsers) } } ; GroupList Result = new GroupList(); var mConnection = GetConnection(); using (var command = mConnection.CreateCommand()) { command.CommandText = "{CALL getUserMembership(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("inusername", user); using (var resultSet = command.ExecuteReader()) { while (resultSet.Read()) { Result.Add(GetUserGroup(resultSet["groupname"].ToString())); } } } bool foundAllUsers = false; foreach (UserGroup ug in Result) { if (ug.GroupName.Equals(DefaultGroups.AllUsers, StringComparison.CurrentCultureIgnoreCase)) { foundAllUsers = true; } } if (!foundAllUsers && UserExists(user)) { Result.Add(GetUserGroup(vwarDAL.DefaultGroups.AllUsers)); } return(Result); }
public GroupList GetGroupsByOwner(string owner) { GroupList results = new GroupList(); var mConnection = GetConnection(); using (var command = mConnection.CreateCommand()) { command.CommandText = "{CALL GetGroupsByOwner(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("inOwner", owner); using (var resultSet = command.ExecuteReader()) { while (resultSet.Read()) { results.Add(PopulateUserGroupFromReader(resultSet)); } } } return(results); }