public AccessControlEntry(AccessControlEntry 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; }
public AccessControlEntry(AccessControlEntry original) { accountSID = original.accountSID; aceType = original.aceType; flags = original.flags; inheritObjectGuid = original.inheritObjectGuid; objectGuid = original.objectGuid; rights = original.rights; }
public static AccessControlEntry AccessControlEntryFromString(string aceString) { Regex aceRegex = new Regex(aceExpr, RegexOptions.IgnoreCase); Match aceMatch = aceRegex.Match(aceString); if (!aceMatch.Success) { throw new FormatException("Invalid ACE String Format"); } AccessControlEntry ace = new AccessControlEntry(); if (aceMatch.Groups["ace_type"] != null && aceMatch.Groups["ace_type"].Success && !string.IsNullOrEmpty(aceMatch.Groups["ace_type"].Value)) { int aceTypeValue = Array.IndexOf(aceTypeStrings, aceMatch.Groups["ace_type"].Value.ToUpper()); if (aceTypeValue == -1) { throw new FormatException("Invalid ACE String Format"); } ace.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 (int i = 0; i < aceFlagsValue.Length - 1; i += 2) { int flagValue = Array.IndexOf(aceFlagStrings, aceFlagsValue.Substring(i, 2)); if (flagValue == -1) { throw new FormatException("Invalid ACE String Format"); } ace.flags = ace.flags | ((AceFlags)(int)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 (int i = 0; i < rightsValue.Length - 1; i += 2) { int rightValue = Array.IndexOf(rightsStrings, rightsValue.Substring(i, 2)); if (rightValue == -1) { throw new FormatException("Invalid ACE String Format"); } ace.Add((AceRights)(int)Math.Pow(2.0d, rightValue)); } } if (aceMatch.Groups["object_guid"] != null && aceMatch.Groups["object_guid"].Success && !string.IsNullOrEmpty(aceMatch.Groups["object_guid"].Value)) { ace.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)) { ace.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)) { ace.AccountSID = SecurityIdentity.SecurityIdentityFromString(aceMatch.Groups["account_sid"].Value.ToUpper()); } else { throw new FormatException("Invalid ACE String Format"); } return(ace); }