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