// Token: 0x06000503 RID: 1283 RVA: 0x00025B70 File Offset: 0x00023D70
 private void InitializeArchiveMailboxSession()
 {
     if (this.primaryMailboxSession != null)
     {
         IMailboxInfo archiveMailbox = this.primaryMailboxSession.MailboxOwner.GetArchiveMailbox();
         if (archiveMailbox != null)
         {
             try
             {
                 ExchangePrincipal mailboxOwner = ExchangePrincipal.FromMailboxGuid(this.primaryMailboxSession.GetADSessionSettings(), archiveMailbox.MailboxGuid, RemotingOptions.AllowCrossSite | RemotingOptions.AllowCrossPremise, null);
                 this.archiveMailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.CurrentCulture, "Client=TBA;Action=MoveToArchive;Interactive=False", null, true);
             }
             catch (ObjectNotFoundException arg)
             {
                 LocalArchiveProcessor.Tracer.TraceDebug <IExchangePrincipal, ObjectNotFoundException>((long)this.primaryMailboxSession.GetHashCode(), "{0}: Problems opening the archive.{1}", this.primaryMailboxSession.MailboxOwner, arg);
             }
             catch (StorageTransientException arg2)
             {
                 LocalArchiveProcessor.Tracer.TraceWarning <IExchangePrincipal, MailboxSession, StorageTransientException>((long)this.primaryMailboxSession.GetHashCode(), "{0}: Failed to connect to the the archive mailbox : {1}.\nError:\n{2}", this.primaryMailboxSession.MailboxOwner, this.primaryMailboxSession, arg2);
             }
             catch (StoragePermanentException arg3)
             {
                 LocalArchiveProcessor.Tracer.TraceError <IExchangePrincipal, MailboxSession, StoragePermanentException>((long)this.primaryMailboxSession.GetHashCode(), "{0}: Failed to connect to the the archive mailbox : {1}.\nError:\n{2}", this.primaryMailboxSession.MailboxOwner, this.primaryMailboxSession, arg3);
             }
         }
     }
 }
Beispiel #2
0
        private static Uri GetBackEndWebServicesUrl(IMailboxInfo mailbox)
        {
            Uri       result = null;
            Exception ex     = null;

            try
            {
                result = BackEndLocator.GetBackEndWebServicesUrl(mailbox);
            }
            catch (BackEndLocatorException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    Globals.ConsistencyChecksTracer.TraceError <IMailboxInfo, Exception>(0L, "Unable to find a server to process the request for {0} - {1}", mailbox, ex);
                }
            }
            return(result);
        }
 public static string GetMailboxLegacyDn(this IMailboxInfo mailboxInfo, string userLegacyDn)
 {
     if (mailboxInfo.IsArchive || mailboxInfo.IsAggregated)
     {
         return(userLegacyDn + "/guid=" + mailboxInfo.MailboxGuid);
     }
     return(userLegacyDn);
 }
 public static Guid GetDatabaseGuid(this IMailboxInfo mailboxInfo)
 {
     ArgumentValidator.ThrowIfNull("mailboxInfo", mailboxInfo);
     if (mailboxInfo.MailboxDatabase.IsNullOrEmpty())
     {
         return(Guid.Empty);
     }
     return(mailboxInfo.MailboxDatabase.ObjectGuid);
 }
        public ElcArchiveStoreDataProvider(IExchangePrincipal primaryExchangePrincipal) : base(new LazilyInitialized <IExchangePrincipal>(() => primaryExchangePrincipal))
        {
            IMailboxInfo archiveMailbox = primaryExchangePrincipal.GetArchiveMailbox();

            if (archiveMailbox != null && archiveMailbox.IsRemote)
            {
                throw new NotImplementedException("Cross premise remote archive is not supported yet");
            }
            base.LogonType  = new SpecialLogonType?(SpecialLogonType.SystemService);
            base.BudgetType = OpenAsAdminOrSystemServiceBudgetTypeType.RunAsBackgroundLoad;
        }
Beispiel #6
0
 private static Uri GetBackEndHttpServiceUrl <ServiceType>(IMailboxInfo mailbox) where ServiceType : HttpService
 {
     if (mailbox == null)
     {
         throw new ArgumentNullException("mailbox");
     }
     return(BackEndLocator.CallWithExceptionHandling <Uri>(delegate
     {
         BackEndServer backEndServer = BackEndLocator.GetBackEndServer(mailbox);
         return HttpProxyBackEndHelper.GetBackEndServiceUrlByServer <ServiceType>(backEndServer);
     }));
 }
        private void EnforceSharingPolicy(MailboxSession mailboxSession, ICollection <MapiAclTableRestriction.ExternalUserPermission> externalUserPermissions)
        {
            Util.ThrowOnNullArgument(mailboxSession, "mailboxSession");
            if (externalUserPermissions == null || externalUserPermissions.Count == 0)
            {
                return;
            }
            List <RightsNotAllowedRecipient> list = new List <RightsNotAllowedRecipient>(externalUserPermissions.Count);
            SharingPolicy sharingPolicy           = null;

            foreach (MapiAclTableRestriction.ExternalUserPermission externalUserPermission in externalUserPermissions)
            {
                if (sharingPolicy == null)
                {
                    IMailboxInfo mailboxInfo = mailboxSession.MailboxOwner.MailboxInfo;
                    sharingPolicy = DirectoryHelper.ReadSharingPolicy(mailboxInfo.MailboxGuid, mailboxInfo.IsArchive, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));
                    if (sharingPolicy == null)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: No policy assigned means no external sharing is allowed for this user.", mailboxSession.MailboxOwner);
                        throw new NotAllowedExternalSharingByPolicyException();
                    }
                }
                if (!sharingPolicy.Enabled)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: A disabled policy means no external sharing is allowed for this user.", mailboxSession.MailboxOwner);
                    throw new NotAllowedExternalSharingByPolicyException();
                }
                SharingPolicyAction sharingPolicyAction = externalUserPermission.Principal.ExternalUser.IsReachUser ? sharingPolicy.GetAllowedForAnonymousCalendarSharing() : sharingPolicy.GetAllowed(externalUserPermission.Principal.ExternalUser.SmtpAddress.Domain);
                if (sharingPolicyAction == (SharingPolicyAction)0)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal, PermissionSecurityPrincipal>((long)this.GetHashCode(), "{0}: Policy does not allow granting permissions to {1}.", mailboxSession.MailboxOwner, externalUserPermission.Principal);
                    throw new PrincipalNotAllowedByPolicyException(externalUserPermission.Principal);
                }
                MemberRights allowed      = PolicyAllowedMemberRights.GetAllowed(sharingPolicyAction, this.FolderInfo.StoreObjectType);
                MemberRights memberRights = ~allowed & externalUserPermission.MemberRights;
                if (memberRights != MemberRights.None)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "{0}: Policy does not allow granting permission {1} to {2} on {3} folder '{4}'.", new object[]
                    {
                        mailboxSession.MailboxOwner,
                        memberRights,
                        externalUserPermission.Principal,
                        this.FolderInfo.StoreObjectType,
                        this.FolderInfo.DisplayName
                    });
                    list.Add(new RightsNotAllowedRecipient(externalUserPermission.Principal, memberRights));
                }
            }
            if (list.Count > 0)
            {
                throw new RightsNotAllowedByPolicyException(list.ToArray(), this.FolderInfo.StoreObjectType, this.FolderInfo.DisplayName);
            }
        }
