Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        internal void DiagnoseAndReportMapiException(LocalizedException ex)
        {
            MapiTransaction        mapiTransaction = new MapiTransaction(this.SourceMailboxServer, this.SourceSystemMailboxMdb, this.SourceSystemMailbox, false, true);
            bool                   flag;
            bool                   flag2;
            string                 value = mapiTransaction.DiagnoseMapiOperationException(ex, out flag, out flag2);
            RecipientTaskException ex2   = new RecipientTaskException(new LocalizedString(value));

            if (flag)
            {
                this.AddErrorMonitoringEvent(1009, ex2.Message);
            }
            else
            {
                this.AddErrorMonitoringEvent(1007, ex2.Message);
            }
            this.Task.WriteError(ex2, ErrorCategory.InvalidData, null);
        }
Exemplo n.º 3
0
        private LinkSharePointSiteResult InternalLinkSharePointSite(Uri sharePointUrl, out string sharePointTeamMailboxKey, bool siteChecked, bool forceToUnlink)
        {
            LinkSharePointSiteResult linkSharePointSiteResult = LinkSharePointSiteResult.Success;

            sharePointTeamMailboxKey = "N/A";
            bool      flag = sharePointUrl == null;
            Uri       uri  = sharePointUrl ?? this.teamMailbox.SharePointUrl;
            Exception ex   = null;

            if (flag)
            {
                if (this.teamMailbox.SharePointUrl == null)
                {
                    return(LinkSharePointSiteResult.CurrentlyNotLinked);
                }
                sharePointUrl = this.teamMailbox.SharePointUrl;
            }
            try
            {
                using (ClientContext clientContext = new ClientContext(sharePointUrl.AbsoluteUri))
                {
                    clientContext.RequestTimeout = 60000;
                    bool flag2;
                    TeamMailboxHelper.GetCredentialAndConfigureClientContext(this.actAsUser, this.actAsUserOrgId, clientContext, true, out flag2);
                    Web web = clientContext.Web;
                    clientContext.Load <Web>(web, new Expression <Func <Web, object> >[]
                    {
                        (Web x) => x.AllProperties,
                        (Web x) => (object)x.Id
                    });
                    Site site = clientContext.Site;
                    clientContext.Load <Site>(site, new Expression <Func <Site, object> >[]
                    {
                        (Site x) => x.Url
                    });
                    clientContext.ExecuteQuery();
                    if (!siteChecked && clientContext.ServerVersion.Major < 15)
                    {
                        return(LinkSharePointSiteResult.SPServerVersionNotCompatible);
                    }
                    string text = this.teamMailbox.PrimarySmtpAddress.ToString();
                    if (web.AllProperties.FieldValues.ContainsKey("ExchangeTeamMailboxEmailAddress"))
                    {
                        sharePointTeamMailboxKey = (string)web.AllProperties["ExchangeTeamMailboxEmailAddress"];
                        if (!string.Equals(text, sharePointTeamMailboxKey, StringComparison.OrdinalIgnoreCase))
                        {
                            linkSharePointSiteResult = LinkSharePointSiteResult.LinkedByOthers;
                        }
                        else if (flag)
                        {
                            web.AllProperties["ExchangeTeamMailboxEmailAddress"] = null;
                            web.Update();
                            clientContext.ExecuteQuery();
                            this.teamMailbox.SharePointUrl = null;
                            this.teamMailbox.SetSharePointSiteInfo(null, Guid.Empty);
                            this.teamMailbox.SharePointLinkedBy = null;
                        }
                        else
                        {
                            if (this.actAsUser.Id.Equals(this.teamMailbox.SharePointLinkedBy))
                            {
                                linkSharePointSiteResult = LinkSharePointSiteResult.AlreadyLinkedBySelf;
                            }
                            else
                            {
                                this.teamMailbox.SharePointLinkedBy = this.actAsUser.Id;
                            }
                            this.teamMailbox.SharePointUrl = sharePointUrl;
                        }
                    }
                    else if (flag)
                    {
                        this.teamMailbox.SharePointUrl = null;
                        this.teamMailbox.SetSharePointSiteInfo(null, Guid.Empty);
                        this.teamMailbox.SharePointLinkedBy = null;
                    }
                    else
                    {
                        Uri url = TeamMailbox.GetUrl(site.Url);
                        if (url == null)
                        {
                            throw new RecipientTaskException(Strings.ErrorSharePointSiteHasNoValidWebCollectionUrl(site.Url));
                        }
                        web.AllProperties["ExchangeTeamMailboxEmailAddress"]      = text;
                        web.AllProperties["ExchangeTeamMailboxSharePointUrl"]     = sharePointUrl.AbsoluteUri;
                        web.AllProperties["ExchangeTeamMailboxSiteID"]            = web.Id.ToString();
                        web.AllProperties["ExchangeTeamMailboxSiteCollectionUrl"] = site.Url;
                        web.Update();
                        clientContext.ExecuteQuery();
                        this.teamMailbox.SharePointUrl = sharePointUrl;
                        this.teamMailbox.SetSharePointSiteInfo(url, web.Id);
                        this.teamMailbox.SharePointLinkedBy = this.actAsUser.Id;
                    }
                }
            }
            catch (ClientRequestException ex2)
            {
                ex = new RecipientTaskException(Strings.ErrorTeamMailboxContactSharePointSite(uri.AbsoluteUri, ex2.Message));
            }
            catch (ServerException ex3)
            {
                ex = new RecipientTaskException(Strings.ErrorTeamMailboxContactSharePointSiteWithCorrelationId(uri.AbsoluteUri, ex3.Message, ex3.ServerErrorTraceCorrelationId));
            }
            catch (TimeoutException ex4)
            {
                ex = new RecipientTaskException(Strings.ErrorTeamMailboxContactSharePointSite(uri.AbsoluteUri, ex4.Message));
            }
            catch (IOException ex5)
            {
                ex = new RecipientTaskException(Strings.ErrorTeamMailboxContactSharePointSite(uri.AbsoluteUri, ex5.Message));
            }
            catch (WebException e)
            {
                SharePointException ex6 = new SharePointException(uri.AbsoluteUri, e, false);
                ex = new RecipientTaskException(Strings.ErrorTeamMailboxContactSharePointSite(uri.AbsoluteUri, ex6.DiagnosticInfo));
            }
            catch (FormatException ex7)
            {
                ex = new RecipientTaskException(Strings.ErrorTeamMailboxContactSharePointSite(uri.AbsoluteUri, ex7.Message));
            }
            if (flag && forceToUnlink)
            {
                if (ex != null || linkSharePointSiteResult == LinkSharePointSiteResult.LinkedByOthers)
                {
                    this.teamMailbox.SharePointUrl = null;
                    this.teamMailbox.SetSharePointSiteInfo(null, Guid.Empty);
                    this.teamMailbox.SharePointLinkedBy = null;
                    linkSharePointSiteResult            = LinkSharePointSiteResult.Success;
                }
            }
            else if (ex != null)
            {
                throw ex;
            }
            return(linkSharePointSiteResult);
        }
Exemplo n.º 4
0
 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();
 }