private void HandleCheckBoxClick(CheckBox source, AceType aceType, AceRights aceRight) { foreach (var ace in acl) { if (ace.AceType == aceType && ace.AccountSID == selectedUser) { if (source.Checked) { ace.Add(aceRight); } else { ace.Remove(aceRight); } return; } } // The ace type doesn't exist var newAce = new AccessControlEntry(selectedUser) { AceType = aceType }; newAce.Add(aceRight); acl.Add(newAce); }
/// <summary> /// Creates a deep copy of an existing Access Control Entry /// </summary> /// <param name="original">Original AccessControlEntry</param> public AccessControlEntryEx(AccessControlEntryEx original) { this.accountSID = original.accountSID; this.aceType = original.aceType; this.flags = original.flags; this.inheritObjectGuid = original.inheritObjectGuid; this.objectGuid = original.objectGuid; this.rights = original.rights; }
/// <summary> /// AceAssertion constructor /// </summary> /// <param name="aceRight"> /// A single AceRight (e.g.: use AceRights.parseValue(0x00000004) if AceRights.ObjectRight enum does not contain /// desired right.) MUST be specified. /// </param> /// <param name="aceObjFlags">One or more AceObjectFlags, may be null.</param> /// <param name="objectType">Object type GUID. Must be set if Flag.ACE_OBJECT_TYPE_PRESENT is in aceObjFlags</param> /// <param name="inheritedObjectType"> /// Inherited object type GUID. Must be set if Flag.ACE_INHERITED_OBJECT_TYPE_PRESENT is in aceObjFlags /// </param> /// <param name="requiredFlag">Single AceFlag that stipulates an ACE must contain it; may be null.</param> /// <param name="excludedFlag">Single AceFlag that stipulates an ACE must NOT contain it; may be null.</param> public AceAssertion(AceRights aceRight, AceObjectFlags aceObjFlags, Guid?objectType, Guid?inheritedObjectType, AceFlag requiredFlag, AceFlag excludedFlag) { this.aceRight = aceRight; this.aceObjectFlags = aceObjFlags; this.objectType = objectType; this.inheritedObjectType = inheritedObjectType; this.requiredFlag = requiredFlag; this.excludedFlag = excludedFlag; }
private bool GetRightValue(AceType aceType, AceRights aceRight) { foreach (var ace in acl) { if (ace.AceType == aceType && ace.AccountSID == selectedUser) { foreach (var right in ace) { if (right == aceRight) { return(true); } } } } return(false); }
private bool GetRightValue(AceType aceType, AceRights aceRight) { foreach (AccessControlEntry ace in this.acl) { if (ace.AceType == aceType && ace.AccountSID == this.selectedUser) { foreach (AceRights right in ace) { if (right == aceRight) { return(true); } } } } return(false); }
/// <summary> /// Load the ACE from the buffer returning the last ACE segment position into the buffer. /// @param buff source buffer. /// @param start start loading position. /// @return last loading position. /// </summary> public void Parse(BinaryReader buff) { var start = buff.BaseStream.Position; byte[] bytes = NumberFacility.GetBytes(buff.ReadInt32()); this.type = AceTypeExtension.ParseValue(bytes[0]); this.flags = AceFlagExtension.ParseValue(bytes[1]); int size = NumberFacility.GetInt(bytes[3], bytes[2]); this.rights = AceRights.ParseValue(NumberFacility.GetReverseInt(buff.ReadInt32())); if (this.type == AceType.AccessAllowedObjectAceType || this.type == AceType.AccessDeniedObjectAceType) { this.objectFlags = AceObjectFlags.ParseValue(NumberFacility.GetReverseInt(buff.ReadInt32())); if (this.objectFlags.GetFlags().Contains(AceObjectFlags.Flag.AceObjectTypePresent)) { this.objectType = new Guid(buff.ReadBytes(16)); } if (this.objectFlags.GetFlags().Contains(AceObjectFlags.Flag.AceInheritedObjectTypePresent)) { this.inheritedObjectType = new Guid(buff.ReadBytes(16)); } } this.sid = new SID(); this.sid.Parse(buff); if (size > 0) { var lastPos = start + size; this.applicationData = new byte[lastPos - buff.BaseStream.Position]; for (var i = 0; i < applicationData.Length; i++) { this.applicationData[i] = buff.ReadByte(); } } }
/// <summary> /// Sets ACE rights. /// @param rights ACE rights. /// AceRights /// </summary> public void SetRights(AceRights rights) => this.rights = rights;
public CheckAceTypeCheckedHandler(AccessControlRightsListBox parent, AceType aceType, AceRights aceRight) { this.parent = parent; this.aceType = aceType; this.aceRight = aceRight; }
public checkAceTypeCheckedHandler(AccessControlRightsListBox parent, AceType aceType, AceRights aceRight) { this.parent = parent; this.aceType = aceType; this.aceRight = aceRight; }
private void HandleCheckBoxClick(CheckBox source, AceType aceType, AceRights aceRight) { foreach (AccessControlEntry ace in this.acl) { if (ace.AceType == aceType && ace.AccountSID == this.selectedUser) { if (source.Checked) { ace.Add(aceRight); } else { ace.Remove(aceRight); } return; } } // The ace type doesn't exist AccessControlEntry newAce = new AccessControlEntry(this.selectedUser); newAce.AceType = aceType; newAce.Add(aceRight); this.acl.Add(newAce); }
private bool GetRightValue(AceType aceType, AceRights aceRight) { foreach (AccessControlEntry ace in this.acl) { if (ace.AceType == aceType && ace.AccountSID == this.selectedUser) { foreach (AceRights right in ace) { if (right == aceRight) return true; } } } return false; }
/// <summary> /// Creates a Access Control Entry of type AccessAllowed with account SID, Type and Rights /// </summary> /// <param name="account">Account SID</param> /// <param name="aceType">Type of Access Control</param> /// <param name="rights">Rights</param> public AccessControlEntryEx(SecurityIdentity account, AceType aceType, AceRights rights) { this.accountSID = account; this.aceType = aceType; this.rights = rights; }
/// <summary> /// Creates a Access Control Entry from a ACE string /// </summary> /// <param name="aceString">ACE string</param> public AccessControlEntryEx(string aceString) { Regex aceRegex = new Regex(cAceExpr, RegexOptions.IgnoreCase); Match aceMatch = aceRegex.Match(aceString); if (!aceMatch.Success) { throw new FormatException("Invalid ACE String Format"); } if (aceMatch.Groups["ace_type"] != null && aceMatch.Groups["ace_type"].Success && !String.IsNullOrEmpty(aceMatch.Groups["ace_type"].Value)) { Int32 aceTypeValue = Array.IndexOf <string>(AccessControlEntryEx.aceTypeStrings, aceMatch.Groups["ace_type"].Value.ToUpper()); if (aceTypeValue == -1) { throw new FormatException("Invalid ACE String Format"); } this.aceType = ( AceType )aceTypeValue; } else { throw new FormatException("Invalid ACE String Format"); } if (aceMatch.Groups["ace_flags"] != null && aceMatch.Groups["ace_flags"].Success && !String.IsNullOrEmpty(aceMatch.Groups["ace_flags"].Value)) { string aceFlagsValue = aceMatch.Groups["ace_flags"].Value.ToUpper(); for (Int32 i = 0; i < aceFlagsValue.Length - 1; i += 2) { Int32 flagValue = Array.IndexOf <string>(AccessControlEntryEx.aceFlagStrings, aceFlagsValue.Substring(i, 2)); if (flagValue == -1) { throw new FormatException("Invalid ACE String Format"); } this.flags = this.flags | (( AceFlags )( Int32 )Math.Pow(2.0d, flagValue)); } } if (aceMatch.Groups["rights"] != null && aceMatch.Groups["rights"].Success && !String.IsNullOrEmpty(aceMatch.Groups["rights"].Value)) { string rightsValue = aceMatch.Groups["rights"].Value.ToUpper(); for (Int32 i = 0; i < rightsValue.Length - 1; i += 2) { Int32 rightValue = Array.IndexOf <string>(AccessControlEntryEx.rightsStrings, rightsValue.Substring(i, 2)); if (rightValue == -1) { throw new FormatException("Invalid ACE String Format"); } this.rights = this.rights | ( AceRights )( Int32 )Math.Pow(2.0d, rightValue); } } if (aceMatch.Groups["object_guid"] != null && aceMatch.Groups["object_guid"].Success && !String.IsNullOrEmpty(aceMatch.Groups["object_guid"].Value)) { this.objectGuid = new Guid(aceMatch.Groups["object_guid"].Value); } if (aceMatch.Groups["inherit_object_guid"] != null && aceMatch.Groups["inherit_object_guid"].Success && !String.IsNullOrEmpty(aceMatch.Groups["inherit_object_guid"].Value)) { this.inheritObjectGuid = new Guid(aceMatch.Groups["inherit_object_guid"].Value); } if (aceMatch.Groups["account_sid"] != null && aceMatch.Groups["account_sid"].Success && !String.IsNullOrEmpty(aceMatch.Groups["account_sid"].Value)) { this.accountSID = SecurityIdentity.SecurityIdentityFromSIDorAbbreviation(aceMatch.Groups["account_sid"].Value.ToUpper()); } else { throw new FormatException("Invalid ACE String Format"); } }