コード例 #1
0
        /// <summary>
        /// Checks if the specified user is allowed to access this partition.
        /// </summary>
        /// <returns></returns>
        public static bool IsUserAccessAllowed(this ServerPartition partition, CustomPrincipal user)
        {
            Platform.CheckForNullReference(user, "user cannot be null");

            if (partition.ServerPartitionTypeEnum.Equals(ServerPartitionTypeEnum.VFS))
	        {
		        return user.IsInRole(AuthorityTokens.Vfs.ViewPartitions);
	        }

	        // If user has the "access all" token, return true
            if (user.IsInRole(ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllPartitions))
                return true;
            
            // If user belongs to any data access authority group which can access the partition, return true
            var isAllowed = user.Credentials.DataAccessAuthorityGroups != null
                && user.Credentials.DataAccessAuthorityGroups.Any(g => partition.IsAuthorityGroupAllowed(g.ToString()));

            return isAllowed;
        }