예제 #1
0
        /// <summary>
        /// Checks if the user of the current context(session) has the ability to perform the action right on the system.
        /// If this is correct, true is returned, otherwise false.
        /// </summary>
        /// <param name="actionRightID">Actionright to check. This is a system action right</param>
        /// <returns>True if the user of the current context is allowed to perform the action right on the
        /// system, false otherwise.</returns>
        public static bool HasSystemActionRight(ActionRights actionRightID)
        {
            ActionRightCollection actionRights = GetSystemActionRights();

            if (actionRights != null && actionRights.Count > 0)
            {
                // use the FindMatches routine to find all entities which match with the filter on the specified actionrightid
                return(actionRights.FindMatches((ActionRightFields.ActionRightID == (int)actionRightID)).Count > 0);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Determines whether the user can administrate the system in one way or the other.
        /// </summary>
        /// <returns>true if the user can administrate system, user or security</returns>
        public static bool CanAdministrate()
        {
            ActionRightCollection actionRights = GetSystemActionRights();

            if ((actionRights == null) || (actionRights.Count <= 0))
            {
                return(false);
            }
            // use FindMatches to determine if there are actionrights present which allow administation.
            List <int> toFind = new List <int>();

            toFind.Add((int)ActionRights.SystemManagement);
            toFind.Add((int)ActionRights.SecurityManagement);
            toFind.Add((int)ActionRights.UserManagement);

            return(actionRights.FindMatches((ActionRightFields.ActionRightID == toFind)).Count > 0);
        }