Example #1
0
        /// <summary>
        /// Turns the on is inherited.
        /// </summary>
        public void TurnOnIsInherited()
        {
            using (IDataReader fileReader = DBDirectory.GetById(CurrentTimeZoneId, 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,
                                                                       (Guid)SqlHelper.DBNull2Null(aclReader["ownerKey"], Guid.Empty)));
                        }
                    }
                }
            }

            _isInherited = true;
            SetChanged();
        }
Example #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,
                                                               (Guid)SqlHelper.DBNull2Null(reader["ownerKey"], Guid.Empty)));
                }
            }

            _isInheritedInitialValue = _isInherited;

            Reset();
        }
Example #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);
 }
Example #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 &&
                    ace.OwnerKey == item.OwnerKey)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #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();
        }
Example #6
0
 public DACLItem(string filter, AccessControlEntry ace)
 {
     this.Filter = filter;
     this.Ace = ace;
 }
Example #7
0
 internal void Add(string filter, AccessControlEntry ace)
 {
     _items.Add(new DACLItem(filter, ace));
 }
Example #8
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            AccessControlList ACLr = (AccessControlList)ViewState["ACL"];
            AccessControlEntry ACEr;
            string sRight = "";
            switch (ddRights.SelectedValue)
            {
                case "1":
                    sRight = "Read";
                    break;
                case "2":
                    sRight = "Write";
                    break;
                case "3":
                    sRight = "Admin";
                    break;
                default:
                    break;
            }

            if (ddGroups.SelectedValue == "0")
                ACEr = new AccessControlEntry(ddUsers.SelectedValue, sRight, (rbList.SelectedValue == "0"));
            else
            {
                int iPrincipalId = (ddUsers.SelectedValue == "0") ? int.Parse(ddGroups.SelectedValue) : int.Parse(ddUsers.SelectedValue);
                ACEr = new AccessControlEntry(iPrincipalId, sRight, (rbList.SelectedValue == "0"));
            }
            ACLr.Add(ACEr);

            ViewState["ACL"] = ACLr;

            ListItem _li = ddGroups.SelectedItem;
            if (_li != null)
                BindUsers(int.Parse(_li.Value));
            BinddgMembers();
        }
Example #9
0
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(AccessControlEntry item)
 {
     this.List.Remove(item);
 }
Example #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);
 }
Example #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 &&
                    ace.OwnerKey == item.OwnerKey)
                {
                    return true;
                }
            }

            return false;
        }
Example #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;
 }
Example #13
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));
 }
Example #14
0
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(AccessControlEntry item)
 {
     this.List.Remove(item);
 }
Example #15
0
 internal void Add(string filter, AccessControlEntry ace)
 {
     _items.Add(new DACLItem(filter, ace));
 }
Example #16
0
 public DACLItem(string filter, AccessControlEntry ace)
 {
     this.Filter = filter;
     this.Ace    = ace;
 }