Esempio n. 1
0
        /// <summary>
        /// Turns the on is inherited.
        /// </summary>
        public void TurnOnIsInherited()
        {
            using (IDataReader fileReader = DBDirectory.GetById(this.OwnerDirectoryId))
            {
                if (fileReader.Read())
                {
                    int ParentDirectoryId = (int)fileReader["ParentDirectoryId"];

                    using (IDataReader aclReader = DBAccessControlList.GetAcl(ParentDirectoryId))
                    {
                        while (aclReader.Read())
                        {
                            this.Add(AccessControlEntry.InternalCreate((int)aclReader["AceId"],
                                                                       true,
                                                                       (string)SqlHelper.DBNull2Null(aclReader["role"]),
                                                                       (int)SqlHelper.DBNull2Null(aclReader["principalId"], 0),
                                                                       (string)SqlHelper.DBNull2Null(aclReader["action"]),
                                                                       (bool)(((byte)SqlHelper.DBNull2Null(aclReader["allow"])) == 1),
                                                                       false));
                        }
                    }
                }
            }

            _isInherited = true;
            SetChanged();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AccessControlList"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal AccessControlList(IDataReader reader)
        {
            bool bFirstRun = true;

            while (reader.Read())
            {
                if (bFirstRun)
                {
                    _id                      = (int)reader["AclId"];
                    _isInherited             = (bool)reader["AclIsInherited"];
                    _isInheritedInitialValue = _isInherited;
                    _ownerDirectoryId        = (int)reader["DirectoryId"];
                    bFirstRun                = false;
                }

                if (reader["AceId"] != DBNull.Value)
                {
                    this.Add(AccessControlEntry.InternalCreate((int)reader["AceId"],
                                                               (bool)reader["IsInherited"],
                                                               (string)SqlHelper.DBNull2Null(reader["role"]),
                                                               (int)SqlHelper.DBNull2Null(reader["principalId"], 0),
                                                               (string)SqlHelper.DBNull2Null(reader["action"]),
                                                               (bool)(((byte)SqlHelper.DBNull2Null(reader["allow"])) == 1),
                                                               false));
                }
            }

            _isInheritedInitialValue = _isInherited;

            Reset();
        }
Esempio n. 3
0
 /// <summary>
 /// Adds the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public int Add(AccessControlEntry item)
 {
     // Check item originality
     if (!CheckAceOriginality(item))
     {
         return(this.List.Add(item));
     }
     return(-1);
 }
Esempio n. 4
0
        /// <summary>
        /// Checks the ace originality.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public bool CheckAceOriginality(AccessControlEntry item)
        {
            foreach (AccessControlEntry ace in this)
            {
                if (ace.IsIherited == item.IsIherited &&
                    !ace.IsInternal &&
                    ace.PrincipalId == item.PrincipalId &&
                    ace.Role == item.Role &&
                    ace.Action == item.Action &&
                    ace.Allow == item.Allow)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
        /// <summary>
        /// Turns the off is inherited.
        /// </summary>
        /// <param name="bCopyACL">if set to <c>true</c> [b copy ACL].</param>
        public void TurnOffIsInherited(bool bCopyACL)
        {
            for (int index = this.InnerList.Count - 1; index >= 0; index--)
            {
                if (this[index].IsIherited)
                {
                    if (bCopyACL)
                    {
                        AccessControlEntry tmpAce = this[index];
                        tmpAce.SetIsInherited(false);
                        this.InnerList.RemoveAt(index);
                        this.Add(tmpAce);
                    }
                    else
                    {
                        this.InnerList.RemoveAt(index);
                    }
                }
            }

            _isInherited = false;
            SetChanged();
        }
Esempio n. 6
0
 public DACLItem(string filter, AccessControlEntry ace)
 {
     this.Filter = filter;
     this.Ace    = ace;
 }
Esempio n. 7
0
 /// <summary>
 /// Determines whether [contains] [the specified item].
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>
 ///     <c>true</c> if [contains] [the specified item]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AccessControlEntry item)
 {
     return(this.List.Contains(item));
 }
Esempio n. 8
0
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(AccessControlEntry item)
 {
     this.List.Remove(item);
 }
Esempio n. 9
0
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(AccessControlEntry item)
 {
     this.List.Remove(item);
 }
Esempio n. 10
0
 /// <summary>
 /// Determines whether [contains] [the specified item].
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>
 /// 	<c>true</c> if [contains] [the specified item]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(AccessControlEntry item)
 {
     return this.List.Contains(item);
 }
Esempio n. 11
0
        /// <summary>
        /// Checks the ace originality.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public bool CheckAceOriginality(AccessControlEntry item)
        {
            foreach(AccessControlEntry ace in this)
            {
                if(ace.IsIherited==item.IsIherited&&
                    !ace.IsInternal&&
                    ace.PrincipalId==item.PrincipalId&&
                    ace.Role==item.Role&&
                    ace.Action==item.Action&&
                    ace.Allow==item.Allow)
                {
                    return true;
                }
            }

            return false;
        }
Esempio n. 12
0
 /// <summary>
 /// Adds the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public int Add(AccessControlEntry item)
 {
     // Check item originality
     if(!CheckAceOriginality(item))
         return this.List.Add(item);
     return -1;
 }
Esempio n. 13
0
 public DACLItem(string filter, AccessControlEntry ace)
 {
     this.Filter = filter;
     this.Ace = ace;
 }
Esempio n. 14
0
 internal void Add(string filter, AccessControlEntry ace)
 {
     _items.Add(new DACLItem(filter, ace));
 }