예제 #1
0
        private SharingsWithDetailedAccessMask grabSharingDetails(Entity sharing)
        {
            var result    = new SharingsWithDetailedAccessMask(sharing);
            int arm       = sharing.GetAttributeValue <int>("accessrightsmask");
            int valueleft = arm;

            string userteam = "";

            if (sharing.GetAttributeValue <string>("principaltypecode") == "systemuser")
            {
                userteam = sharing.GetAttributeValue <AliasedValue>("systemuser.domainname").Value.ToString();
            }
            if (sharing.GetAttributeValue <string>("principaltypecode") == "team")
            {
                userteam = sharing.GetAttributeValue <AliasedValue>("team.name").Value.ToString();
            }

            result.sharedWith = userteam;

            foreach (var right in poaAccessMasksRights)
            {
                var enabled = valueleft >= right.Key;
                switch (right.Value)
                {
                case "read":
                    result.read = enabled;
                    break;

                case "write":
                    result.write = enabled;
                    break;

                case "append":
                    result.append = enabled;
                    break;

                case "assign":
                    result.assign = enabled;
                    break;

                case "delete":
                    result.delete = enabled;
                    break;

                case "share":
                    result.share = enabled;
                    break;
                }

                if (enabled)
                {
                    valueleft -= right.Key;
                }
            }

            return(result);
        }
예제 #2
0
        private AccessRights getNewAccessRightMask(SharingsWithDetailedAccessMask sharing)
        {
            List <AccessRights> masks = new List <AccessRights>();

            if (sharing.read)
            {
                masks.Add(AccessRights.ReadAccess);
            }
            if (sharing.write)
            {
                masks.Add(AccessRights.WriteAccess);
            }
            if (sharing.append)
            {
                masks.Add(AccessRights.AppendAccess);
            }
            if (sharing.delete)
            {
                masks.Add(AccessRights.DeleteAccess);
            }
            if (sharing.share)
            {
                masks.Add(AccessRights.ShareAccess);
            }
            if (sharing.assign)
            {
                masks.Add(AccessRights.AssignAccess);
            }

            AccessRights mask = masks[0];

            for (int i = 1; i < masks.Count; i++)
            {
                mask |= masks[i];
            }

            return(mask);
        }