Пример #1
0
        private static int ParseSddlAliasRights(string accessMask)
        {
            int ret = 0;

            int pos = 0;

            while (pos < accessMask.Length - 1)
            {
                string          flag  = accessMask.Substring(pos, 2);
                SddlAccessRight right = SddlAccessRight.LookupByName(flag);
                if (right == null)
                {
                    throw new ArgumentException("Invalid SDDL string.", "accessMask");
                }

                ret |= right.Value;
                pos += 2;
            }

            if (pos != accessMask.Length)
            {
                throw new ArgumentException("Invalid SDDL string.", "accessMask");
            }

            return(ret);
        }
Пример #2
0
        private static string GetSddlAliasRights(int accessMask)
        {
            SddlAccessRight[] rights = SddlAccessRight.Decompose(accessMask);
            if (rights == null)
            {
                return(null);
            }

            StringBuilder ret = new StringBuilder();

            foreach (var right in rights)
            {
                ret.Append(right.Name);
            }

            return(ret.ToString());
        }