protected override void InternalValidate() { TaskLogger.LogEnter(new object[] { this.Identity }); if (base.ParameterSetName == "Identity") { this.Identity.Parameters = this.Parameters; this.Identity.PSSnapinName = this.PSSnapinName; if (base.Fields.IsModified(RbacCommonParameters.ParameterType)) { this.Identity.Type = this.Type; } } else { ExchangeRoleEntryPresentation exchangeRoleEntryPresentation = (ExchangeRoleEntryPresentation)base.GetDataObject <ExchangeRoleEntryPresentation>(this.ParentRoleEntry, base.DataSession, null, new LocalizedString?(Strings.ErrorRoleEntryNotFound(this.ParentRoleEntry.RoleId.ToString(), this.ParentRoleEntry.CmdletOrScriptName)), new LocalizedString?(Strings.ErrorRoleEntryNotUnique(this.ParentRoleEntry.RoleId.ToString(), this.ParentRoleEntry.CmdletOrScriptName))); this.Identity = new RoleEntryIdParameter(this.Role, exchangeRoleEntryPresentation.Name, exchangeRoleEntryPresentation.Type); string[] array = new string[exchangeRoleEntryPresentation.Parameters.Count]; exchangeRoleEntryPresentation.Parameters.CopyTo(array, 0); this.Parameters = array; } base.InternalValidate(); TaskLogger.LogExit(); }
// Token: 0x06000E3A RID: 3642 RVA: 0x0002A55C File Offset: 0x0002875C public RoleEntryIdParameter(ExchangeRoleEntryPresentation roleEntry) : this(roleEntry.Role, roleEntry.Name, roleEntry.Type) { this.Parameters = new string[roleEntry.Parameters.Count]; this.PSSnapinName = roleEntry.PSSnapinName; roleEntry.Parameters.CopyTo(this.Parameters, 0); }
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(); }