Beispiel #1
0
        public static void SetGroupPermissions(_GroupInfo group, List <long> permissions)
        {
            if (permissions == null)
            {
                return;
            }

            foreach (long permission in permissions)
            {
                if (permission == 6) // file read
                {
                    group._Permissions[0] = true;
                }
                else if (permission == 8) // file check out
                {
                    group._Permissions[1] = true;
                }
                else if (permission == 5) // file delete conditional
                {
                    group._Permissions[2] = true;
                }
                else if (permission == 81) // admin user write
                {
                    group._IsAdmin = true;
                }
            }
        }
Beispiel #2
0
        public static PermissionState DecodePermissions(int[] permissions, _GroupInfo group)
        {
            // a value of 1 means that access has been granted.
            // a value of 0 (not set) or 2 (denied) results i no access.

            // we assume no read also means no write or delete
            if (permissions[0] != 1 || !group._Permissions[0])
            {
                if (group._IsAdmin)
                {
                    return(PermissionState.READ_ONLY);   // administrators can always read.
                }
                else
                {
                    return(PermissionState.NO_ACCESS);
                }
            }

            // read is granted but not write.  Assume delete is also not granted
            if (permissions[1] != 1 || !group._Permissions[1])
            {
                return(PermissionState.READ_ONLY);
            }

            // read and write granted, but not delete
            if (permissions[2] != 1 || !group._Permissions[2])
            {
                return(PermissionState.READ_WRITE);
            }

            // if we got this far, it means everything was granted
            return(PermissionState.FULL_CONTROL);
        }
Beispiel #3
0
        public static _GroupInfo[] Convert(GroupInfo[] inputArray)
        {
            if (inputArray == null)
            {
                return(null);
            }

            _GroupInfo[] retval = new _GroupInfo[inputArray.Length];

            for (int i = 0; i < inputArray.Length; i++)
            {
                retval[i] = _GroupInfo.Convert(inputArray[i]);
            }

            return(retval);
        }
Beispiel #4
0
 public static PermissionState DecodePermissions(_GroupInfo group)
 {
     return(DecodePermissions(new int[] { 1, 1, 1 }, group));
 }