Beispiel #8
0
        private void ValidateBackendServerIfNeeded()
        {
            if (this.isBackendServerValidated)
            {
                return;
            }
            IMailboxInfo mailboxInfo     = base.ExchangePrincipal.MailboxInfo;
            string       localServerFqdn = LocalServerCache.LocalServerFqdn;
            string       serverFqdn      = mailboxInfo.Location.ServerFqdn;

            ExTraceGlobals.CoreTracer.TraceDebug <string, string>((long)this.GetHashCode(), "UserContext.ValidateBackendServerIfNeeded: Target Mailbox location {0}. Current Server Name: {1}.", serverFqdn, localServerFqdn);
            if (!localServerFqdn.Equals(serverFqdn, StringComparison.OrdinalIgnoreCase))
            {
                throw new WrongServerException(ServerStrings.IncorrectServerError(mailboxInfo.PrimarySmtpAddress, serverFqdn), mailboxInfo.GetDatabaseGuid(), serverFqdn, mailboxInfo.Location.ServerVersion, null);
            }
            this.isBackendServerValidated = true;
        }
Beispiel #9
0
 public static BackEndServer GetBackEndServer(IMailboxInfo mailbox)
 {
     if (mailbox == null)
     {
         throw new ArgumentNullException("mailbox");
     }
     return(BackEndLocator.CallWithExceptionHandling <BackEndServer>(delegate
     {
         if (mailbox.Location != null)
         {
             BackEndServer backEndServer = new BackEndServer(mailbox.Location.ServerFqdn, mailbox.Location.ServerVersion);
             ExTraceGlobals.CafeTracer.TraceDebug <BackEndServer, IMailboxInfo>(0L, "[BackEndLocator.GetBackEndServer] Returns back end server {0} for Mailbox {1}", backEndServer, mailbox);
             return backEndServer;
         }
         return BackEndLocator.GetBackEndServerByDatabase(mailbox.MailboxDatabase, mailbox.OrganizationId, mailbox.PrimarySmtpAddress);
     }));
 }
        // Token: 0x06000418 RID: 1048 RVA: 0x0001CFF8 File Offset: 0x0001B1F8
        internal void DeleteConfigMessage(IArchiveProcessor archiveProcessor)
        {
            StoreId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);

            base.MailboxSession.UserConfigurationManager.DeleteFolderConfigurations(defaultFolderId, new string[]
            {
                "MRM"
            });
            IMailboxInfo archiveMailbox = base.MailboxSession.MailboxOwner.GetArchiveMailbox();

            if (!base.MailboxSession.MailboxOwner.MailboxInfo.IsArchive && archiveProcessor != null && archiveMailbox != null && archiveMailbox.IsRemote)
            {
                CloudArchiveProcessor cloudArchiveProcessor = archiveProcessor as CloudArchiveProcessor;
                if (cloudArchiveProcessor != null && cloudArchiveProcessor.ArchiveEwsClient != null)
                {
                    cloudArchiveProcessor.DeleteConfigItemInArchive();
                }
            }
        }
        public ExchangePrincipal WithSelectedMailbox(IMailboxInfo selectedMailboxInfo, RemotingOptions?remotingOptions)
        {
            remotingOptions = new RemotingOptions?(remotingOptions ?? this.remotingOptions);
            bool flag = (remotingOptions & RemotingOptions.AllowCrossPremise) == RemotingOptions.AllowCrossPremise;

            if (selectedMailboxInfo == null || (selectedMailboxInfo.IsRemote && !flag))
            {
                throw new UserHasNoMailboxException();
            }
            if (!this.AllMailboxes.Contains(selectedMailboxInfo))
            {
                throw new InvalidOperationException("Selected mailbox not found in all mailboxes collection");
            }
            ExchangePrincipal exchangePrincipal = this.Clone();

            exchangePrincipal.MailboxInfo     = selectedMailboxInfo;
            exchangePrincipal.remotingOptions = remotingOptions.Value;
            return(exchangePrincipal);
        }
        // Token: 0x06000417 RID: 1047 RVA: 0x0001CE4C File Offset: 0x0001B04C
        internal bool SaveConfigItem(IArchiveProcessor archiveProcessor)
        {
            bool      result = false;
            Exception arg    = null;

            try
            {
                MrmFaiFormatter.Serialize(this.storeTagDictionary, this.storeDefaultArchiveTagDictionary, this.deletedTags, new RetentionHoldData(base.SuspendExpiration, base.ADUser.RetentionComment, base.ADUser.RetentionUrl), this.configItem, false, base.MailboxSession.MailboxOwner);
                this.configItem.Save();
                IMailboxInfo archiveMailbox = base.MailboxSession.MailboxOwner.GetArchiveMailbox();
                if (!base.MailboxSession.MailboxOwner.MailboxInfo.IsArchive && archiveProcessor != null && archiveMailbox != null && archiveMailbox.IsRemote)
                {
                    CloudArchiveProcessor cloudArchiveProcessor = archiveProcessor as CloudArchiveProcessor;
                    if (cloudArchiveProcessor != null && cloudArchiveProcessor.ArchiveEwsClient != null)
                    {
                        byte[] xmlData = MrmFaiFormatter.Serialize(this.storeTagDictionary, this.storeDefaultArchiveTagDictionary, null, new RetentionHoldData(base.SuspendExpiration, base.ADUser.RetentionComment, base.ADUser.RetentionUrl), this.fullCrawlRequired, base.MailboxSession.MailboxOwner);
                        if (!cloudArchiveProcessor.SaveConfigItemInArchive(xmlData))
                        {
                            ElcUserInformation.Tracer.TraceError((long)this.GetHashCode(), "The MRM FAI message could not be saved to the cross-premise archive");
                            return(false);
                        }
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                if (ex is ObjectNotFoundException || ex is ObjectExistedException || ex is SaveConflictException || ex is StorageTransientException || ex is StoragePermanentException)
                {
                    result = false;
                    ElcUserInformation.Tracer.TraceDebug <IExchangePrincipal, MailboxSession, Exception>((long)this.GetHashCode(), "The MRM FAI message could not be saved. Mailbox Owner {0}, Mailbox Session {1}. Exception: {2}", base.MailboxSession.MailboxOwner, base.MailboxSession, arg);
                    throw new TransientMailboxException(ex);
                }
                throw;
            }
            return(result);
        }
        private static LocalizedException CheckHAState(LocalizedString exceptionMessage, LocalizedException mapiException, StoreSession session)
        {
            if (session != null && (mapiException is MapiExceptionBackupInProgress || mapiException is MapiExceptionEndOfSession || mapiException is MapiExceptionLogonFailed || mapiException is MapiExceptionExiting || mapiException is MapiExceptionMailboxInTransit || mapiException is MapiExceptionCanNotComplete || mapiException is MapiExceptionMdbOffline || mapiException is MapiExceptionWrongServer || mapiException is MapiExceptionUnconfigured || mapiException is MapiExceptionUnknownUser || mapiException is MapiExceptionConditionViolation || mapiException is MapiExceptionServerPaused || mapiException is MapiExceptionCallFailed))
            {
                ExTraceGlobals.SessionTracer.TraceDebug <LocalizedException>((long)session.GetHashCode(), "StorageGlobals::CheckHAState. Translating exception {0}.", mapiException);
                DatabaseLocationInfo databaseLocationInfoOnOperationFailure = session.GetDatabaseLocationInfoOnOperationFailure();
                ExTraceGlobals.SessionTracer.TraceDebug <DatabaseLocationInfoResult>((long)session.GetHashCode(), "StorageGlobals::CheckHAState. AM result {0}.", databaseLocationInfoOnOperationFailure.RequestResult);
                switch (databaseLocationInfoOnOperationFailure.RequestResult)
                {
                case DatabaseLocationInfoResult.Success:
                {
                    IExchangePrincipal mailboxOwner = session.MailboxOwner;
                    if (mailboxOwner != null)
                    {
                        IMailboxInfo mailboxInfo = mailboxOwner.MailboxInfo;
                        if (mailboxInfo != null)
                        {
                            IMailboxLocation location = mailboxInfo.Location;
                            if (location != null)
                            {
                                if (string.Equals(location.ServerFqdn, databaseLocationInfoOnOperationFailure.ServerFqdn, StringComparison.OrdinalIgnoreCase))
                                {
                                    if (mapiException is MapiExceptionWrongServer)
                                    {
                                        return(new WrongServerException(exceptionMessage, mapiException));
                                    }
                                    return(null);
                                }
                                else
                                {
                                    if (location.ServerSite == null || databaseLocationInfoOnOperationFailure.ServerSite == null)
                                    {
                                        return(new MailboxInSiteFailoverException(exceptionMessage, mapiException));
                                    }
                                    if (ADObjectId.Equals(location.ServerSite, databaseLocationInfoOnOperationFailure.ServerSite))
                                    {
                                        return(new MailboxInSiteFailoverException(exceptionMessage, mapiException));
                                    }
                                    return(new MailboxCrossSiteFailoverException(exceptionMessage, mapiException, databaseLocationInfoOnOperationFailure));
                                }
                            }
                        }
                    }
                    break;
                }

                case DatabaseLocationInfoResult.Unknown:
                    return(new MailboxOfflineException(exceptionMessage, mapiException));

                case DatabaseLocationInfoResult.InTransitSameSite:
                    return(new MailboxInSiteFailoverException(exceptionMessage, mapiException));

                case DatabaseLocationInfoResult.InTransitCrossSite:
                    return(new MailboxCrossSiteFailoverException(exceptionMessage, mapiException, databaseLocationInfoOnOperationFailure));

                case DatabaseLocationInfoResult.SiteViolation:
                    return(new WrongServerException(exceptionMessage, mapiException));

                default:
                    throw new NotSupportedException(string.Format("DatabaseLocationInfoResult.{0} is not supported", databaseLocationInfoOnOperationFailure));
                }
            }
            return(null);
        }
        // Token: 0x06001ACF RID: 6863 RVA: 0x0006569C File Offset: 0x0006389C
        public static WacAttachmentType Execute(CallContext callContext, IStoreSession originalAttachmentSession, IItem originalAttachmentItem, IAttachment originalAttachment, string draftId, string ewsAttachmentId, bool isEdit)
        {
            MdbCache.GetInstance().BeginAsyncUpdate();
            UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true);

            if (userContext == null)
            {
                throw new OwaInvalidRequestException("Unable to determine user context.");
            }
            if (!userContext.IsWacEditingEnabled)
            {
                isEdit = false;
            }
            ConfigurationContext configurationContext = new ConfigurationContext(userContext);
            AttachmentPolicy     attachmentPolicy     = configurationContext.AttachmentPolicy;
            bool isPublicLogon = userContext.IsPublicLogon;

            if (!attachmentPolicy.GetWacViewingEnabled(isPublicLogon))
            {
                throw new OwaOperationNotSupportedException("WAC viewing not enabled for the current user");
            }
            MailboxSession mailboxSession = null;
            StoreObjectId  draftObjectId  = null;

            if (draftId != null)
            {
                IdAndSession idAndSession = GetWacAttachmentInfo.GetIdAndSession(callContext, draftId, false);
                mailboxSession = (idAndSession.Session as MailboxSession);
                draftObjectId  = StoreId.EwsIdToStoreObjectId(draftId);
                if (mailboxSession == null)
                {
                    throw new OwaOperationNotSupportedException("We need a MailboxSession to create the draft, but this a " + idAndSession.Session.GetType().Name);
                }
            }
            string text = originalAttachmentSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            string primarySmtpAddress        = callContext.EffectiveCaller.PrimarySmtpAddress;
            RequestDetailsLogger protocolLog = callContext.ProtocolLog;

            protocolLog.Set(GetWacAttachmentInfoMetadata.LogonSmtpAddress, primarySmtpAddress);
            protocolLog.Set(GetWacAttachmentInfoMetadata.MailboxSmtpAddress, text);
            protocolLog.Set(GetWacAttachmentInfoMetadata.Edit, isEdit);
            protocolLog.Set(GetWacAttachmentInfoMetadata.Extension, originalAttachment.FileExtension);
            protocolLog.Set(GetWacAttachmentInfoMetadata.DraftProvided, draftId != null);
            string                 displayName = callContext.AccessingPrincipal.MailboxInfo.DisplayName;
            XSOFactory             factory     = new XSOFactory();
            AttachmentDataProvider defaultUploadDataProvider = new AttachmentDataProviderManager().GetDefaultUploadDataProvider(callContext);
            IReferenceAttachment   referenceAttachment       = originalAttachment as IReferenceAttachment;

            if (referenceAttachment != null)
            {
                GetWacAttachmentInfo.LogReferenceAttachmentProperties(protocolLog, referenceAttachment.ProviderEndpointUrl, GetWacAttachmentInfoMetadata.OriginalReferenceAttachmentServiceUrl, referenceAttachment.AttachLongPathName, GetWacAttachmentInfoMetadata.OriginalReferenceAttachmentUrl);
            }
            if (defaultUploadDataProvider != null)
            {
                protocolLog.Set(GetWacAttachmentInfoMetadata.AttachmentDataProvider, defaultUploadDataProvider.ToString());
            }
            WacAttachmentType wacAttachmentType;

            try
            {
                using (GetWacAttachmentInfo.Implementation implementation = new GetWacAttachmentInfo.Implementation(defaultUploadDataProvider, factory, originalAttachmentSession, originalAttachmentSession.MailboxOwner.ModernGroupType, originalAttachmentItem, originalAttachment, ewsAttachmentId, mailboxSession, draftObjectId, isEdit, displayName, (IStoreSession session, StoreId itemId, AttachmentId attachmentId) => new IdAndSession(itemId, (StoreSession)session)
                {
                    AttachmentIds =
                    {
                        attachmentId
                    }
                }.GetConcatenatedId().Id))
                {
                    implementation.Execute();
                    protocolLog.Set(GetWacAttachmentInfoMetadata.OriginalAttachmentType, implementation.OriginalAttachmentType);
                    protocolLog.Set(GetWacAttachmentInfoMetadata.ResultAttachmentType, implementation.ResultAttachmentType);
                    protocolLog.Set(GetWacAttachmentInfoMetadata.ResultAttachmentCreation, implementation.ResultAttachmentCreation);
                    if (implementation.ResultAttachmentType == AttachmentType.Reference)
                    {
                        IMailboxInfo mailboxInfo       = originalAttachmentSession.MailboxOwner.MailboxInfo;
                        string       mailboxAddress    = mailboxInfo.PrimarySmtpAddress.ToString();
                        StoreId      id                = originalAttachmentItem.Id;
                        BaseItemId   itemIdFromStoreId = IdConverter.GetItemIdFromStoreId(id, new MailboxId(mailboxInfo.MailboxGuid));
                        string       exchangeSessionId = WacUtilities.GetExchangeSessionId(default(Guid).ToString());
                        protocolLog.Set(GetWacAttachmentInfoMetadata.ExchangeSessionId, exchangeSessionId);
                        wacAttachmentType = GetWacAttachmentInfo.GetResultForReferenceAttachment(callContext, userContext, implementation, defaultUploadDataProvider, mailboxAddress, itemIdFromStoreId, originalAttachment.FileName, isEdit, displayName, exchangeSessionId, protocolLog);
                    }
                    else
                    {
                        if (implementation.ResultAttachmentType != AttachmentType.Stream)
                        {
                            throw new OwaNotSupportedException("Unsupported attachment type " + implementation.ResultAttachmentType);
                        }
                        AttachmentIdType ewsAttachmentIdType = GetWacAttachmentInfo.GetEwsAttachmentIdType(callContext, implementation.ResultItemId, implementation.ResultAttachmentId);
                        wacAttachmentType = GetWacAttachmentInfo.GetResultForStreamAttachment(callContext, userContext, configurationContext, attachmentPolicy, isPublicLogon, Thread.CurrentThread.CurrentCulture.Name, isEdit, (IStreamAttachment)implementation.ResultAttachment, implementation.ResultAttachmentExtension, ewsAttachmentIdType, implementation.ResultIsInDraft, implementation.ResultStoreSession, text, originalAttachmentSession.MailboxOwner.MailboxInfo.IsArchive);
                    }
                }
            }
            catch (ServerException exception)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception, WacAttachmentStatus.UploadFailed);
            }
            catch (GetWacAttachmentInfo.AttachmentUploadException exception2)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception2, WacAttachmentStatus.UploadFailed);
            }
            catch (RightsManagementPermanentException exception3)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception3, WacAttachmentStatus.ProtectedByUnsupportedIrm);
            }
            catch (AttachmentProtectionException exception4)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception4, WacAttachmentStatus.ProtectedByUnsupportedIrm);
            }
            catch (ObjectNotFoundException exception5)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception5, WacAttachmentStatus.NotFound);
            }
            catch (OwaInvalidRequestException exception6)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception6, WacAttachmentStatus.InvalidRequest);
            }
            catch (WacDiscoveryFailureException exception7)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception7, WacAttachmentStatus.WacDiscoveryFailed);
            }
            catch (WebException exception8)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception8, WacAttachmentStatus.AttachmentDataProviderError);
            }
            if (wacAttachmentType == null)
            {
                throw new OwaInvalidOperationException("There is no reason known for code to reach here without throwing an unhandled exception elsewhere");
            }
            protocolLog.Set(GetWacAttachmentInfoMetadata.Status, wacAttachmentType.Status.ToString());
            return(wacAttachmentType);
        }
