internal static QueryFilter ConstructRoleEntryFilter(string name, ManagementRoleEntryType type, string snapinName) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } char value; switch (type) { case ManagementRoleEntryType.Cmdlet: value = 'c'; goto IL_52; case ManagementRoleEntryType.Script: value = 's'; goto IL_52; case ManagementRoleEntryType.Cmdlet | ManagementRoleEntryType.Script: break; case ManagementRoleEntryType.ApplicationPermission: value = 'a'; goto IL_52; default: if (type == ManagementRoleEntryType.WebService) { value = 'w'; goto IL_52; } break; } throw new ArgumentOutOfRangeException("type"); IL_52: StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(value); stringBuilder.Append(','); stringBuilder.Append(name); if (type == ManagementRoleEntryType.Cmdlet && !string.IsNullOrEmpty(snapinName)) { stringBuilder.Append(','); stringBuilder.Append(snapinName); } stringBuilder.Append(','); stringBuilder.Append('*'); stringBuilder.Replace('?', '*'); return(RBACHelper.ConstructRoleEntryFilter(stringBuilder.ToString())); }
protected override void InternalValidate() { TaskLogger.LogEnter(new object[] { this.Identity }); ((IConfigurationSession)base.DataSession).SessionSettings.IsSharedConfigChecked = true; this.ConfigurationSession.SessionSettings.IsSharedConfigChecked = true; this.Identity.Parameters = this.Parameters; this.Identity.PSSnapinName = this.PSSnapinName; if (this.Type != null && this.Type.Length > 0) { ManagementRoleEntryType managementRoleEntryType = (ManagementRoleEntryType)0; foreach (ManagementRoleEntryType managementRoleEntryType2 in this.Type) { managementRoleEntryType |= managementRoleEntryType2; } this.Identity.Type = managementRoleEntryType; } base.InternalValidate(); TaskLogger.LogExit(); }
// Token: 0x06000E39 RID: 3641 RVA: 0x0002A54A File Offset: 0x0002874A public RoleEntryIdParameter(ADObjectId adObjectId, string cmdletOrScriptName, ManagementRoleEntryType type) : this(new RoleIdParameter(adObjectId), cmdletOrScriptName, type) { }
// Token: 0x06000E38 RID: 3640 RVA: 0x0002A4FC File Offset: 0x000286FC public RoleEntryIdParameter(RoleIdParameter roleId, string cmdletOrScriptName, ManagementRoleEntryType type) : base(roleId.RawIdentity) { if (string.IsNullOrEmpty(cmdletOrScriptName)) { this.cmdletOrScriptName = "*"; } else { this.cmdletOrScriptName = cmdletOrScriptName; } this.roleId = roleId; this.Type = type; }
internal static QueryFilter ConstructRoleEntryFilter(string name, ManagementRoleEntryType type) { return(RBACHelper.ConstructRoleEntryFilter(name, type, null)); }
internal static bool DoesRoleEntryMatchNameAndParameters(RoleEntry roleEntry, ManagementRoleEntryType type, string name, string[] parameters, string snapinName) { if (null == roleEntry) { throw new ArgumentNullException("roleEntry"); } ManagementRoleEntryType managementRoleEntryType = (ManagementRoleEntryType)0; if (roleEntry is CmdletRoleEntry) { managementRoleEntryType = ManagementRoleEntryType.Cmdlet; } else if (roleEntry is ScriptRoleEntry) { managementRoleEntryType = ManagementRoleEntryType.Script; } else if (roleEntry is ApplicationPermissionRoleEntry) { managementRoleEntryType = ManagementRoleEntryType.ApplicationPermission; } else if (roleEntry is WebServiceRoleEntry) { managementRoleEntryType = ManagementRoleEntryType.WebService; } if ((type & managementRoleEntryType) == (ManagementRoleEntryType)0 && type != ManagementRoleEntryType.All) { return(false); } if (!string.IsNullOrEmpty(snapinName)) { if (managementRoleEntryType != ManagementRoleEntryType.Cmdlet) { return(false); } Regex regex = new Regex(Wildcard.ConvertToRegexPattern(snapinName), RegexOptions.IgnoreCase); if (!regex.IsMatch(((CmdletRoleEntry)roleEntry).PSSnapinName)) { return(false); } } if (!string.IsNullOrEmpty(name)) { Regex regex2 = new Regex(Wildcard.ConvertToRegexPattern(name), RegexOptions.IgnoreCase); if (!regex2.IsMatch(roleEntry.Name)) { if (type != ManagementRoleEntryType.Cmdlet) { return(false); } if (!regex2.IsMatch(roleEntry.Name + "," + ((CmdletRoleEntry)roleEntry).PSSnapinName)) { return(false); } } } if (parameters != null && parameters.Length != 0) { foreach (string wildcardString in parameters) { Regex regex3 = new Regex(Wildcard.ConvertToRegexPattern(wildcardString), RegexOptions.IgnoreCase); bool flag = false; foreach (string input in roleEntry.Parameters) { if (regex3.IsMatch(input)) { flag = true; break; } } if (!flag) { return(false); } } } return(true); }
protected override void InternalApplyChangeAndValidate() { if (this.DataObject.IsUnscopedTopLevel) { if (this.ParentRoleEntry != null) { base.WriteError(new InvalidOperationException(Strings.ParameterNotAllowedWithTopLevelRole("ParentRoleEntry", RoleType.UnScoped.ToString())), ErrorCategory.InvalidArgument, this.DataObject.Id); } if (this.Role != null) { base.WriteError(new InvalidOperationException(Strings.ParameterNotAllowedWithTopLevelRole("Role", RoleType.UnScoped.ToString())), ErrorCategory.InvalidArgument, this.DataObject.Id); } ManagementRoleEntryType managementRoleEntryType = ManagementRoleEntryType.Cmdlet; if (base.Fields.Contains(RbacCommonParameters.ParameterType)) { if (this.Type == ManagementRoleEntryType.ApplicationPermission || this.Type == ManagementRoleEntryType.All) { base.WriteError(new InvalidOperationException(Strings.EntryNoAllowedInRoleType(this.Type.ToString(), RoleType.UnScoped.ToString())), ErrorCategory.InvalidArgument, this.DataObject.Id); } managementRoleEntryType = this.Type; } else if (Regex.IsMatch(this.Identity.CmdletOrScriptName, "ps\\d?.$", RegexOptions.IgnoreCase)) { managementRoleEntryType = ManagementRoleEntryType.Script; } if (managementRoleEntryType == ManagementRoleEntryType.Cmdlet && string.IsNullOrEmpty(this.PSSnapinName)) { base.WriteError(new InvalidOperationException(string.Format(Strings.ProvideSnapinNameForCmdletEntryForRole(RoleType.UnScoped.ToString()), new object[0])), ErrorCategory.InvalidArgument, this.DataObject.Id); } ManagementRoleEntryType managementRoleEntryType2 = managementRoleEntryType; switch (managementRoleEntryType2) { case ManagementRoleEntryType.Cmdlet: base.VerifyCmdletEntry(this.Identity.CmdletOrScriptName, this.PSSnapinName, this.Parameters); this.addedEntry = new CmdletRoleEntry(this.Identity.CmdletOrScriptName, this.PSSnapinName, this.Parameters); break; case ManagementRoleEntryType.Script: base.VerifyScriptEntry(this.Identity.CmdletOrScriptName, this.Parameters, this.SkipScriptExistenceCheck); this.addedEntry = new ScriptRoleEntry(this.Identity.CmdletOrScriptName, this.Parameters); break; default: if (managementRoleEntryType2 == ManagementRoleEntryType.WebService) { this.VerifyWebServiceEntry(this.Identity.CmdletOrScriptName); this.addedEntry = new WebServiceRoleEntry(this.Identity.CmdletOrScriptName, new string[0]); } break; } this.roleEntryOnDataObject = RoleHelper.GetRoleEntry(this.DataObject, this.Identity.CmdletOrScriptName, this.Identity.PSSnapinName, managementRoleEntryType, new Task.TaskErrorLoggingDelegate(base.WriteError)); } else { if (this.UnScopedTopLevel) { base.WriteError(new InvalidOperationException(Strings.ParameterAllowedOnlyForTopLevelRoleManipulation("UnScopedTopLevel", RoleType.UnScoped.ToString())), ErrorCategory.InvalidOperation, null); } RoleEntryIdParameter roleEntryIdParameter = new RoleEntryIdParameter(base.ParentRole.Id, this.Identity.CmdletOrScriptName, this.Identity.Type); roleEntryIdParameter.PSSnapinName = this.PSSnapinName; ExchangeRoleEntryPresentation exchangeRoleEntryPresentation = (ExchangeRoleEntryPresentation)base.GetDataObject <ExchangeRoleEntryPresentation>(roleEntryIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorRoleEntryNotFound(roleEntryIdParameter.RoleId.ToString(), roleEntryIdParameter.CmdletOrScriptName)), new LocalizedString?(Strings.ErrorRoleEntryNotUnique(roleEntryIdParameter.RoleId.ToString(), roleEntryIdParameter.CmdletOrScriptName))); string[] array; if (base.Fields.IsModified(RbacCommonParameters.ParameterParameters)) { array = this.Parameters; } else { array = new string[exchangeRoleEntryPresentation.Parameters.Count]; exchangeRoleEntryPresentation.Parameters.CopyTo(array, 0); } try { ManagementRoleEntryType type = exchangeRoleEntryPresentation.Type; switch (type) { case ManagementRoleEntryType.Cmdlet: if (base.IsEntryValidationRequired()) { base.VerifyCmdletEntry(exchangeRoleEntryPresentation.Name, exchangeRoleEntryPresentation.PSSnapinName, array); } this.addedEntry = new CmdletRoleEntry(exchangeRoleEntryPresentation.Name, exchangeRoleEntryPresentation.PSSnapinName, array); break; case ManagementRoleEntryType.Script: if (base.IsEntryValidationRequired()) { base.VerifyScriptEntry(exchangeRoleEntryPresentation.Name, array, false); } this.addedEntry = new ScriptRoleEntry(exchangeRoleEntryPresentation.Name, array); break; case ManagementRoleEntryType.Cmdlet | ManagementRoleEntryType.Script: break; case ManagementRoleEntryType.ApplicationPermission: this.addedEntry = new ApplicationPermissionRoleEntry(exchangeRoleEntryPresentation.Name, array); break; default: if (type == ManagementRoleEntryType.WebService) { this.VerifyWebServiceEntry(exchangeRoleEntryPresentation.Name); this.addedEntry = new WebServiceRoleEntry(exchangeRoleEntryPresentation.Name, new string[0]); } break; } } catch (FormatException ex) { base.WriteError(new ArgumentException(new LocalizedString(ex.Message)), ErrorCategory.InvalidArgument, this.DataObject.Id); } this.roleEntryOnDataObject = RoleHelper.GetRoleEntry(this.DataObject, this.Identity.CmdletOrScriptName, this.Identity.PSSnapinName, exchangeRoleEntryPresentation.Type, new Task.TaskErrorLoggingDelegate(base.WriteError)); } if (!this.Overwrite.IsPresent && null != this.roleEntryOnDataObject) { this.WriteWarning(Strings.WarningRoleEntryAlreadyExists(this.DataObject.Id.ToString(), this.Identity.CmdletOrScriptName)); } this.InternalAddRemoveRoleEntry(this.DataObject.RoleEntries); TaskLogger.LogExit(); }