protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); TDataObject dataObject = this.DataObject; if (dataObject.IsModified(ADRecipientSchema.Alias)) { TDataObject dataObject2 = this.DataObject; if (string.IsNullOrEmpty(dataObject2.Alias)) { LocalizedException exception = new RecipientTaskException(Strings.ErrorAliasEmpty); ExchangeErrorCategory category = ExchangeErrorCategory.Client; TDataObject dataObject3 = this.DataObject; base.WriteError(exception, category, dataObject3.Identity); } } TDataObject dataObject4 = this.DataObject; if (dataObject4.IsChanged(ADRecipientSchema.ModeratedBy)) { int num = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled ? 10 : 25; TDataObject dataObject5 = this.DataObject; if (dataObject5.ModeratedBy != null) { TDataObject dataObject6 = this.DataObject; if (dataObject6.ModeratedBy.Count > num) { base.WriteError(new RecipientTaskException(Strings.ErrorTooManyModerators(num)), ExchangeErrorCategory.Client, null); } } } TaskLogger.LogExit(); }
private void VerifyMandatoryPropertiesAppliable(ADUser mailbox) { if (this.needApplyMandatoryProperties) { return; } string serverLegacyDN; if (mailbox != null) { serverLegacyDN = mailbox.ServerLegacyDN; } else { TPublicObject instance = this.Instance; serverLegacyDN = instance.ServerLegacyDN; } if (!string.IsNullOrEmpty(serverLegacyDN)) { AdministrativeGroup administrativeGroup = base.GlobalConfigSession.GetAdministrativeGroup(); if (serverLegacyDN.StartsWith(administrativeGroup.LegacyExchangeDN + "/")) { this.needApplyMandatoryProperties = true; return; } TIdentity identity = this.Identity; LocalizedException exception = new TaskInvalidOperationException(Strings.ErrorNoNeedApplyMandatoryProperties(identity.ToString())); ExchangeErrorCategory category = ExchangeErrorCategory.Client; TPublicObject instance2 = this.Instance; base.WriteError(exception, category, instance2.Id); } }
internal virtual void WriteErrorPerObject(LocalizedException exception, ExchangeErrorCategory category, object target) { if (target == null) { this.WriteError(exception, category, this.CurrentProcessedObject, false); return; } base.WriteError(exception, category, target); }
protected override IConfigDataProvider CreateSession() { IRecipientSession tenantGlobalCatalogSession = base.TenantGlobalCatalogSession; MailboxIdParameter mailboxIdParameter = null; if (this.Identity != null) { if (this.Identity.InternalMessageCategoryId != null) { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalMessageCategoryId.MailboxOwnerId); } else { mailboxIdParameter = this.Identity.RawMailbox; } } if (mailboxIdParameter != null && this.Mailbox != null) { base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidArgument, this.Identity); } if (mailboxIdParameter == null) { ADObjectId executingUserId; base.TryGetExecutingUserId(out executingUserId); mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity != null && this.Identity.InternalMessageCategoryId == null) { this.Identity.InternalMessageCategoryId = new MessageCategoryId(aduser.Id, this.Identity.RawCategoryName, this.Identity.RawCategoryId); } base.VerifyIsWithinScopes(tenantGlobalCatalogSession, aduser, true, new DataAccessTask <MessageCategory> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); Exception ex = null; ExchangeErrorCategory category = (ExchangeErrorCategory)0; MessageCategoryDataProvider result = null; try { result = new MessageCategoryDataProvider(base.SessionSettings, aduser, "Get-MessageCategory"); } catch (MapiPermanentException ex2) { ex = ex2; category = ExchangeErrorCategory.ServerOperation; } catch (MapiRetryableException ex3) { ex = ex3; category = ExchangeErrorCategory.ServerTransient; } if (ex != null) { base.WriteError(new InvalidOperationException(Strings.ErrorUnableToAccessMessageCategoriesGenericMessage(ex.Message), ex), (ErrorCategory)category, aduser.Identity); } return(result); }
private void WriteErrorAndMonitoringEvent(Exception exception, ExchangeErrorCategory errorCategory, object target, int eventId, string eventSource) { if (this.MonitoringContext) { this.monitoringData.Events.Add(new MonitoringEvent(eventSource, eventId, EventTypeEnumeration.Error, exception.Message)); base.WriteObject(this.monitoringData); } base.WriteError(exception, (ErrorCategory)errorCategory, target); }
// Token: 0x06000677 RID: 1655 RVA: 0x000180CD File Offset: 0x000162CD public void SetErrorInfo(Exception exception, ExchangeErrorCategory errorCategory, object target, string helpUrl, bool terminatePipeline, bool isKnownError) { this.HasErrors = true; this.Exception = exception; this.ExchangeErrorCategory = new ExchangeErrorCategory?(errorCategory); this.Target = target; this.HelpUrl = helpUrl; this.TerminatePipeline = terminatePipeline; this.IsKnownError = isKnownError; }
internal static ADObjectId GetExecutingUserAndCheckGroupOwnership(Task task, IDirectorySession dataSession, IRecipientSession gcSession, ADGroup group, bool bypassSecurityGroupManagerCheck) { ADScopeException ex2 = null; ADObjectId adobjectId = null; bool flag = task.TryGetExecutingUserId(out adobjectId); LocalizedException ex = null; ExchangeErrorCategory errCategory = ExchangeErrorCategory.Client; object targetObj = null; bool flag2 = false; if (flag && adobjectId != null && !dataSession.TryVerifyIsWithinScopes(group, true, out ex2)) { task.WriteVerbose(Strings.VerboseDGOwnershipDeepSearch(adobjectId.ToString(), group.Identity.ToString())); RecipientTaskHelper.ValidateUserIsGroupManager(adobjectId, group, delegate(LocalizedException exception, ExchangeErrorCategory category, object target) { ex = exception; errCategory = category; targetObj = target; }, true, gcSession); flag2 = true; group.IsExecutingUserGroupOwner = (ex == null); } if (RecipientType.MailUniversalSecurityGroup == group.RecipientType && !bypassSecurityGroupManagerCheck) { if (!flag) { task.WriteError(new RecipientTaskException(Strings.ErrorExecutingUserOutOfTargetOrg(task.MyInvocation.MyCommand.Name)), ExchangeErrorCategory.Client, group.Identity.ToString()); } if (!flag2) { task.WriteVerbose(Strings.VerboseDGOwnershipDeepSearch(adobjectId.ToString(), group.Identity.ToString())); RecipientTaskHelper.ValidateUserIsGroupManager(adobjectId, group, new Task.ErrorLoggerDelegate(task.WriteError), true, gcSession); group.IsExecutingUserGroupOwner = true; } else if (ex != null) { task.WriteError(ex, errCategory, targetObj); } } group.propertyBag.ResetChangeTracking(ADGroupSchema.IsExecutingUserGroupOwner); return(adobjectId); }
public ProvisioningValidationError(LocalizedString description, ExchangeErrorCategory errorCategory) : this(description, errorCategory, null) { }
protected override void InternalValidate() { TaskLogger.LogEnter(); this.isToInactiveMailbox = false; this.isDisconnectInactiveMailbox = false; if (this.Identity != null) { base.InternalValidate(); this.isToInactiveMailbox = this.IsToInactiveMailbox(); this.isDisconnectInactiveMailbox = this.IsDisconnectInactiveMailbox(); if (!this.isToInactiveMailbox && !this.isDisconnectInactiveMailbox) { MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool()); MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool()); } MailboxTaskHelper.BlockRemoveOrDisableIfJournalNDRMailbox(base.DataObject, this.TenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), false); if (ComplianceConfigImpl.JournalArchivingHardeningEnabled && !this.skipJournalArchivingCheck) { MailboxTaskHelper.BlockRemoveOrDisableMailboxIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false); } if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.ArbitrationMailbox && this.ArbitrationMailboxUsageValidationRequired) { ADUser dataObject = base.DataObject; Task.ErrorLoggerDelegate writeError = new Task.ErrorLoggerDelegate(base.WriteError); TIdentity identity = this.Identity; MailboxTaskHelper.ValidateNotBuiltInArbitrationMailbox(dataObject, writeError, Strings.ErrorRemoveArbitrationMailbox(identity.ToString())); ADUser dataObject2 = base.DataObject; IRecipientSession tenantGlobalCatalogSession = base.TenantGlobalCatalogSession; Task.ErrorLoggerDelegate writeError2 = new Task.ErrorLoggerDelegate(base.WriteError); TIdentity identity2 = this.Identity; MailboxTaskHelper.ValidateArbitrationMailboxHasNoGroups(dataObject2, tenantGlobalCatalogSession, writeError2, Strings.ErrorRemoveMailboxWithAssociatedApprovalRecipents(identity2.ToString())); ADUser dataObject3 = base.DataObject; bool overrideCheck = this.RemoveArbitrationMailboxWithOABsAllowed.ToBool(); Task.ErrorLoggerDelegate writeError3 = new Task.ErrorLoggerDelegate(base.WriteError); TIdentity identity3 = this.Identity; MailboxTaskHelper.ValidateNoOABsAssignedToArbitrationMailbox(dataObject3, overrideCheck, writeError3, Strings.ErrorRemoveArbitrationMailboxWithOABsAssigned(identity3.ToString())); ADUser dataObject4 = base.DataObject; IRecipientSession tenantGlobalCatalogSession2 = base.TenantGlobalCatalogSession; ADObjectId rootOrgContainerId = base.RootOrgContainerId; bool isPresent = this.RemoveLastArbitrationMailboxAllowed.IsPresent; Task.ErrorLoggerDelegate writeError4 = new Task.ErrorLoggerDelegate(base.WriteError); TIdentity identity4 = this.Identity; MailboxTaskHelper.ValidateNotLastArbitrationMailbox(dataObject4, tenantGlobalCatalogSession2, rootOrgContainerId, isPresent, writeError4, Strings.ErrorCannotRemoveLastArbitrationMailboxInOrganization(identity4.ToString())); } if (this.AuditLog) { if (base.DataObject.RecipientTypeDetails != RecipientTypeDetails.AuditLogMailbox) { LocalizedException exception = new RecipientTaskException(Strings.ErrorSpecifiedMailboxShouldBeAuditLogMailbox(base.DataObject.Identity.ToString())); ExchangeErrorCategory category = ExchangeErrorCategory.Context; TIdentity identity5 = this.Identity; base.WriteError(exception, category, identity5.ToString()); } } else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox) { LocalizedException exception2 = new RecipientTaskException(Strings.ErrorAuditLogMailboxShouldBeDeletedWithAuditLogSpecified(base.DataObject.Identity.ToString())); ExchangeErrorCategory category2 = ExchangeErrorCategory.Context; TIdentity identity6 = this.Identity; base.WriteError(exception2, category2, identity6.ToString()); } } else { this.InternalValidateStoreMailboxIdentity(); try { this.mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.StoreMailboxIdentity, this.mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(this.database), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.StoreMailboxIdentity.ToString(), this.Database.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.StoreMailboxIdentity.ToString(), this.Database.ToString())), ExchangeErrorCategory.Client); MailboxTaskHelper.ValidateMailboxIsDisconnected(base.TenantGlobalCatalogSession, this.mailboxStatistics.MailboxGuid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); this.mailboxStatistics.Database = this.database.Identity; } catch (DataSourceTransientException exception3) { base.WriteError(exception3, ExchangeErrorCategory.ServerTransient, this.StoreMailboxIdentity); } } if (this.PublicFolder) { Organization orgContainer = this.TenantLocalConfigurationSession.GetOrgContainer(); if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid == Guid.Empty && !this.Force) { LocalizedException exception4 = new RecipientTaskException(Strings.ErrorPrimaryPublicFolderMailboxNotFound); ExchangeErrorCategory category3 = ExchangeErrorCategory.Context; TIdentity identity7 = this.Identity; base.WriteError(exception4, category3, identity7.ToString()); } if (this.currentOrganizationId == null || this.currentOrganizationId != base.DataObject.OrganizationId) { this.currentOrganizationId = base.DataObject.OrganizationId; TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.DataObject.OrganizationId); } MailboxTaskHelper.RemoveOrDisablePublicFolderMailbox(base.DataObject, Guid.Empty, this.tenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), false, this.Force); } TaskLogger.LogExit(); }
protected IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, OptionalIdentityData optionalData, LocalizedString?notFoundError, LocalizedString?multipleFoundError, ExchangeErrorCategory errorCategory) where TObject : IConfigurable, new() { IConfigurable result = null; LocalizedString? localizedString; IEnumerable <TObject> dataObjects = this.GetDataObjects <TObject>(id, session, rootID, optionalData, out localizedString); Exception ex = null; using (IEnumerator <TObject> enumerator = dataObjects.GetEnumerator()) { if (enumerator.MoveNext()) { result = enumerator.Current; if (enumerator.MoveNext()) { ex = new ManagementObjectAmbiguousException(multipleFoundError ?? Strings.ErrorManagementObjectAmbiguous(id.ToString())); } } else if (notFoundError != null) { LocalizedString message; if (localizedString != null) { LocalizedString?localizedString2 = notFoundError; string notFound = (localizedString2 != null) ? localizedString2.GetValueOrDefault() : null; LocalizedString?localizedString3 = localizedString; message = Strings.ErrorNotFoundWithReason(notFound, (localizedString3 != null) ? localizedString3.GetValueOrDefault() : null); } else { message = notFoundError.Value; } ex = new ManagementObjectNotFoundException(message); } else { ex = new ManagementObjectNotFoundException(localizedString ?? this.GetErrorMessageObjectNotFound(id.ToString(), typeof(TObject).ToString(), (this.DataSession != null) ? this.DataSession.Source : null)); } } if (ex != null) { if (errorCategory != (ExchangeErrorCategory)0) { RecipientTaskHelper.SetExceptionErrorCategory(ex, errorCategory); } throw ex; } return(result); }
private IEnumerable <TResult> ResolveIdList <TObject, TResult>(IEnumerable idParameters, IConfigDataProvider session, ObjectId rootId, OptionalIdentityData optionalData, ExchangeErrorCategory errorCategory, Func <IIdentityParameter, LocalizedString> parameterToNotFoundError, Func <IIdentityParameter, LocalizedString> parameterToMultipleFoundError, Func <IConfigurable, TResult> convertToResult, Func <IConfigurable, IConfigurable> validateObject) where TObject : IConfigurable, new() { Func <IConfigurable, TResult> func = null; Func <IConfigurable, IConfigurable> func2 = null; Dictionary <TResult, IIdentityParameter> dictionary = new Dictionary <TResult, IIdentityParameter>(); if (idParameters != null) { if (convertToResult == null) { if (func == null) { func = ((IConfigurable obj) => (TResult)((object)obj.Identity)); } convertToResult = func; } if (validateObject == null) { if (func2 == null) { func2 = ((IConfigurable obj) => obj); } validateObject = func2; } foreach (object obj2 in idParameters) { IIdentityParameter identityParameter = (IIdentityParameter)obj2; LocalizedString? notFoundError = (parameterToNotFoundError == null) ? null : new LocalizedString?(parameterToNotFoundError(identityParameter)); LocalizedString? multipleFoundError = (parameterToMultipleFoundError == null) ? null : new LocalizedString?(parameterToMultipleFoundError(identityParameter)); IConfigurable arg = this.GetDataObject <TObject>(identityParameter, session, rootId, notFoundError, multipleFoundError); arg = validateObject(arg); TResult tresult = convertToResult(arg); if (dictionary.ContainsKey(tresult)) { throw new ManagementObjectDuplicateException(Strings.ErrorDuplicateManagementObjectFound(dictionary[tresult], identityParameter, tresult)); } dictionary.Add(tresult, identityParameter); } } return(dictionary.Keys); }
protected MultiValuedProperty <TResult> ResolveIdParameterCollection <TIdParameter, TObject, TResult>(IEnumerable <TIdParameter> idParameters, IConfigDataProvider session, ObjectId rootId, OptionalIdentityData optionalData, ExchangeErrorCategory errorCategory, Func <IIdentityParameter, LocalizedString> parameterToNotFoundError, Func <IIdentityParameter, LocalizedString> parameterToMultipleFoundError, Func <IConfigurable, TResult> convertToResult, Func <IConfigurable, IConfigurable> validateObject) where TIdParameter : IIdentityParameter where TObject : IConfigurable, new() { MultiValuedProperty <TIdParameter> multiValuedProperty = idParameters as MultiValuedProperty <TIdParameter>; MultiValuedProperty <TResult> result; if (multiValuedProperty != null && multiValuedProperty.IsChangesOnlyCopy) { Hashtable hashtable = new Hashtable(); if (multiValuedProperty.Added.Length > 0) { IEnumerable <TResult> value = this.ResolveIdList <TObject, TResult>(multiValuedProperty.Added, session, rootId, optionalData, errorCategory, parameterToNotFoundError, parameterToMultipleFoundError, convertToResult, validateObject); hashtable.Add("Add", value); } if (multiValuedProperty.Removed.Length > 0) { IEnumerable <TResult> value2 = this.ResolveIdList <TObject, TResult>(multiValuedProperty.Removed, session, rootId, optionalData, errorCategory, parameterToNotFoundError, parameterToMultipleFoundError, convertToResult, null); hashtable.Add("Remove", value2); } result = new MultiValuedProperty <TResult>(hashtable); } else { IEnumerable <TResult> value3 = this.ResolveIdList <TObject, TResult>(idParameters, session, rootId, optionalData, errorCategory, parameterToNotFoundError, parameterToMultipleFoundError, convertToResult, validateObject); result = new MultiValuedProperty <TResult>(value3); } return(result); }
protected IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, LocalizedString?notFoundError, LocalizedString?multipleFoundError, ExchangeErrorCategory errorCategory) where TObject : IConfigurable, new() { return(this.GetDataObject <TObject>(id, session, rootID, null, notFoundError, multipleFoundError, errorCategory)); }
public ProvisioningValidationError(LocalizedString description, ExchangeErrorCategory errorCategory, Exception exception) : base(description) { this.errorCategory = errorCategory; this.exception = exception; }
internal static void ValidateUserParameters(ADUser userObject, IConfigurationSession configSession, IRecipientSession globalCatalogSession, Task.TaskVerboseLoggingDelegate verboseLogger, Task.ErrorLoggerDelegate errorLogger, ExchangeErrorCategory errorLoggerCategory, bool shouldCheckAcceptedDomains, ProvisioningCache provisioningCache) { if (userObject.IsModified(UserSchema.ResetPasswordOnNextLogon) && userObject.ResetPasswordOnNextLogon && (userObject.UserAccountControl & UserAccountControlFlags.DoNotExpirePassword) != UserAccountControlFlags.None) { errorLogger(new TaskInvalidOperationException(Strings.ErrorUserCannotChangePasswordAtNextLogon(userObject.Identity.ToString())), errorLoggerCategory, userObject.Identity); } if (userObject.IsModified(UserSchema.UserPrincipalName)) { if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.ValidateExternalEmailAddressInAcceptedDomain.Enabled&& shouldCheckAcceptedDomains) { RecipientTaskHelper.ValidateInAcceptedDomain(configSession, userObject.OrganizationId, RecipientTaskHelper.GetDomainPartOfUserPrincalName(userObject.UserPrincipalName), errorLogger, provisioningCache); } RecipientTaskHelper.IsUserPrincipalNameUnique(globalCatalogSession, userObject, userObject.UserPrincipalName, verboseLogger, errorLogger, errorLoggerCategory); } if (userObject.IsModified(UserSchema.SamAccountName)) { RecipientTaskHelper.IsSamAccountNameUnique(globalCatalogSession, userObject, userObject.SamAccountName, verboseLogger, errorLogger, errorLoggerCategory); } }
private void WriteError(Exception exception, ExchangeErrorCategory category, object target) { throw new BatchReferenceErrorReporter.ValidationException(exception); }
public void WriteError(LocalizedException localizedException, ExchangeErrorCategory exchangeErrorCategory, object target) { this.task.WriteError(localizedException, exchangeErrorCategory, target); }