Beispiel #15
0
 public static Uri GetBackEndOwaUrl(IMailboxInfo mailbox)
 {
     return(BackEndLocator.GetBackEndHttpServiceUrl <OwaService>(mailbox));
 }
Beispiel #16
0
 public static Uri GetBackEndWebServicesUrl(IMailboxInfo mailbox)
 {
     return(BackEndLocator.GetBackEndHttpServiceUrl <WebServicesService>(mailbox));
 }
Beispiel #17
0
        // Token: 0x0600211A RID: 8474 RVA: 0x0007953C File Offset: 0x0007773C
        internal SessionSettingsType(UserContext userContext, MailboxSession mailboxSession, UserAgent userAgent, CallContext callContext, UMSettingsData umSettings, OwaHelpUrlData helpUrlData)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (userContext.ExchangePrincipal == null)
            {
                throw new OwaInvalidRequestException("userContext.ExchangePrincipal is null");
            }
            StorePerformanceCountersCapture countersCapture = StorePerformanceCountersCapture.Start(mailboxSession);

            this.userDisplayName      = userContext.ExchangePrincipal.MailboxInfo.DisplayName;
            this.userEmailAddress     = userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
            this.userLegacyExchangeDN = userContext.ExchangePrincipal.LegacyDn;
            this.hasArchive           = this.UserHasArchive(userContext.ExchangePrincipal);
            this.archiveDisplayName   = (this.hasArchive ? userContext.ExchangePrincipal.GetArchiveMailbox().ArchiveName : string.Empty);
            IEnumerable <string> source = from emailAddress in userContext.ExchangePrincipal.MailboxInfo.EmailAddresses
                                          select emailAddress.AddressString;

            if (source.Any <string>())
            {
                this.userProxyAddresses = source.ToArray <string>();
            }
            this.UpdateMailboxQuotaLimits(mailboxSession);
            this.isBposUser        = userContext.IsBposUser;
            this.userSipUri        = userContext.SipUri;
            this.userPrincipalName = userContext.UserPrincipalName;
            this.isGallatin        = SessionSettingsType.GetIsGallatin();
            if (userContext.ExchangePrincipal.MailboxInfo.OrganizationId != null)
            {
                this.TenantGuid = userContext.ExchangePrincipal.MailboxInfo.OrganizationId.GetTenantGuid().ToString();
            }
            if (userContext.LogEventCommonData != null)
            {
                this.TenantDomain = userContext.LogEventCommonData.TenantDomain;
            }
            OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettingsMisc, countersCapture, true);
            int?maximumMessageSize = SessionSettingsType.GetMaximumMessageSize(mailboxSession);

            this.maxMessageSizeInKb = ((maximumMessageSize != null) ? maximumMessageSize.Value : 5120);
            OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettingsMessageSize, countersCapture, true);
            this.isPublicLogon = UserContextUtilities.IsPublicRequest(callContext.HttpContext.Request);
            OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettingsIsPublicLogon, countersCapture, true);
            ADUser aduser = null;

            if (userContext.IsExplicitLogon)
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(), 303, ".ctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\types\\SessionSettingsType.cs");
                aduser = (DirectoryHelper.ReadADRecipient(userContext.ExchangePrincipal.MailboxInfo.MailboxGuid, userContext.ExchangePrincipal.MailboxInfo.IsArchive, tenantOrRootOrgRecipientSession) as ADUser);
                if (aduser != null && aduser.SharePointUrl != null)
                {
                    this.sharePointUrl   = aduser.SharePointUrl.ToString();
                    this.sharePointTitle = aduser.DisplayName;
                }
            }
            OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.TeamMailbox, countersCapture, true);
            if (userContext.LogonIdentity != null)
            {
                OWAMiniRecipient owaminiRecipient = userContext.LogonIdentity.GetOWAMiniRecipient();
                this.LogonEmailAddress = string.Empty;
                if (owaminiRecipient != null)
                {
                    SmtpAddress primarySmtpAddress = owaminiRecipient.PrimarySmtpAddress;
                    this.LogonEmailAddress = owaminiRecipient.PrimarySmtpAddress.ToString();
                }
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.GetOWAMiniRecipient, countersCapture, false);
            }
            this.MailboxGuid     = userContext.ExchangePrincipal.MailboxInfo.MailboxGuid.ToString();
            this.isExplicitLogon = userContext.IsExplicitLogon;
            this.isExplicitLogonOthersMailbox = false;
            this.canActAsOwner = true;
            countersCapture    = StorePerformanceCountersCapture.Start(mailboxSession);
            this.SetDefaultFolderMapping(mailboxSession);
            OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SetDefaultFolderMapping, countersCapture, false);
            CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture;

            this.userCulture = currentUICulture.Name;
            this.isUserCultureSpeechEnabled = Culture.IsCultureSpeechEnabled(currentUICulture);
            this.isUserCultureRightToLeft   = currentUICulture.TextInfo.IsRightToLeft;
            countersCapture                    = StorePerformanceCountersCapture.Start(mailboxSession);
            this.playOnPhoneDialString         = umSettings.PlayOnPhoneDialString;
            this.isRequireProtectedPlayOnPhone = umSettings.IsRequireProtectedPlayOnPhone;
            this.isUMEnabled                   = umSettings.IsUMEnabled;
            if (SyncUtilities.IsDatacenterMode())
            {
                SendAsSubscriptionsAndPeopleConnectResult allSendAsSubscriptionsAndPeopleConnect = SubscriptionManager.GetAllSendAsSubscriptionsAndPeopleConnect(mailboxSession);
                List <PimAggregationSubscription>         pimSendAsAggregationSubscriptionList   = allSendAsSubscriptionsAndPeopleConnect.PimSendAsAggregationSubscriptionList;
                this.PeopleConnectionsExist = allSendAsSubscriptionsAndPeopleConnect.PeopleConnectionsExist;
                List <AggregatedAccountInfo> list = null;
                if (aduser == null && userContext.ExchangePrincipal != null)
                {
                    IRecipientSession tenantOrRootOrgRecipientSession2 = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(), 375, ".ctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\types\\SessionSettingsType.cs");
                    aduser = (DirectoryHelper.ReadADRecipient(userContext.ExchangePrincipal.MailboxInfo.MailboxGuid, userContext.ExchangePrincipal.MailboxInfo.IsArchive, tenantOrRootOrgRecipientSession2) as ADUser);
                }
                if (aduser != null)
                {
                    AggregatedAccountHelper aggregatedAccountHelper = new AggregatedAccountHelper(mailboxSession, aduser);
                    list = aggregatedAccountHelper.GetListOfAccounts();
                }
                int capacity = pimSendAsAggregationSubscriptionList.Count + ((list != null) ? list.Count : 0);
                List <ConnectedAccountInfo> list2 = new List <ConnectedAccountInfo>(capacity);
                foreach (PimAggregationSubscription pimAggregationSubscription in pimSendAsAggregationSubscriptionList)
                {
                    list2.Add(new ConnectedAccountInfo
                    {
                        SubscriptionGuid = pimAggregationSubscription.SubscriptionGuid,
                        EmailAddress     = SessionSettingsType.DecodeIdnDomain(pimAggregationSubscription.UserEmailAddress),
                        DisplayName      = pimAggregationSubscription.UserDisplayName
                    });
                }
                if (list != null)
                {
                    foreach (AggregatedAccountInfo aggregatedAccountInfo in list)
                    {
                        bool   flag = false;
                        string aggregatedAccountEmail = SessionSettingsType.DecodeIdnDomain(aggregatedAccountInfo.SmtpAddress);
                        if (!string.IsNullOrWhiteSpace(aggregatedAccountEmail))
                        {
                            if (list2.Find((ConnectedAccountInfo account) => StringComparer.InvariantCultureIgnoreCase.Equals(account.EmailAddress, aggregatedAccountEmail)) != null)
                            {
                                break;
                            }
                            if (!flag)
                            {
                                list2.Add(new ConnectedAccountInfo
                                {
                                    SubscriptionGuid = aggregatedAccountInfo.RequestGuid,
                                    EmailAddress     = aggregatedAccountEmail,
                                    DisplayName      = aggregatedAccountEmail
                                });
                            }
                        }
                    }
                }
                this.connectedAccountInfos = list2.ToArray();
            }
            OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.IsDatacenterMode, countersCapture, true);
            this.helpUrl = helpUrlData.HelpUrl;
            this.isPublicComputerSession = UserContextUtilities.IsPublicComputerSession(callContext.HttpContext);
            string errorString = string.Empty;

            try
            {
                IMailboxInfo mailboxInfo = userContext.ExchangePrincipal.MailboxInfo;
                TenantPublicFolderConfiguration tenantPublicFolderConfiguration = null;
                if (TenantPublicFolderConfigurationCache.Instance.TryGetValue(mailboxInfo.OrganizationId, out tenantPublicFolderConfiguration))
                {
                    ADObjectId            defaultPublicFolderMailbox = userContext.ExchangePrincipal.DefaultPublicFolderMailbox;
                    PublicFolderRecipient publicFolderRecipient      = tenantPublicFolderConfiguration.GetPublicFolderRecipient(mailboxInfo.MailboxGuid, defaultPublicFolderMailbox);
                    if (publicFolderRecipient != null)
                    {
                        if (publicFolderRecipient.IsLocal)
                        {
                            this.DefaultPublicFolderMailbox = publicFolderRecipient.PrimarySmtpAddress.ToString();
                        }
                        else if (publicFolderRecipient.ObjectId == null)
                        {
                            errorString = "publicFolderRecipient not local and ObjectId null";
                        }
                        else
                        {
                            errorString = "publicFolderRecipient not local and ObjectId " + publicFolderRecipient.ObjectId.ObjectGuid;
                        }
                    }
                    else
                    {
                        errorString = "publicFolderRecipient null";
                    }
                }
            }
            catch (LocalizedException ex)
            {
                errorString = ex.ToString();
            }
            finally
            {
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.DefaultPublicFolderMailbox, countersCapture, true, errorString);
            }
        }
 // Token: 0x0600059A RID: 1434 RVA: 0x0002B0FC File Offset: 0x000292FC
 public static Uri DiscoverEwsUrl(IMailboxInfo mailbox)
 {
     return(BackEndLocator.GetBackEndWebServicesUrl(mailbox));
 }
