BExIS.Security.Services.Authorization.PermissionManager.HasUserDataAccess C# (CSharp) Метод

HasUserDataAccess() публичный Метод

public HasUserDataAccess ( long userId, long entityId, long dataId, RightType rightType ) : bool
userId long
entityId long
dataId long
rightType RightType
Результат bool
        public bool HasUserDataAccess(long userId, long entityId, long dataId, RightType rightType)
        {
            User user = UsersRepo.Get(userId);

            List<long> subjectIds = new List<long>(user.Groups.Select(g => g.Id));
            subjectIds.Add(user.Id);

            return ExistsDataPermission(subjectIds, entityId, dataId, rightType);
        }

Same methods

PermissionManager::HasUserDataAccess ( string username, long entityId, long dataId, RightType rightType ) : bool

Usage Example

Пример #1
0
        /// <summary>
        /// return true if user has edit rights
        /// </summary>
        /// <returns></returns>
        private bool hasUserEditRights(long entityId)
        {
            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthenticationRigths = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;

            if (user != null)
            {
                userid = subjectManager.GetUserByName(GetUsernameOrDefault()).Id;

                hasAuthenticationRigths = permissionManager.HasUserDataAccess(userid, 1, entityId, RightType.Update);

                return (hasAuthenticationRigths);
            }
            else
            {
               return false;
            }

            #endregion
        }