Esempio n. 1
0
        private static void SaveArchiveSecurityDescriptor(ADUser mailbox, IConfigDataProvider writableAdSession, RawSecurityDescriptor rawSd, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            ADObjectId adobjectId = mailbox.ArchiveDatabase ?? mailbox.Database;
            MailboxId  mailboxId  = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), mailbox.ArchiveGuid);

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(adobjectId.ObjectGuid);
                using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn)))
                {
                    logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName));
                    mapiMessageStoreSession.ForceStoreToRefreshMailbox(mailboxId);
                }
            }
            catch (FormatException)
            {
                logError(new TaskInvalidOperationException(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString())), ExchangeErrorCategory.ServerOperation, null);
            }
            catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException)
            {
                logVerbose(Strings.VerboseArchiveNotExistInStore(mailbox.Name));
                PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            }
            catch (LocalizedException exception)
            {
                logError(new SetArchivePermissionException(mailbox.Name, exception), ExchangeErrorCategory.ServerOperation, null);
            }
        }
        public override string ToString()
        {
            MailboxId mailboxId = base.MapiObjectId as MailboxId;

            if (null != mailboxId)
            {
                return(mailboxId.ToString());
            }
            if (!string.IsNullOrEmpty(this.displayName))
            {
                return(this.displayName);
            }
            return(string.Empty);
        }
Esempio n. 3
0
        public static void SaveMailboxSecurityDescriptor(ADUser mailbox, ActiveDirectorySecurity adSecurity, IConfigDataProvider writableAdSession, ref MapiMessageStoreSession storeSession, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            if (writableAdSession == null)
            {
                throw new ArgumentException("writableAdSession");
            }
            RawSecurityDescriptor rawSd = new RawSecurityDescriptor(adSecurity.GetSecurityDescriptorBinaryForm(), 0);

            PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            string text = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(mailbox.Database.ObjectGuid);
                text = serverForDatabase.ServerFqdn;
                if (storeSession == null)
                {
                    storeSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn));
                }
                else
                {
                    storeSession.RedirectServer(serverForDatabase.ServerLegacyDN, Fqdn.Parse(serverForDatabase.ServerFqdn));
                }
                MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(mailbox.Database), mailbox.ExchangeGuid);
                logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), storeSession.ServerName));
                storeSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid);
            }
            catch (DatabaseNotFoundException)
            {
                logVerbose(Strings.ErrorMailboxDatabaseNotFound(mailbox.Database.ToString()));
            }
            catch (MapiExceptionNetworkError)
            {
                logVerbose(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty));
            }
            catch (FormatException)
            {
                logVerbose(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString()));
            }
            catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException)
            {
                logVerbose(Strings.VerboseMailboxNotExistInStore(mailbox.DistinguishedName));
            }
            if (mailbox.HasLocalArchive)
            {
                PermissionTaskHelper.SaveArchiveSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            }
        }
Esempio n. 4
0
 public MailboxIdentity(MailboxId rawIdentity) : base(rawIdentity.ToString(), rawIdentity.ToString())
 {
 }
Esempio n. 5
0
        internal static void CheckLegacyDNNotInUse(MailboxId disconnectedMailboxIdentity, string disconnectedMailboxLegacyDN, IRecipientSession globalCatalogSession, Task.ErrorLoggerDelegate errorLogger)
        {
            ADRecipient adrecipient = ConnectMailbox.FindMailboxByLegacyDN(disconnectedMailboxLegacyDN, globalCatalogSession);

            if (adrecipient != null)
            {
                errorLogger(new MdbAdminTaskException(Strings.ErrorMailboxLegacyDNInUse(disconnectedMailboxLegacyDN, disconnectedMailboxIdentity.ToString(), adrecipient.DisplayName)), ExchangeErrorCategory.ServerOperation, disconnectedMailboxIdentity);
            }
        }
