protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); ADUser aduser = (ADUser)base.PrepareDataObject(); if ((aduser.UMEnabledFlags & UMEnabledFlags.UMEnabled) != UMEnabledFlags.UMEnabled) { base.WriteError(new RecipientTaskException(Strings.MailboxNotUmEnabled(this.Identity.ToString())), (ErrorCategory)1000, aduser); } if (base.UMMailboxPolicy != null) { IConfigurationSession configurationSession = this.ConfigurationSession; ADObjectId ummailboxPolicy = aduser.UMMailboxPolicy; if (ummailboxPolicy != null) { MailboxPolicyIdParameter id = new MailboxPolicyIdParameter(ummailboxPolicy); UMMailboxPolicy ummailboxPolicy2 = (UMMailboxPolicy)base.GetDataObject <UMMailboxPolicy>(id, configurationSession, null, new LocalizedString?(Strings.ErrorManagedFolderMailboxPolicyNotFound(ummailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorManagedFolderMailboxPolicyNotUnique(ummailboxPolicy.ToString()))); if (!ummailboxPolicy2.UMDialPlan.Equals(this.newMailboxPolicy.UMDialPlan)) { base.WriteError(new RecipientTaskException(Strings.NewPolicyMustBeInTheSameDialPlanAsOldPolicy(ummailboxPolicy2.UMDialPlan.Name)), (ErrorCategory)1000, aduser); } } aduser.UMMailboxPolicy = this.newMailboxPolicy.Id; } if (base.Fields.IsModified("PhoneNumber")) { this.SetPhoneNumber(aduser); } if (base.Fields.IsModified("AirSyncNumbers")) { this.SetAirSyncNumber(aduser); } TaskLogger.LogExit(); return(aduser); }
protected override void ResolveLocalSecondaryIdentities() { base.ResolveLocalSecondaryIdentities(); Mailbox mailbox = (Mailbox)this.GetDynamicParameters(); if (this.RemoveManagedFolderAndPolicy) { mailbox.ManagedFolderMailboxPolicy = null; } if (base.Fields.IsModified(MailboxSchema.RetentionPolicy)) { if (this.RetentionPolicy != null) { RetentionPolicy retentionPolicy = (RetentionPolicy)base.GetDataObject<RetentionPolicy>(this.RetentionPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorRetentionPolicyNotFound(this.RetentionPolicy.ToString())), new LocalizedString?(Strings.ErrorRetentionPolicyNotUnique(this.RetentionPolicy.ToString())), ExchangeErrorCategory.Client); mailbox.RetentionPolicy = (ADObjectId)retentionPolicy.Identity; mailbox.ManagedFolderMailboxPolicy = null; } else { mailbox.RetentionPolicy = null; } } base.SetReferenceParameter<RecipientIdParameter>(MailboxSchema.ForwardingAddress, this.ForwardingAddress, mailbox, new GetRecipientDelegate<RecipientIdParameter>(this.GetRecipient)); if (base.Fields.IsModified(MailboxSchema.OfflineAddressBook)) { if (this.OfflineAddressBook != null) { OfflineAddressBook offlineAddressBook = (OfflineAddressBook)base.GetDataObject<OfflineAddressBook>(this.OfflineAddressBook, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOfflineAddressBookNotFound(this.OfflineAddressBook.ToString())), new LocalizedString?(Strings.ErrorOfflineAddressBookNotUnique(this.OfflineAddressBook.ToString())), ExchangeErrorCategory.Client); mailbox.OfflineAddressBook = (ADObjectId)offlineAddressBook.Identity; } else { mailbox.OfflineAddressBook = null; } } if (base.Fields.IsModified(ADRecipientSchema.AddressBookPolicy)) { AddressBookMailboxPolicyIdParameter addressBookMailboxPolicyIdParameter = (AddressBookMailboxPolicyIdParameter)base.Fields[ADRecipientSchema.AddressBookPolicy]; if (addressBookMailboxPolicyIdParameter != null) { AddressBookMailboxPolicy addressBookMailboxPolicy = (AddressBookMailboxPolicy)base.GetDataObject<AddressBookMailboxPolicy>(addressBookMailboxPolicyIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorAddressBookMailboxPolicyNotFound(addressBookMailboxPolicyIdParameter.ToString())), new LocalizedString?(Strings.ErrorAddressBookMailboxPolicyNotUnique(addressBookMailboxPolicyIdParameter.ToString())), ExchangeErrorCategory.Client); mailbox[ADRecipientSchema.AddressBookPolicy] = (ADObjectId)addressBookMailboxPolicy.Identity; } else { mailbox[ADRecipientSchema.AddressBookPolicy] = null; } } if (base.Fields.IsModified(ADRecipientSchema.ThrottlingPolicy)) { if (SharedConfiguration.IsDehydratedConfiguration(base.CurrentOrganizationId)) { base.WriteError(new TaskInvalidOperationException(Strings.ErrorLinkOpOnDehydratedTenant("ThrottlingPolicy")), ExchangeErrorCategory.Context, this.DataObject.Identity); } ThrottlingPolicyIdParameter throttlingPolicyIdParameter = (ThrottlingPolicyIdParameter)base.Fields[ADRecipientSchema.ThrottlingPolicy]; if (throttlingPolicyIdParameter != null) { ThrottlingPolicy throttlingPolicy = (ThrottlingPolicy)base.GetDataObject<ThrottlingPolicy>(throttlingPolicyIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorThrottlingPolicyNotFound(throttlingPolicyIdParameter.ToString())), new LocalizedString?(Strings.ErrorThrottlingPolicyNotUnique(throttlingPolicyIdParameter.ToString())), ExchangeErrorCategory.Client); mailbox[ADRecipientSchema.ThrottlingPolicy] = (ADObjectId)throttlingPolicy.Identity; } else { mailbox[ADRecipientSchema.ThrottlingPolicy] = null; } } if (base.Fields.IsModified(ADUserSchema.SharingPolicy)) { if (SharedConfiguration.IsDehydratedConfiguration(base.CurrentOrganizationId)) { base.WriteError(new LocalizedException(Strings.ErrorLinkOpOnDehydratedTenant("SharingPolicy")), ExchangeErrorCategory.Client, this.DataObject); } SharingPolicyIdParameter sharingPolicyIdParameter = (SharingPolicyIdParameter)base.Fields[ADUserSchema.SharingPolicy]; if (sharingPolicyIdParameter != null) { SharingPolicy sharingPolicy = (SharingPolicy)base.GetDataObject<SharingPolicy>(sharingPolicyIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorSharingPolicyNotFound(sharingPolicyIdParameter.ToString())), new LocalizedString?(Strings.ErrorSharingPolicyNotUnique(sharingPolicyIdParameter.ToString())), ExchangeErrorCategory.Client); mailbox[ADUserSchema.SharingPolicy] = (ADObjectId)sharingPolicy.Identity; } else { mailbox[ADUserSchema.SharingPolicy] = null; } } if (base.Fields.IsModified(ADUserSchema.RemoteAccountPolicy)) { RemoteAccountPolicyIdParameter remoteAccountPolicyIdParameter = (RemoteAccountPolicyIdParameter)base.Fields[ADUserSchema.RemoteAccountPolicy]; if (remoteAccountPolicyIdParameter != null) { RemoteAccountPolicy remoteAccountPolicy = (RemoteAccountPolicy)base.GetDataObject<RemoteAccountPolicy>(remoteAccountPolicyIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorRemoteAccountPolicyNotFound(remoteAccountPolicyIdParameter.ToString())), new LocalizedString?(Strings.ErrorRemoteAccountPolicyNotUnique(remoteAccountPolicyIdParameter.ToString())), ExchangeErrorCategory.Client); mailbox[ADUserSchema.RemoteAccountPolicy] = (ADObjectId)remoteAccountPolicy.Identity; } else { mailbox[ADUserSchema.RemoteAccountPolicy] = null; } } if (base.Fields.IsModified(ADRecipientSchema.RoleAssignmentPolicy)) { MailboxPolicyIdParameter mailboxPolicyIdParameter = (MailboxPolicyIdParameter)base.Fields[ADRecipientSchema.RoleAssignmentPolicy]; if (mailboxPolicyIdParameter != null) { IConfigurationSession tenantLocalConfigSession = RecipientTaskHelper.GetTenantLocalConfigSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId, base.RootOrgContainerId); RoleAssignmentPolicy roleAssignmentPolicy = (RoleAssignmentPolicy)base.GetDataObject<RoleAssignmentPolicy>(mailboxPolicyIdParameter, tenantLocalConfigSession, null, new LocalizedString?(Strings.ErrorRoleAssignmentPolicyNotFound(mailboxPolicyIdParameter.ToString())), new LocalizedString?(Strings.ErrorRoleAssignmentPolicyNotUnique(mailboxPolicyIdParameter.ToString())), ExchangeErrorCategory.Client); mailbox[ADRecipientSchema.RoleAssignmentPolicy] = (ADObjectId)roleAssignmentPolicy.Identity; } else { mailbox[ADRecipientSchema.RoleAssignmentPolicy] = null; } } if (base.Fields.IsModified(ADRecipientSchema.MailboxPlan)) { if (this.MailboxPlan != null) { ADUser aduser = base.ProvisioningCache.TryAddAndGetOrganizationDictionaryValue<ADUser, string>(CannedProvisioningCacheKeys.CacheKeyMailboxPlanIdParameterId, base.CurrentOrganizationId, this.MailboxPlan.RawIdentity, () => (ADUser)base.GetDataObject<ADUser>(this.MailboxPlan, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxPlanNotFound(this.MailboxPlan.ToString())), new LocalizedString?(Strings.ErrorMailboxPlanNotUnique(this.MailboxPlan.ToString())), ExchangeErrorCategory.Client)); MailboxTaskHelper.ValidateMailboxPlanRelease(aduser, new Task.ErrorLoggerDelegate(base.WriteError)); mailbox[ADRecipientSchema.MailboxPlan] = (ADObjectId)aduser.Identity; return; } mailbox[ADRecipientSchema.MailboxPlan] = null; } }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.Fields.IsModified(CASMailboxSchema.ActiveSyncMailboxPolicy)) { if (this.ActiveSyncMailboxPolicy != null) { MobileMailboxPolicy mobileMailboxPolicy = (MobileMailboxPolicy)base.GetDataObject <MobileMailboxPolicy>(this.ActiveSyncMailboxPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorMobileMailboxPolicyNotFound(this.ActiveSyncMailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorMobileMailboxPolicyNotUnique(this.ActiveSyncMailboxPolicy.ToString()))); this.DataObject.ActiveSyncMailboxPolicy = (ADObjectId)mobileMailboxPolicy.Identity; } else { this.DataObject.ActiveSyncMailboxPolicy = null; } } if (base.Fields.IsModified(CASMailboxSchema.OwaMailboxPolicy)) { if (this.DataObject.ExchangeVersion.Equals(ExchangeObjectVersion.Exchange2007)) { base.WriteError(new ArgumentException(Strings.ErrorSetOWAMailboxPolicyToE12User), ErrorCategory.InvalidArgument, this.Identity); } if (this.OwaMailboxPolicy != null) { OwaMailboxPolicy owaMailboxPolicy = (OwaMailboxPolicy)base.GetDataObject <OwaMailboxPolicy>(this.OwaMailboxPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOwaMailboxPolicyNotFound(this.OwaMailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorOwaMailboxPolicyNotUnique(this.OwaMailboxPolicy.ToString()))); this.DataObject.OwaMailboxPolicy = (ADObjectId)owaMailboxPolicy.Identity; } else { this.DataObject.OwaMailboxPolicy = null; } } this.allowedDeviceIDs = this.DataObject.ActiveSyncAllowedDeviceIDs; this.blockedDeviceIDs = this.DataObject.ActiveSyncBlockedDeviceIDs; bool changed = this.allowedDeviceIDs.Changed; bool changed2 = this.blockedDeviceIDs.Changed; if (changed || changed2) { List <string> list = new List <string>(); List <string> list2 = new List <string>(); this.deviceIdListsChanged = true; foreach (string text in this.allowedDeviceIDs) { foreach (string b in this.blockedDeviceIDs) { if (string.Equals(text, b, StringComparison.OrdinalIgnoreCase)) { if (changed && changed2) { base.WriteError(new ErrorDeviceIdInBothLists(text), ErrorCategory.InvalidData, this.Identity); } else if (changed) { list2.Add(text); } else { list.Add(text); } } } } if (list.Count > 0) { foreach (string item in list) { this.allowedDeviceIDs.Remove(item); } this.DataObject.ActiveSyncAllowedDeviceIDs = this.allowedDeviceIDs; } if (list2.Count > 0) { foreach (string item2 in list2) { this.blockedDeviceIDs.Remove(item2); } this.DataObject.ActiveSyncBlockedDeviceIDs = this.blockedDeviceIDs; } } TaskLogger.LogExit(); }
protected override void DoValidate() { LocalizedException ex = null; if (this.ShouldInitUMMailbox && UMSubscriber.IsValidSubscriber(this.DataObject)) { ex = new UserAlreadyUmEnabledException(this.DataObject.Id.Name); } else if (!this.IsUserAllowedForUnifiedMessaging(this.DataObject)) { ex = new UserNotAllowedForUMEnabledException(); } else { MailboxPolicyIdParameter ummailboxPolicy = this.UMMailboxPolicy; this.mailboxPolicy = (UMMailboxPolicy)base.GetDataObject <UMMailboxPolicy>(ummailboxPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.UMMailboxPolicyIdNotFound(ummailboxPolicy.ToString())), new LocalizedString?(Strings.MultipleUMMailboxPolicyWithSameId(ummailboxPolicy.ToString()))); this.dialPlan = this.mailboxPolicy.GetDialPlan(); if (this.DialPlan.SubscriberType != UMSubscriberType.Consumer || this.DialPlan.URIType != UMUriType.E164 || !string.IsNullOrEmpty(this.SIPResourceIdentifier) || (this.Extensions != null && this.Extensions.Count != 0)) { if (this.Extensions == null || this.Extensions.Count == 0) { string text = null; PhoneNumber phoneNumber; if (PhoneNumber.TryParse(this.DataObject.Phone, out phoneNumber)) { text = this.DialPlan.GetDefaultExtension(phoneNumber.Number); } if (!string.IsNullOrEmpty(Utils.TrimSpaces(text))) { this.Extensions = new MultiValuedProperty <string>(text); } } if (this.DialPlan.URIType == UMUriType.SipName) { ProxyAddress proxyAddress = this.DataObject.EmailAddresses.Find((ProxyAddress p) => string.Equals(p.PrefixString, "sip", StringComparison.OrdinalIgnoreCase)); string text2 = (proxyAddress != null) ? proxyAddress.AddressString : null; if (string.IsNullOrEmpty(this.SIPResourceIdentifier)) { this.SIPResourceIdentifier = ((text2 != null) ? text2 : null); } else if (text2 != null && !string.Equals(this.SIPResourceIdentifier, text2, StringComparison.OrdinalIgnoreCase)) { ex = new SIPResouceIdConflictWithExistingValue(this.SIPResourceIdentifier, text2); base.WriteError(ex, ErrorCategory.InvalidArgument, null); } } IRecipientSession tenantLocalRecipientSession = RecipientTaskHelper.GetTenantLocalRecipientSession(this.DataObject.OrganizationId, base.ExecutingUserOrganizationId, base.RootOrgContainerId); LocalizedException ex2 = null; TelephoneNumberProcessStatus telephoneNumberProcessStatus; Utils.ValidateExtensionsAndSipResourceIdentifier(tenantLocalRecipientSession, this.ConfigurationSession, CommonConstants.DataCenterADPresent, this.DataObject, this.DialPlan, (this.Extensions != null) ? this.Extensions.ToArray() : null, null, this.SIPResourceIdentifier, out ex2, out telephoneNumberProcessStatus); if (ex2 != null) { this.DataObject.EmailAddresses.Clear(); ex = ex2; } } } if (ex == null || this.ValidateOnly) { this.DataObject.UMEnabledFlags |= UMEnabledFlags.UMEnabled; if (base.Fields.IsModified("ASREnabled")) { bool flag = (bool)base.Fields["ASREnabled"]; if (flag) { this.DataObject.UMEnabledFlags |= UMEnabledFlags.ASREnabled; } else { this.DataObject.UMEnabledFlags = (this.DataObject.UMEnabledFlags & ~UMEnabledFlags.ASREnabled); } } this.DataObject.PopulateDtmfMap(true); if (!this.ValidateOnly) { Utils.UMPopulate(this.DataObject, this.SIPResourceIdentifier, this.Extensions, this.mailboxPolicy, this.DialPlan); if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled) { RecipientTaskHelper.ValidateSmtpAddress(this.ConfigurationSession, this.DataObject.EmailAddresses, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache); } if (this.ShouldSavePin) { base.PinInfo = base.ValidateOrGeneratePIN(this.Pin, this.mailboxPolicy.Guid); base.PinInfo.PinExpired = this.PinExpired; base.PinInfo.LockedOut = false; } } else if (this.Extensions != null) { this.DataObject.AddEUMProxyAddress(this.Extensions, this.DialPlan); } } if (ex == null) { if (this.ValidateOnly) { this.WriteResult(); } return; } if (this.ValidateOnly) { this.WriteResult(); base.WriteError(ex, ErrorCategory.InvalidArgument, null, false, null); return; } base.WriteError(ex, ErrorCategory.InvalidArgument, null); }