예제 #1
0
        public bool IsGroupAdmin(string administrator, string groupname)
        {
            GroupList gl = GetGroupsByAdministrator(administrator);

            foreach (UserGroup g in gl)
            {
                if (g.GroupName == groupname)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        //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);
        }
예제 #3
0
        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);
        }