Esempio n. 6
0
        internal void RefreshStoreCache()
        {
            this.AddVerboseLog("Start: RefreshStoreCache");
            bool flag = this.groupMailbox.WhenMailboxCreated == null || this.groupMailbox.WhenMailboxCreated.Value.AddMinutes(15.0).ToUniversalTime() > DateTime.UtcNow;

            if (flag)
            {
                return;
            }
            string text = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(this.groupMailbox.Database.ObjectGuid);
                text = serverForDatabase.ServerFqdn;
                using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, serverForDatabase.ServerLegacyDN + "/cn=Microsoft System Attendant", Fqdn.Parse(serverForDatabase.ServerFqdn)))
                {
                    MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(this.groupMailbox.Database), this.groupMailbox.ExchangeGuid);
                    this.AddVerboseLog(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName));
                    mapiMessageStoreSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid);
                }
            }
            catch (DatabaseNotFoundException)
            {
                this.AddVerboseLog(Strings.ErrorMailboxDatabaseNotFound(this.groupMailbox.Database.ToString()));
            }
            catch (MapiExceptionNetworkError)
            {
                this.AddVerboseLog(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty));
            }
            catch (MailboxNotFoundException)
            {
                this.AddVerboseLog(Strings.VerboseMailboxNotExistInStore(this.groupMailbox.DistinguishedName));
            }
            this.AddVerboseLog("End: RefreshStoreCache");
        }
Esempio n. 7
0
        public void TestMailboxIdProperties()
        {
            MailboxId mailboxId = new MailboxId("*****@*****.**");

            Assert.AreEqual(
                mailboxId.Id,
                "*****@*****.**");

            Assert.IsTrue(mailboxId.IdInEmailAddressForm);
            Assert.IsFalse(mailboxId.IdInMeForm);
            Assert.AreEqual(
                mailboxId.Path,
                "users/[email protected]");

            Assert.IsTrue(mailboxId.Equals(new MailboxId("*****@*****.**")));

            mailboxId = new MailboxId("me");
            Assert.IsTrue(mailboxId.IdInMeForm);
            Assert.IsFalse(mailboxId.IdInEmailAddressForm);

            Assert.AreEqual(
                mailboxId.Path,
                "me");

            Assert.IsFalse(mailboxId.Equals(null));
            Assert.AreEqual(
                mailboxId.ToString(),
                "me");

            string guidFormat = "35190d3b-a0c3-462f-873d-14739728ec13@fddcbad5-788b-4eb8-be11-21d569abe684";

            mailboxId = new MailboxId(guidFormat);

            Assert.AreEqual(
                mailboxId.Id,
                guidFormat);

            Assert.AreEqual(
                mailboxId.Path,
                $"users/{guidFormat}");

            string invalidGuidFormat1 = "35190d3b-a0c3-462f873d-14739728ec13@fddcbad5-788b-4eb8-be11-21d569abe684";
            string invalidGuidFormat2 = "35190d3b-a0c3-462f-873d-14739728ec13@fddcbad5-788b-4eb8be11-21d569abe684";
            string invalidGuidFormat3 = "35190d3b-a0c3-462f-873d-14739728ec13@";
            string invalidFormat1     = "fsdsfsfds";
            string invalidFormat2     = "fsdfs@fsfsd@fs";

            Assert.ThrowsException <ArgumentException>(() =>
            {
                mailboxId = new MailboxId(invalidGuidFormat1);
            });

            Assert.ThrowsException <ArgumentException>(() =>
            {
                mailboxId = new MailboxId(invalidGuidFormat2);
            });

            Assert.ThrowsException <ArgumentException>(() =>
            {
                mailboxId = new MailboxId(invalidGuidFormat3);
            });

            Assert.ThrowsException <ArgumentException>(() =>
            {
                mailboxId = new MailboxId(invalidFormat1);
            });

            Assert.ThrowsException <ArgumentException>(() =>
            {
                mailboxId = new MailboxId(invalidFormat2);
            });
        }