public MailboxInfo(Guid mailboxGuid, ADObjectId databaseId, IGenericADUser adUser, IMailboxConfiguration mailboxConfiguration, IMailboxLocation mailboxLocation) { ArgumentValidator.ThrowIfEmpty("mailboxGuid", mailboxGuid); ArgumentValidator.ThrowIfNull("adUser", adUser); ArgumentValidator.ThrowIfNull("mailboxConfiguration", mailboxConfiguration); ArgumentValidator.ThrowIfNull("mailboxLocation", mailboxLocation); MailboxLocationType?mailboxLocationType = adUser.GetMailboxLocationType(mailboxGuid); if (mailboxLocationType == null) { throw new ArgumentException("The provided mailbox guid doesn't match with any of the user's mailbox."); } this.MailboxType = mailboxLocationType.Value; this.DisplayName = adUser.DisplayName; this.PrimarySmtpAddress = adUser.PrimarySmtpAddress; this.ExternalEmailAddress = adUser.ExternalEmailAddress; this.EmailAddresses = (adUser.EmailAddresses ?? Array <ProxyAddress> .Empty); this.OrganizationId = adUser.OrganizationId; this.MailboxGuid = mailboxGuid; this.MailboxDatabase = databaseId; if (this.IsArchive) { this.archiveName = ((adUser.ArchiveName != null) ? (adUser.ArchiveName.FirstOrDefault <string>() ?? string.Empty) : string.Empty); this.archiveState = adUser.ArchiveState; this.archiveStatus = adUser.ArchiveStatus; this.IsRemote = adUser.IsArchiveMailboxRemote(); } else { this.IsRemote = adUser.IsPrimaryMailboxRemote(); } if (this.IsRemote) { this.remoteIdentity = this.GetRemoteIdentity(adUser, this.IsArchive); } else if (this.MailboxDatabase.IsNullOrEmpty()) { throw new ObjectNotFoundException(ServerStrings.MailboxDatabaseRequired(mailboxGuid)); } this.WhenMailboxCreated = adUser.WhenMailboxCreated; this.Location = mailboxLocation; this.Configuration = mailboxConfiguration; }
public static bool IsArchiveMailboxRemote(this IGenericADUser user) { return(VariantConfiguration.InvariantNoFlightingSnapshot.DataStorage.RepresentRemoteMailbox.Enabled && (user.IsPrimaryMailboxRemote() || user.ArchiveDomain != null)); }