Exemple #1
0
 internal static void UpdateSDAndRefreshMailbox(MapiAdministrationSession mapiAdministrationSession, ADUser userToConnect, MailboxDatabase database, Guid mailboxGuid, string parameterSetName, Task.TaskVerboseLoggingDelegate verboseLogger, Task.TaskWarningLoggingDelegate warningLogger)
 {
     ConnectMailbox.UpdateMailboxSecurityDescriptor(userToConnect.Sid, userToConnect, mapiAdministrationSession, database, mailboxGuid, parameterSetName, verboseLogger);
     try
     {
         mapiAdministrationSession.ForceStoreToRefreshMailbox(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), mailboxGuid));
     }
     catch (FailedToRefreshMailboxException ex)
     {
         TaskLogger.Trace("An exception is caught and ignored when refreshing the mailbox '{0}'. Exception: {1}", new object[]
         {
             mailboxGuid,
             ex.Message
         });
         warningLogger(Strings.WarningReplicationLatency);
     }
     try
     {
         mapiAdministrationSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), mailboxGuid));
     }
     catch (DataSourceTransientException ex2)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex2
         });
         warningLogger(ex2.LocalizedString);
     }
     catch (DataSourceOperationException ex3)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex3
         });
         warningLogger(ex3.LocalizedString);
     }
     catch (ArgumentNullException ex4)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex4
         });
         warningLogger(Strings.ErrorNoDatabaseInfor);
     }
 }
Exemple #2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     if (this.PublicFolder)
     {
         MailboxTaskHelper.RemoveOrDisablePublicFolderMailbox(this.DataObject, this.exchangeGuid, this.TenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), true, false);
     }
     base.InternalProcessRecord();
     if ("Archive" == base.ParameterSetName || "RemoteArchive" == base.ParameterSetName)
     {
         TaskLogger.Trace("DisableMailbox -Archive or -RemoteArchive skipping InternalProcessRecord", new object[0]);
         TaskLogger.LogExit();
         return;
     }
     try
     {
         MailboxDatabase mailboxDatabase = null;
         if (this.mdbId != null)
         {
             mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(new DatabaseIdParameter(this.mdbId)
             {
                 AllowLegacy = true
             }, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.mdbId.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.mdbId.ToString())));
         }
         if (mailboxDatabase != null && this.exchangeGuid != Guid.Empty)
         {
             Server server = mailboxDatabase.GetServer();
             if (server == null)
             {
                 this.WriteWarning(Strings.ErrorDBOwningServerNotFound(mailboxDatabase.Identity.ToString()));
             }
             else if (string.IsNullOrEmpty(server.ExchangeLegacyDN))
             {
                 this.WriteWarning(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, server.Identity.ToString(), ServerSchema.ExchangeLegacyDN.Name));
             }
             else if (string.IsNullOrEmpty(server.Fqdn))
             {
                 this.WriteWarning(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, server.Identity.ToString(), ServerSchema.Fqdn.Name));
             }
             else
             {
                 base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(server.Fqdn));
                 using (MapiAdministrationSession mapiAdministrationSession = new MapiAdministrationSession(server.ExchangeLegacyDN, Fqdn.Parse(server.Fqdn)))
                 {
                     base.WriteVerbose(Strings.VerboseSyncMailboxWithDS(this.Identity.ToString(), this.mdbId.ToString(), server.Fqdn));
                     mapiAdministrationSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(this.mdbId), this.exchangeGuid));
                 }
             }
         }
     }
     catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex
         });
         base.WriteVerbose(ex.LocalizedString);
     }
     catch (DataSourceTransientException ex2)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex2
         });
         this.WriteWarning(ex2.LocalizedString);
     }
     catch (DataSourceOperationException ex3)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex3
         });
         this.WriteWarning(ex3.LocalizedString);
     }
     TaskLogger.LogExit();
 }