A class that stores the components of ACE within a DACL.
Example #1
0
        /// <summary>
        /// Extracts a list of ACEs from a SDDL string.
        /// </summary>
        public static IList <AccessControlEntity> Parse(string sddl)
        {
            List <AccessControlEntity> entities = new List <AccessControlEntity>();

            if (!sddl.StartsWith("D:", StringComparison.Ordinal))
            {
                throw new ArgumentException(Utils.Format("Could not parse SDDL string: {0}", sddl));
            }

            sddl = sddl.Substring(2, sddl.Length - 2);

            string[] aces = sddl.Split('(', ')');

            for (int ii = 0; ii < aces.Length; ii++)
            {
                if (String.IsNullOrEmpty(aces[ii]))
                {
                    continue;
                }

                AccessControlEntity entity = new AccessControlEntity();
                entity.Initialize(aces[ii]);
                entities.Add(entity);
            }

            return(entities);
        }
Example #2
0
        /// <summary>
        /// Extracts the access rules from the SDDL string.
        /// </summary>
        private static void ParseSddl(string url, string sddl, List <HttpAccessRule> accessRules)
        {
            IList <AccessControlEntity> entities = AccessControlEntity.Parse(sddl);

            for (int ii = 0; ii < entities.Count; ii++)
            {
                AccessControlEntity entity = entities[ii];

                if (entity.AccessType != "A")
                {
                    continue;
                }

                ApplicationAccessRight rights = ApplicationAccessRight.None;

                switch (entity.Rights)
                {
                case "GA":
                case "GXGW":
                case "GWGX":
                {
                    rights = ApplicationAccessRight.Configure;
                    break;
                }

                case "GX":
                {
                    rights = ApplicationAccessRight.Run;
                    break;
                }
                }

                if (rights == ApplicationAccessRight.None)
                {
                    continue;
                }

                string accountName = ApplicationAccessRule.SidToAccountName(entity.AccountSid);

                if (String.IsNullOrEmpty(accountName))
                {
                    continue;
                }

                HttpAccessRule rule = new HttpAccessRule();

                rule.UrlPrefix    = url;
                rule.Right        = rights;
                rule.IdentityName = accountName;

                accessRules.Add(rule);
            }
        }
Example #3
0
        /// <summary>
        /// Extracts the access rules from the SDDL string.
        /// </summary>
        private static void ParseSddl(string url, string sddl, List <HttpAccessRule> accessRules)
        {
            IList <AccessControlEntity> entities = AccessControlEntity.Parse(sddl);

            for (int ii = 0; ii < entities.Count; ii++)
            {
                AccessControlEntity entity = entities[ii];

                if (entity.AccessType != "A")
                {
                    continue;
                }

                ApplicationAccessRight rights = ApplicationAccessRight.None;

                switch (entity.Rights)
                {
                case "GA":
                case "GXGW":
                case "GWGX":
                {
                    rights = ApplicationAccessRight.Configure;
                    break;
                }

                case "GX":
                {
                    rights = ApplicationAccessRight.Run;
                    break;
                }
                }

                if (rights == ApplicationAccessRight.None)
                {
                    continue;
                }
            }
        }
        /// <summary>
        /// Extracts a list of ACEs from a SDDL string.
        /// </summary>
        public static IList<AccessControlEntity> Parse(string sddl)
        {
            List<AccessControlEntity> entities = new List<AccessControlEntity>();

            if (!sddl.StartsWith("D:", StringComparison.Ordinal))
            {
                throw new ArgumentException(Utils.Format("Could not parse SDDL string: {0}", sddl));
            }

            sddl = sddl.Substring(2, sddl.Length-2);

            string[] aces = sddl.Split('(', ')');

            for (int ii = 0; ii < aces.Length; ii++)
            {
                if (String.IsNullOrEmpty(aces[ii]))
                {
                    continue;
                }
                
                AccessControlEntity entity = new AccessControlEntity();
                entity.Initialize(aces[ii]);
                entities.Add(entity);
            }

            return entities;
        }