예제 #1
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();
        }
예제 #2
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();
        }