コード例 #1
0
 internal static bool ContainsPermission(PC.Permissions.SCContainerAndPermissionCollection permissions, string containerID, string permission)
 {
     if (permissions == null || string.IsNullOrEmpty(containerID))
     {
         return(false);
     }
     else
     {
         return(permissions.ContainsKey(containerID, permission));
     }
 }
コード例 #2
0
        private static SCContainerAndPermissionCollection GetPrincipalPermissions(IPrincipal principal, params string[] containerIDs)
        {
            string calculatedKey = CalculatePrincipalAndPermissionKey(principal, containerIDs);

            return((SCContainerAndPermissionCollection)ObjectContextCache.Instance.GetOrAddNewValue(calculatedKey, (cache, key) =>
            {
                SCContainerAndPermissionCollection permissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(GetUserID(principal), containerIDs);

                cache.Add(key, permissions);

                return permissions;
            }));
        }
コード例 #3
0
        /// <summary>
        /// 是否拥有指定的权限
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="permissions"></param>
        /// <param name="permissionName"></param>
        /// <param name="containerIDs"></param>
        /// <returns></returns>
        public static bool HasPermissions(this IPrincipal principal, SCContainerAndPermissionCollection permissions, string permissionName, params string[] containerIDs)
        {
            bool result = IsSupervisor(principal);

            if (result == false)
            {
                if (principal != null)
                {
                    permissions.NullCheck("permissions");

                    foreach (string containerID in containerIDs)
                    {
                        if (permissions.ContainsKey(containerID, permissionName))
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }

            return(result);
        }
コード例 #4
0
 public DictionaryDebugView(SCContainerAndPermissionCollection collection)
 {
     this.collection = collection;
 }