Beispiel #19
0
        private ExchangePrincipal BuildExchangePrincipal(IGenericADUser user, bool isSelectedMailboxArchive, ADObjectId selectedDatabaseId, Guid?selectedMailboxGuid, MailboxConfiguration mailboxConfiguration, IMailboxLocation selectedMailboxLocation, Func <ADObjectId, IMailboxLocation> locationFactory, RemotingOptions remotingOptions)
        {
            List <IMailboxInfo> list = new List <IMailboxInfo>();

            if (user.ArchiveGuid != Guid.Empty)
            {
                IMailboxInfo mailboxInfo5 = this.BuildMailboxInfo(user.ArchiveGuid, user.ArchiveDatabase, isSelectedMailboxArchive, selectedDatabaseId, selectedMailboxLocation, user, mailboxConfiguration, locationFactory);
                if (mailboxInfo5 != null)
                {
                    list.Add(mailboxInfo5);
                }
            }
            bool flag = false;

            if (selectedMailboxGuid != null && selectedMailboxGuid.Value != Guid.Empty)
            {
                if (user.MailboxLocations != null)
                {
                    flag = user.MailboxLocations.Any((IMailboxLocationInfo mailboxInfo) => mailboxInfo.MailboxGuid == selectedMailboxGuid.Value);
                }
                if (!flag && user.AggregatedMailboxGuids != null)
                {
                    flag = user.AggregatedMailboxGuids.Any((Guid mailbox) => mailbox == selectedMailboxGuid.Value);
                }
            }
            if (user.MailboxGuid != Guid.Empty)
            {
                bool         isSelected   = (selectedMailboxGuid != null && user.MailboxGuid.Equals(selectedMailboxGuid.Value)) || !flag || !isSelectedMailboxArchive;
                IMailboxInfo mailboxInfo2 = this.BuildMailboxInfo(user.MailboxGuid, user.MailboxDatabase, isSelected, selectedDatabaseId, selectedMailboxLocation, user, mailboxConfiguration, locationFactory);
                if (mailboxInfo2 != null)
                {
                    list.Add(mailboxInfo2);
                }
            }
            if (user.MailboxLocations != null)
            {
                foreach (IMailboxLocationInfo mailboxLocationInfo in user.MailboxLocations)
                {
                    IMailboxInfo mailboxInfo3 = this.BuildMailboxInfo(mailboxLocationInfo.MailboxGuid, mailboxLocationInfo.DatabaseLocation, mailboxLocationInfo.MailboxLocationType.Equals(MailboxLocationType.MainArchive) ? isSelectedMailboxArchive : (mailboxLocationInfo.MailboxGuid == selectedMailboxGuid), mailboxLocationInfo.DatabaseLocation, selectedMailboxLocation, user, mailboxConfiguration, locationFactory);
                    if (mailboxInfo3 != null)
                    {
                        list.Add(mailboxInfo3);
                    }
                }
            }
            if (user.AggregatedMailboxGuids != null)
            {
                foreach (Guid guid in user.AggregatedMailboxGuids)
                {
                    IMailboxInfo mailboxInfo4 = this.BuildMailboxInfo(guid, user.MailboxDatabase, selectedMailboxGuid == guid, selectedDatabaseId, selectedMailboxLocation, user, mailboxConfiguration, locationFactory);
                    if (mailboxInfo4 != null)
                    {
                        list.Add(mailboxInfo4);
                    }
                }
            }
            Func <IMailboxInfo, bool> mailboxSelector;

            if (isSelectedMailboxArchive)
            {
                mailboxSelector = ((IMailboxInfo mailbox) => mailbox.MailboxType == MailboxLocationType.MainArchive);
            }
            else if (selectedMailboxGuid != null && selectedMailboxGuid != Guid.Empty)
            {
                mailboxSelector = ((IMailboxInfo mailbox) => mailbox.MailboxGuid == selectedMailboxGuid);
            }
            else
            {
                mailboxSelector = ((IMailboxInfo mailbox) => mailbox.MailboxGuid == user.MailboxGuid && mailbox.MailboxType == MailboxLocationType.Primary);
            }
            return(this.BuildPrincipal(user, list, mailboxSelector, remotingOptions));
        }
Beispiel #20
0
        // Token: 0x06002167 RID: 8551 RVA: 0x00079F04 File Offset: 0x00078104
        private bool UserHasArchive(ExchangePrincipal principal)
        {
            IMailboxInfo archiveMailbox = principal.GetArchiveMailbox();

            return(archiveMailbox != null && (archiveMailbox.ArchiveState == ArchiveState.Local || archiveMailbox.ArchiveState == ArchiveState.HostedProvisioned));
        }
Beispiel #21
0
 public GenericADUser(IExchangePrincipal exchangePrincipal)
 {
     ArgumentValidator.ThrowIfNull("exchangePrincipal", exchangePrincipal);
     this.LegacyDn = exchangePrincipal.LegacyDn;
     this.Alias    = exchangePrincipal.Alias;
     this.DefaultPublicFolderMailbox = exchangePrincipal.DefaultPublicFolderMailbox;
     this.Sid = exchangePrincipal.Sid;
     this.MasterAccountSid          = exchangePrincipal.MasterAccountSid;
     this.SidHistory                = exchangePrincipal.SidHistory;
     this.GrantSendOnBehalfTo       = exchangePrincipal.Delegates;
     this.Languages                 = exchangePrincipal.PreferredCultures;
     this.ObjectId                  = exchangePrincipal.ObjectId;
     this.RecipientType             = exchangePrincipal.RecipientType;
     this.RecipientTypeDetails      = exchangePrincipal.RecipientTypeDetails;
     this.IsResource                = exchangePrincipal.IsResource;
     this.AggregatedMailboxGuids    = exchangePrincipal.AggregatedMailboxGuids;
     this.ModernGroupType           = exchangePrincipal.ModernGroupType;
     this.PublicToGroupSids         = exchangePrincipal.PublicToGroupSids;
     this.ExternalDirectoryObjectId = exchangePrincipal.ExternalDirectoryObjectId;
     if (exchangePrincipal.MailboxInfo != null)
     {
         this.DisplayName          = exchangePrincipal.MailboxInfo.DisplayName;
         this.PrimarySmtpAddress   = exchangePrincipal.MailboxInfo.PrimarySmtpAddress;
         this.ExternalEmailAddress = exchangePrincipal.MailboxInfo.ExternalEmailAddress;
         this.EmailAddresses       = new ProxyAddressCollection();
         foreach (ProxyAddress item in exchangePrincipal.MailboxInfo.EmailAddresses)
         {
             this.EmailAddresses.Add(item);
         }
         this.OrganizationId     = exchangePrincipal.MailboxInfo.OrganizationId;
         this.MailboxGuid        = exchangePrincipal.MailboxInfo.MailboxGuid;
         this.MailboxDatabase    = exchangePrincipal.MailboxInfo.MailboxDatabase;
         this.WhenMailboxCreated = exchangePrincipal.MailboxInfo.WhenMailboxCreated;
         IUserPrincipal userPrincipal = exchangePrincipal as IUserPrincipal;
         if (userPrincipal != null)
         {
             this.WindowsLiveID = userPrincipal.WindowsLiveId;
             this.NetId         = userPrincipal.NetId;
         }
         IMailboxInfo mailboxInfo = exchangePrincipal.AllMailboxes.FirstOrDefault((IMailboxInfo mailbox) => mailbox.IsArchive);
         if (mailboxInfo != null)
         {
             this.ArchiveGuid     = mailboxInfo.MailboxGuid;
             this.ArchiveDatabase = mailboxInfo.MailboxDatabase;
             this.ArchiveName     = new string[]
             {
                 mailboxInfo.ArchiveName
             };
             this.ArchiveState  = mailboxInfo.ArchiveState;
             this.ArchiveStatus = mailboxInfo.ArchiveStatus;
         }
         this.SharePointUrl                     = exchangePrincipal.MailboxInfo.Configuration.SharePointUrl;
         this.IsMapiEnabled                     = exchangePrincipal.MailboxInfo.Configuration.IsMapiEnabled;
         this.IsOwaEnabled                      = exchangePrincipal.MailboxInfo.Configuration.IsOwaEnabled;
         this.IsMowaEnabled                     = exchangePrincipal.MailboxInfo.Configuration.IsMowaEnabled;
         this.ThrottlingPolicy                  = exchangePrincipal.MailboxInfo.Configuration.ThrottlingPolicy;
         this.OwaMailboxPolicy                  = exchangePrincipal.MailboxInfo.Configuration.OwaMailboxPolicy;
         this.MobileDeviceMailboxPolicy         = exchangePrincipal.MailboxInfo.Configuration.MobileDeviceMailboxPolicy;
         this.AddressBookPolicy                 = exchangePrincipal.MailboxInfo.Configuration.AddressBookPolicy;
         this.IsPersonToPersonMessagingEnabled  = exchangePrincipal.MailboxInfo.Configuration.IsPersonToPersonMessagingEnabled;
         this.IsMachineToPersonMessagingEnabled = exchangePrincipal.MailboxInfo.Configuration.IsMachineToPersonMessagingEnabled;
         this.SkuCapability                     = exchangePrincipal.MailboxInfo.Configuration.SkuCapability;
         this.SkuAssigned                  = exchangePrincipal.MailboxInfo.Configuration.SkuAssigned;
         this.IsMailboxAuditEnabled        = exchangePrincipal.MailboxInfo.Configuration.IsMailboxAuditEnabled;
         this.BypassAudit                  = exchangePrincipal.MailboxInfo.Configuration.BypassAudit;
         this.MailboxAuditLogAgeLimit      = exchangePrincipal.MailboxInfo.Configuration.MailboxAuditLogAgeLimit;
         this.AuditAdminOperations         = exchangePrincipal.MailboxInfo.Configuration.AuditAdminOperations;
         this.AuditDelegateOperations      = exchangePrincipal.MailboxInfo.Configuration.AuditDelegateOperations;
         this.AuditDelegateAdminOperations = exchangePrincipal.MailboxInfo.Configuration.AuditDelegateAdminOperations;
         this.AuditOwnerOperations         = exchangePrincipal.MailboxInfo.Configuration.AuditOwnerOperations;
         this.AuditLastAdminAccess         = exchangePrincipal.MailboxInfo.Configuration.AuditLastAdminAccess;
         this.AuditLastDelegateAccess      = exchangePrincipal.MailboxInfo.Configuration.AuditLastDelegateAccess;
         this.AuditLastExternalAccess      = exchangePrincipal.MailboxInfo.Configuration.AuditLastExternalAccess;
         this.MailboxLocations             = Enumerable.Empty <IMailboxLocationInfo>();
     }
 }