internal static CreateAttachmentResponse AttachReferenceAttachment(AttachmentDataProvider attachmentDataProvider, UserContext userContext, string location, string dataProviderItemId, string parentItemId, IdConverter idConverter, string dataProviderParentItemId = null, string providerEndpointUrl = null)
		{
			CreateAttachmentResponse result = null;
			if (!userContext.IsDisposed)
			{
				if (string.IsNullOrEmpty(providerEndpointUrl))
				{
					providerEndpointUrl = attachmentDataProvider.GetEndpointUrlFromItemLocation(location);
				}
				string linkingUrl = attachmentDataProvider.GetLinkingUrl(userContext, location, providerEndpointUrl, dataProviderItemId, dataProviderParentItemId);
				string text = Path.GetFileName(HttpUtility.UrlDecode(linkingUrl));
				if (OneDriveProUtilities.IsDurableUrlFormat(text))
				{
					text = text.Substring(0, text.LastIndexOf("?", StringComparison.InvariantCulture));
				}
				try
				{
					userContext.LockAndReconnectMailboxSession();
					IdAndSession idAndSession = new IdAndSession(StoreId.EwsIdToStoreObjectId(parentItemId), userContext.MailboxSession);
					ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType
					{
						Name = text,
						AttachLongPathName = linkingUrl,
						ProviderEndpointUrl = providerEndpointUrl,
						ProviderType = attachmentDataProvider.Type.ToString()
					};
					if (!userContext.IsGroupUserContext)
					{
						referenceAttachmentType.ContentId = Guid.NewGuid().ToString();
						referenceAttachmentType.ContentType = "image/png";
					}
					AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true);
					using (AttachmentBuilder attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[]
					{
						referenceAttachmentType
					}, idConverter, true))
					{
						ServiceError serviceError;
						Attachment attachment = attachmentBuilder.CreateAttachment(referenceAttachmentType, out serviceError);
						if (serviceError == null)
						{
							attachmentHierarchy.SaveAll();
						}
						result = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, referenceAttachmentType, idAndSession, serviceError);
					}
				}
				finally
				{
					userContext.UnlockAndDisconnectMailboxSession();
				}
			}
			return result;
		}
Example #2
0
        // Token: 0x060007D0 RID: 2000 RVA: 0x00019AD4 File Offset: 0x00017CD4
        internal static IConfigurationSession CreateADSystemConfigurationSession(bool readOnly, ConsistencyMode consistencyMode, UserContext userContext, IBudget budget)
        {
            ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(userContext.ExchangePrincipal.MailboxInfo.OrganizationId);

            adsessionSettings.AccountingObject = budget;
            return(DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(readOnly, consistencyMode, adsessionSettings, 379, "CreateADSystemConfigurationSession", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\common\\UserContextUtilities.cs"));
        }
 internal InstantMessageOCSNotifier(UserContext userContext) : base(userContext)
 {
     this.deliverySuccessNotifications = new List <DeliverySuccessNotification>();
 }
Example #4
0
 public SingleSpeechRecognitionScenario(RequestParameters requestParameters, UserContext userContext) : base(requestParameters, userContext)
 {
     ValidateArgument.NotNull(requestParameters, "requestParameters is null");
     ValidateArgument.NotNull(userContext, "userContext is null");
 }
 internal InstantSearchNotifier(string subscriptionId, UserContext userContext) : base(subscriptionId, userContext)
 {
     this.payloadCollection = new List <InstantSearchNotificationPayload>(3);
 }
 // Token: 0x06000F14 RID: 3860 RVA: 0x0003A9D6 File Offset: 0x00038BD6
 public PlayOnPhoneNotificationHandler(UserContext userContext)
 {
     this.notifier      = this.CreateNotifier(userContext);
     this.stateProvider = this.CreateStateProvider(userContext);
 }
        // Token: 0x06001CAA RID: 7338 RVA: 0x000729F0 File Offset: 0x00070BF0
        public FindPeopleSpeechRecognitionResultHandler(RequestParameters parameters, UserContext userContext, HttpContext httpContext)
        {
            IADRecipientLookup iadrecipientLookup = ADRecipientLookupFactory.CreateFromTenantGuid(parameters.TenantGuid);

            this.userRecipient = iadrecipientLookup.LookupByObjectId(new ADObjectId(parameters.UserObjectGuid));
            this.userContext   = userContext;
            this.httpContext   = httpContext;
        }
Example #8
0
        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);
        }
Example #9
0
        protected override Stream InternalExecute()
        {
            UserContext          userContext          = UserContextManager.GetUserContext(HttpContext.Current, CallContext.Current.EffectiveCaller, true);
            ConfigurationContext configurationContext = new ConfigurationContext(userContext);
            string           mailboxSmtpAddress       = userContext.MailboxIdentity.PrimarySmtpAddress.ToString();
            CobaltStoreSaver cobaltStoreSaver;

            if (WacUtilities.ShouldUpdateAttachment(mailboxSmtpAddress, this.id, out cobaltStoreSaver))
            {
                base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Updated, true);
                cobaltStoreSaver.SaveAndLogExceptions(base.CallContext.ProtocolLog);
            }
            else
            {
                base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Updated, false);
            }
            AttachmentHandler attachmentHandler = new AttachmentHandler(this.id, this.webOperationContext, base.CallContext, configurationContext);

            attachmentHandler.IsImagePreview = this.isImagePreview;
            Stream result;

            try
            {
                using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(this.id, base.CallContext))
                {
                    AttachmentHandler.IAttachmentPolicyChecker policyChecker = AttachmentPolicyChecker.CreateInstance(configurationContext.AttachmentPolicy);
                    Stream attachmentStream = attachmentHandler.GetAttachmentStream(attachmentRetriever, policyChecker, this.asDataUri);
                    GetAttachment.EliminateGzFileDoubleCompression(attachmentRetriever);
                    base.CallContext.OnDisposed += delegate(object sender, EventArgs args)
                    {
                        if (attachmentStream != null)
                        {
                            attachmentStream.Dispose();
                        }
                    };
                    if (attachmentRetriever.Attachment != null)
                    {
                        base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Extension, attachmentRetriever.Attachment.FileExtension);
                        base.CallContext.ProtocolLog.Set(GetAttachmentMetadata.Length, attachmentRetriever.Attachment.Size);
                    }
                    result = attachmentStream;
                }
            }
            catch (InvalidStoreIdException innerException)
            {
                throw new OwaInvalidRequestException("Invalid ID, " + this.GetParametersForLogging(), innerException);
            }
            catch (InvalidIdMalformedException innerException2)
            {
                throw new OwaInvalidRequestException("Malformed ID, " + this.GetParametersForLogging(), innerException2);
            }
            catch (CannotOpenFileAttachmentException)
            {
                this.webOperationContext.StatusCode = HttpStatusCode.NotFound;
                result = null;
            }
            catch (ObjectNotFoundException)
            {
                this.webOperationContext.StatusCode = HttpStatusCode.NotFound;
                result = null;
            }
            return(result);
        }
Example #10
0
        private static WacAttachmentType GetResultForReferenceAttachment(CallContext callContext, UserContext userContext, GetWacAttachmentInfo.Implementation implementation, AttachmentDataProvider provider, string mailboxAddress, BaseItemId referenceItemId, string fileName, bool isEdit, string userDisplayName, string sessionId, RequestDetailsLogger logger)
        {
            GetWacAttachmentInfo.LogReferenceAttachmentProperties(logger, implementation.ResultAttachmentWebServiceUrl, GetWacAttachmentInfoMetadata.ResultReferenceAttachmentServiceUrl, implementation.ResultAttachmentContentUrl, GetWacAttachmentInfoMetadata.ResultReferenceAttachmentUrl);
            AttachmentIdType  ewsAttachmentIdType = GetWacAttachmentInfo.GetEwsAttachmentIdType(callContext, implementation.ResultItemId, implementation.ResultAttachmentId);
            WacAttachmentType result = GetWacAttachmentInfo.CreateWacAttachmentType(userContext.LogonIdentity, ewsAttachmentIdType, implementation.ResultAttachmentWebServiceUrl, implementation.ResultAttachmentContentUrl, isEdit, implementation.ResultIsInDraft);

            if (implementation.ResultAttachmentCreation == WacAttachmentCreationType.Upload)
            {
                try
                {
                    GetWacAttachmentInfo.PostUploadMessage(mailboxAddress, userContext.LogonIdentity.PrimarySmtpAddress.ToString(), userDisplayName, referenceItemId, fileName, implementation.ResultAttachmentContentUrl, implementation.ResultAttachmentProviderType, implementation.ResultAttachmentWebServiceUrl, sessionId);
                }
                catch (Exception value)
                {
                    logger.Set(GetWacAttachmentInfoMetadata.HandledException, value);
                }
            }
            return(result);
        }
Example #11
0
        private static WacAttachmentType GetResultForStreamAttachment(CallContext callContext, UserContext userContext, ConfigurationContext configurationContext, AttachmentPolicy attachmentPolicy, bool isPublicLogon, string cultureName, bool isEdit, IStreamAttachment attachment, string attachmentExtension, AttachmentIdType attachmentIdType, bool isInDraft, IStoreSession storeSession, string mailboxSmtpAddress, bool isArchive)
        {
            WacFileRep  wacFileRep = GetWacAttachmentInfo.CreateWacFileRep(callContext, configurationContext, attachmentPolicy, isPublicLogon, isEdit, isArchive);
            HttpRequest request    = callContext.HttpContext.Request;
            string      text;
            string      arg;

            GetWacAttachmentInfo.GenerateWopiSrcUrl(request, wacFileRep, mailboxSmtpAddress, out text, out arg);
            if (text == null)
            {
                throw new OwaInvalidOperationException("WOPI URL is null.");
            }
            string      id                = attachmentIdType.Id;
            TokenResult oauthToken        = GetWacAttachmentInfo.GetOAuthToken(id, userContext, mailboxSmtpAddress, text);
            string      exchangeSessionId = WacUtilities.GetExchangeSessionId(oauthToken.TokenString);

            callContext.ProtocolLog.Set(GetWacAttachmentInfoMetadata.ExchangeSessionId, exchangeSessionId);
            SecurityIdentifier effectiveCallerSid = callContext.EffectiveCallerSid;

            CachedAttachmentInfo.GetInstance(mailboxSmtpAddress, id, exchangeSessionId, effectiveCallerSid, cultureName);
            string wacUrl = GetWacAttachmentInfo.GetWacUrl(isEdit, cultureName, attachmentExtension);

            if (string.IsNullOrEmpty(wacUrl))
            {
                throw new OwaInvalidRequestException(string.Format("Wac Base Url is null for this given extension {0} and culture {1}", attachmentExtension, cultureName));
            }
            new Uri(wacUrl);
            string format = "{0}WOPISrc={1}&access_token={2}";
            string arg2   = HttpUtility.UrlEncode(oauthToken.TokenString);
            string text2  = string.Format(format, wacUrl, HttpUtility.UrlEncode(text), arg2);
            string value  = string.Format(format, wacUrl, arg, arg2);

            callContext.ProtocolLog.Set(GetWacAttachmentInfoMetadata.WacUrl, value);
            if (!Uri.IsWellFormedUriString(text2, UriKind.Absolute))
            {
                throw new OwaInvalidOperationException("The WAC Iframe URL that was generated is not a well formed URI: " + text2);
            }
            return(new WacAttachmentType
            {
                AttachmentId = attachmentIdType,
                IsEdit = isEdit,
                IsInDraft = isInDraft,
                WacUrl = text2,
                Status = WacAttachmentStatus.Success
            });
        }
Example #12
0
 // Token: 0x06001A8B RID: 6795 RVA: 0x00063290 File Offset: 0x00061490
 private UserConfigurationManager.IAggregationContext CreateAggregatedConfiguration(UserContext userContext, MailboxSession session)
 {
     UserConfigurationManager.IAggregationContext result = null;
     if (userContext != null && !userContext.IsExplicitLogon && session != null && session.UserConfigurationManager != null)
     {
         ExTraceGlobals.CoreTracer.TraceDebug((long)this.GetHashCode(), "user configuration will create an aggregated user configuration.");
         result = session.UserConfigurationManager.AttachAggregator(AggregatedUserConfigurationSchema.Instance.OwaUserConfiguration);
     }
     return(result);
 }
Example #13
0
        // Token: 0x06001A7B RID: 6779 RVA: 0x0006247C File Offset: 0x0006067C
        protected override OwaUserConfiguration InternalExecute()
        {
            MailboxSession mailboxIdentityMailboxSession = base.MailboxIdentityMailboxSession;
            UserContext    userContext = UserContextManager.GetUserContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, true);

            UserConfigurationManager.IAggregationContext aggregationContext = null;
            OwaUserConfiguration result;

            try
            {
                if (!DefaultPageBase.IsRecoveryBoot(base.CallContext.HttpContext))
                {
                    using (UserConfigurationManager.IAggregationContext aggregationContext2 = userContext.TryConsumeBootAggregation())
                    {
                        if (aggregationContext2 != null)
                        {
                            aggregationContext = mailboxIdentityMailboxSession.UserConfigurationManager.AttachAggregator(aggregationContext2);
                        }
                        else
                        {
                            aggregationContext = this.CreateAggregatedConfiguration(userContext, mailboxIdentityMailboxSession);
                        }
                    }
                }
                UserOptionsType userOptionsType = new UserOptionsType();
                userOptionsType.Load(mailboxIdentityMailboxSession, true, true);
                OwaUserConfiguration owaUserConfiguration = new OwaUserConfiguration();
                owaUserConfiguration.UserOptions = userOptionsType;
                string    userAgent  = CallContext.Current.HttpContext.Request.UserAgent;
                UserAgent userAgent2 = new UserAgent(userAgent, userContext.FeaturesManager.ClientServerSettings.ChangeLayout.Enabled, base.CallContext.HttpContext.Request.Cookies);
                StorePerformanceCountersCapture countersCapture = StorePerformanceCountersCapture.Start(mailboxIdentityMailboxSession);
                UMSettingsData umSettings = this.ReadAggregatedUMSettingsData(aggregationContext, userContext.ExchangePrincipal);
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.UMClient, countersCapture, true);
                owaUserConfiguration.SessionSettings = new SessionSettingsType(userContext, mailboxIdentityMailboxSession, userAgent2, base.CallContext, umSettings, this.ReadAggregatedOwaHelpUrlData(aggregationContext, Thread.CurrentThread.CurrentUICulture, userContext.MailboxIdentity, userAgent2));
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SessionSettings, countersCapture, true);
                ConfigurationContext configurationContext = new ConfigurationContext(userContext, aggregationContext);
                string defaultTheme = configurationContext.DefaultTheme;
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.ConfigContext, countersCapture, true);
                owaUserConfiguration.SegmentationSettings = new SegmentationSettingsType(configurationContext);
                owaUserConfiguration.SegmentationSettings.InstantMessage &= !UserAgentUtilities.IsMonitoringRequest(userAgent);
                owaUserConfiguration.SegmentationSettings.InstantMessage &= VdirConfiguration.Instance.InstantMessagingEnabled;
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.SegmentationSettings, countersCapture, true);
                WacConfigData wacData = AttachmentPolicy.ReadAggregatedWacData(userContext, aggregationContext);
                owaUserConfiguration.AttachmentPolicy = configurationContext.AttachmentPolicy.CreateAttachmentPolicyType(userContext, userAgent2, wacData);
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.AttachmentPolicy, countersCapture, true);
                PolicySettingsType policySettingsType = new PolicySettingsType();
                policySettingsType.PlacesEnabled  = (this.placesConfigurationCache.IsFeatureEnabled && configurationContext.PlacesEnabled && !PlacesConfigurationCache.IsRestrictedCulture(owaUserConfiguration.SessionSettings.UserCulture));
                policySettingsType.WeatherEnabled = (this.weatherConfigurationCache.IsFeatureEnabled && configurationContext.WeatherEnabled && !this.weatherConfigurationCache.IsRestrictedCulture(owaUserConfiguration.SessionSettings.UserCulture));
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.PlacesWeather, countersCapture, true);
                policySettingsType.DefaultTheme         = configurationContext.DefaultTheme;
                policySettingsType.InstantMessagingType = configurationContext.InstantMessagingType;
                policySettingsType.UseGB18030           = configurationContext.UseGB18030;
                policySettingsType.UseISO885915         = configurationContext.UseISO885915;
                policySettingsType.OutboundCharset      = configurationContext.OutboundCharset;
                policySettingsType.AllowCopyContactsToDeviceAddressBook = configurationContext.AllowCopyContactsToDeviceAddressBook;
                policySettingsType.AllowOfflineOnString = configurationContext.AllowOfflineOn.ToString();
                policySettingsType.MySiteUrl            = configurationContext.MySiteUrl;
                owaUserConfiguration.PolicySettings     = policySettingsType;
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.PolicySettings, countersCapture, true);
                owaUserConfiguration.MobileDevicePolicySettings = MobileDevicePolicyDataFactory.GetPolicySettings(this.ReadAggregatedMobileDevicePolicyData(aggregationContext, userContext.ExchangePrincipal));
                owaUserConfiguration.ApplicationSettings        = this.GetApplicationSettings();
                owaUserConfiguration.ViewStateConfiguration     = new OwaViewStateConfiguration();
                owaUserConfiguration.ViewStateConfiguration.LoadAll(mailboxIdentityMailboxSession);
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.OwaViewStateConfiguration, countersCapture, true);
                OrganizationId organizationId = mailboxIdentityMailboxSession.MailboxOwner.MailboxInfo.OrganizationId;
                this.SetUserConfigPropertiesFromOrganizationConfig(aggregationContext, organizationId, owaUserConfiguration);
                userContext.IsPublicLogon = (owaUserConfiguration.SessionSettings.IsPublicLogon || (owaUserConfiguration.PublicComputersDetectionEnabled && owaUserConfiguration.SessionSettings.IsPublicComputerSession));
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.GetMailTipsLargeAudienceThreshold, countersCapture, true);
                owaUserConfiguration.RetentionPolicyTags = this.GetRetentionPolicyTags(mailboxIdentityMailboxSession);
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.GetRetentionPolicyTags, countersCapture, true);
                try
                {
                    owaUserConfiguration.MasterCategoryList = MasterCategoryListHelper.GetMasterCategoryListType(mailboxIdentityMailboxSession, base.CallContext.OwaCulture);
                }
                catch (QuotaExceededException ex)
                {
                    ExTraceGlobals.UserContextCallTracer.TraceDebug <string>(0L, "GetOwaUserConfiguration:  Get MasterCategoryList failed. Exception: {0}", ex.Message);
                }
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.GetMasterCategoryListType, countersCapture, true);
                owaUserConfiguration.MaxRecipientsPerMessage = this.GetMaxRecipientsPerMessage();
                OwaUserConfigurationLogUtilities.LogAndResetPerfCapture(OwaUserConfigurationLogType.GetMaxRecipientsPerMessage, countersCapture, false);
                owaUserConfiguration.RecoverDeletedItemsEnabled = configurationContext.RecoverDeletedItemsEnabled;
                base.CallContext.ProtocolLog.Set(OwaUserConfigurationLogMetadata.UserCulture, owaUserConfiguration.SessionSettings.UserCulture);
                Converter <KeyValuePair <string, string>, string> converter;
                if (userContext.FeaturesManager.ServerSettings.FlightFormat.Enabled)
                {
                    converter = ((KeyValuePair <string, string> pair) => "&" + pair.Key + ":" + pair.Value);
                }
                else
                {
                    converter = ((KeyValuePair <string, string> pair) => pair.Key + " = " + pair.Value);
                }
                if (userContext.FeaturesManager.ConfigurationSnapshot != null && userContext.FeaturesManager.ClientSettings.OWADiagnostics.Enabled)
                {
                    owaUserConfiguration.FlightConfiguration = Array.ConvertAll <KeyValuePair <string, string>, string>(userContext.FeaturesManager.ConfigurationSnapshot.Constraints, converter);
                }
                else
                {
                    owaUserConfiguration.FlightConfiguration = new string[0];
                }
                this.ReadInferenceSettings(mailboxIdentityMailboxSession, userContext, owaUserConfiguration);
                if (base.CallContext.IsSmimeInstalled)
                {
                    owaUserConfiguration.SmimeAdminSettings = new SmimeAdminSettingsType(this.ReadAggregatedSmimeData(aggregationContext, organizationId));
                }
                VariantConfigurationSnapshot configurationSnapshot = userContext.FeaturesManager.ConfigurationSnapshot;
                if (configurationSnapshot != null)
                {
                    IInlineExploreSettings inlineExploreSettings = configurationSnapshot.OwaServer.InlineExploreSettings;
                    if (inlineExploreSettings != null)
                    {
                        owaUserConfiguration.InlineExploreContent = inlineExploreSettings.Content;
                    }
                }
                owaUserConfiguration.PolicyTipsEnabled = this.ReadAggregatedPolicyTipsData(aggregationContext, organizationId).IsPolicyTipsEnabled;
                UserContext.ReadAggregatedFlightConfigData(aggregationContext, organizationId);
                this.RecordAggregationStats(aggregationContext);
                result = owaUserConfiguration;
            }
            finally
            {
                this.ValidateAndDisposeAggregatedConfiguration(aggregationContext, mailboxIdentityMailboxSession);
            }
            return(result);
        }
 // Token: 0x06000A62 RID: 2658 RVA: 0x00023BA0 File Offset: 0x00021DA0
 internal InstantMessageManager(UserContext userContext)
 {
     ExTraceGlobals.InstantMessagingTracer.TraceDebug((long)this.GetHashCode(), "InstantMessageManager Constructor.");
     this.userContext = userContext;
 }
 // Token: 0x06000D88 RID: 3464 RVA: 0x00033275 File Offset: 0x00031475
 internal CreateAttachmentNotifier(UserContext userContext, string subscriptionId) : base(subscriptionId, userContext)
 {
 }
Example #16
0
        // Token: 0x06001D5A RID: 7514 RVA: 0x000750BC File Offset: 0x000732BC
        private static void GetUserIdentity(HttpContext httpContext, out Guid userObjectGuid, out Guid tenantGuid, out OrganizationId orgId, out UserContext userContext)
        {
            ExTraceGlobals.SpeechRecognitionTracer.TraceDebug(0L, "Entering SpeechRecognitionProcessor.GetUserIdentity");
            userContext    = UserContextManager.GetUserContext(httpContext);
            userObjectGuid = userContext.ExchangePrincipal.ObjectId.ObjectGuid;
            orgId          = userContext.ExchangePrincipal.MailboxInfo.OrganizationId;
            IADSystemConfigurationLookup iadsystemConfigurationLookup = ADSystemConfigurationLookupFactory.CreateFromOrganizationId(orgId);

            tenantGuid = iadsystemConfigurationLookup.GetExternalDirectoryOrganizationId();
            ExTraceGlobals.SpeechRecognitionTracer.TraceDebug <Guid, Guid, OrganizationId>(0L, "SpeechRecognitionProcessor.GetUserIdentity - userObjectGuid='{0}', tenantGuid='{1}', orgId='{2}'", userObjectGuid, tenantGuid, orgId);
        }
        // Token: 0x06001BCF RID: 7119 RVA: 0x0006B438 File Offset: 0x00069638
        private bool UpdateO365Theme(string themeId, string userPrincipalName, UserContext userContext)
        {
            bool flag = userContext.FeaturesManager.ClientServerSettings.O365Header.Enabled || userContext.FeaturesManager.ClientServerSettings.O365G2Header.Enabled;

            this.tracer.TraceDebug <bool, bool>(0L, "UpdateO365Theme::isFeatureSupported='{0}', this.skipO365Call='{1}'", flag, this.request.SkipO365Call);
            if (!flag || this.request.SkipO365Call)
            {
                return(false);
            }
            string text  = null;
            string text2 = null;
            string text3 = string.Empty;
            bool   result;

            try
            {
                using (ShellServiceClient shellServiceClient = new ShellServiceClient("MsOnlineShellService_EndPointConfiguration"))
                {
                    string text4 = ConfigurationManager.AppSettings["MsOnlineShellService_CertThumbprint"];
                    this.tracer.TraceDebug <string, CommunicationState>(1L, "UpdateO365Theme::certificateThumbprint='{0}',client.State'={1}'", text4, shellServiceClient.State);
                    shellServiceClient.ClientCredentials.ClientCertificate.Certificate = TlsCertificateInfo.FindCertByThumbprint(text4);
                    EndpointAddress address = shellServiceClient.Endpoint.Address;
                    Uri             uri     = new Uri(address.Uri.AbsoluteUri);
                    shellServiceClient.Endpoint.Address = new EndpointAddress(uri, address.Identity, new AddressHeader[0]);
                    string text5 = HttpContext.Current.Request.Headers["RPSOrgIdPUID"];
                    text  = (string.IsNullOrEmpty(text5) ? HttpContext.Current.Request.Headers["RPSPUID"] : text5);
                    text2 = shellServiceClient.Endpoint.Address.Uri.AbsoluteUri;
                    text3 = Guid.NewGuid().ToString();
                    this.tracer.TraceDebug(2L, "UpdateO365Theme::orgIdPuid='{0}', userPuid='{1}', userPrincipalName='{2}',serviceUrl='{3}'", new object[]
                    {
                        text5,
                        text,
                        userPrincipalName,
                        text2
                    });
                    SetUserThemeRequest setUserThemeRequest = new SetUserThemeRequest
                    {
                        ThemeId           = themeId,
                        TrackingGuid      = text3,
                        UserPrincipalName = userPrincipalName,
                        UserPuid          = text,
                        WorkloadId        = WorkloadAuthenticationId.Exchange
                    };
                    this.tracer.TraceDebug(3L, "UpdateO365Theme::setUserThemeRequest.ThemeId='{0}', .TrackingGuid='{1}', .UserPrincipalName='{2}', .UserPuid='{3}', .WorkloadId='{4}'", new object[]
                    {
                        setUserThemeRequest.ThemeId,
                        setUserThemeRequest.TrackingGuid,
                        setUserThemeRequest.UserPrincipalName,
                        setUserThemeRequest.UserPuid,
                        setUserThemeRequest.WorkloadId
                    });
                    shellServiceClient.SetUserTheme(setUserThemeRequest);
                    this.tracer.TraceDebug <CommunicationState>(4L, "UpdateO365Theme::setUserThemeRequest.State='{0}'", shellServiceClient.State);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                this.tracer.TraceError(5L, "UpdateO365Theme::Exception: themeId='{0}', trackingGuid='{1}', userPrincipalName='{2}', userPuid='{3}', serviceUrl='{4}', exception='{5}'", new object[]
                {
                    themeId,
                    text3,
                    userPrincipalName,
                    text,
                    text2,
                    ex
                });
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_O365SetUserThemeError, userPrincipalName + text2 + themeId, new object[]
                {
                    text,
                    userPrincipalName,
                    text3,
                    text2,
                    themeId,
                    ex
                });
                result = false;
            }
            return(result);
        }
Example #18
0
        public static UcwaUserConfiguration GetUcwaUserConfiguration(string sipUri, CallContext callContext)
        {
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsTaskCompleted, bool.FalseString);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsUcwaSupported, bool.FalseString);
            UcwaUserConfiguration ucwaUserConfiguration = new UcwaUserConfiguration();

            ucwaUserConfiguration.SipUri = sipUri;
            if (string.IsNullOrEmpty(sipUri))
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsTaskCompleted, bool.TrueString);
                throw new OwaInvalidRequestException("No sipUri specified");
            }
            UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true);

            if (string.Compare(userContext.SipUri, sipUri, StringComparison.OrdinalIgnoreCase) != 0)
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ManagerSipUri, ExtensibleLogger.FormatPIIValue(sipUri));
            }
            if (userContext.ExchangePrincipal.MailboxInfo.OrganizationId != null && userContext.ExchangePrincipal.MailboxInfo.OrganizationId.OrganizationalUnit != null)
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.Organization, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.OrganizationalUnit.Name);
            }
            OAuthCredentials oauthCredential;

            try
            {
                oauthCredential = UcwaConfigurationUtilities.GetOAuthCredential(sipUri);
                oauthCredential.ClientRequestId = new Guid?(Guid.NewGuid());
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.OAuthCorrelationId, oauthCredential.ClientRequestId.Value.ToString());
            }
            catch (OwaException ex)
            {
                string text = UcwaConfigurationUtilities.BuildFailureLogString(ex);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.Exceptions, text);
                ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetUcwaUserConfiguration] An error occurred while obtaining OAuth credential; Exception: {0}", text);
                ucwaUserConfiguration.DiagnosticInfo = text;
                return(ucwaUserConfiguration);
            }
            AutodiscoverResult ucwaDiscoveryUrl = AutodiscoverWorker.GetUcwaDiscoveryUrl(sipUri, oauthCredential);

            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.AuthenticatedLyncAutodiscoverServer, ucwaDiscoveryUrl.AuthenticatedLyncAutodiscoverServer);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsAuthdServerFromCache, ucwaDiscoveryUrl.IsAuthdServerFromCache ? bool.TrueString : bool.FalseString);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsUcwaUrlFromCache, ucwaDiscoveryUrl.IsUcwaUrlFromCache ? bool.TrueString : bool.FalseString);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.UnauthenticatedRedirectHops, string.Join(";", ucwaDiscoveryUrl.UnauthenticatedRedirects));
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.AuthenticatedRedirectHops, string.Join(";", ucwaDiscoveryUrl.AuthenticatedRedirects));
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.WorkerExceptions, ucwaDiscoveryUrl.BuildFailureString());
            if (!ucwaDiscoveryUrl.IsOnlineMeetingEnabled)
            {
                ExTraceGlobals.OnlineMeetingTracer.TraceInformation(0, 0L, "[UcwaConfigurationUtilities.GetUcwaUserConfiguration] Online meetings are not enabled in this topology");
                ucwaUserConfiguration.DiagnosticInfo = "Online meetings not enabled on the server";
                return(ucwaUserConfiguration);
            }
            if (ucwaDiscoveryUrl.HasError)
            {
                Exception     exception     = ucwaDiscoveryUrl.Error.Exception;
                StringBuilder stringBuilder = new StringBuilder(ucwaDiscoveryUrl.Error.FailureStep.ToString() + "_");
                stringBuilder.Append(UcwaConfigurationUtilities.BuildFailureLogString(exception));
                stringBuilder.Append(ucwaDiscoveryUrl.Error.ResponseFailureReason ?? string.Empty);
                string text2 = stringBuilder.ToString();
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.Exceptions, text2);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.RequestHeaders, ucwaDiscoveryUrl.Error.RequestHeaders);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ResponseHeaders, ucwaDiscoveryUrl.Error.ResponseHeaders);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ResponseBody, ucwaDiscoveryUrl.Error.ResponseBody);
                if (ucwaDiscoveryUrl.IsAuthdServerFromCache)
                {
                    AutodiscoverCache.InvalidateDomain(OnlineMeetingHelper.GetSipDomain(sipUri));
                    callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.CacheOperation, AutodiscoverCacheOperation.InvalidateDomain.ToString());
                }
                ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetUcwaUserConfiguration] An error occured while fetching UCWA configuration; Exception: {0}", text2);
                ucwaUserConfiguration.DiagnosticInfo = text2;
                return(ucwaUserConfiguration);
            }
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ResponseBody, ucwaDiscoveryUrl.ResponseBody);
            ucwaUserConfiguration.IsUcwaSupported = ucwaDiscoveryUrl.IsUcwaSupported;
            ucwaUserConfiguration.UcwaUrl         = ucwaDiscoveryUrl.UcwaDiscoveryUrl;
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsTaskCompleted, bool.TrueString);
            if (ucwaUserConfiguration.IsUcwaSupported)
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsUcwaSupported, bool.TrueString);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.UcwaUrl, ucwaUserConfiguration.UcwaUrl);
            }
            return(ucwaUserConfiguration);
        }
 // Token: 0x06000F19 RID: 3865 RVA: 0x0003AAF3 File Offset: 0x00038CF3
 protected virtual IPlayOnPhoneStateProvider CreateStateProvider(UserContext userContext)
 {
     return(new PlayOnPhoneStateProvider(userContext));
 }
Example #20
0
 internal static WacConfigData ReadAggregatedWacData(UserContext userContext, UserConfigurationManager.IAggregationContext ctx)
 {
     return(UserContextUtilities.ReadAggregatedType <WacConfigData>(ctx, "OWA.WacData", () => AttachmentPolicy.GetWacConfigData(userContext)));
 }
 public ConfigurationContext(UserContext userContext) : this(userContext, null)
 {
 }
Example #22
0
        private static WacConfigData GetWacConfigData(UserContext userContext)
        {
            WacConfigData wacConfigData = new WacConfigData();

            if (userContext == null)
            {
                throw new NullReferenceException("Retail assert: UserContext is null.");
            }
            if (userContext.FeaturesManager == null)
            {
                throw new NullReferenceException("Retail assert: UserContext.FeaturesManager is null.");
            }
            if (WacConfiguration.Instance == null)
            {
                throw new NullReferenceException("Retail assert: WacConfiguration.Instance is null.");
            }
            if (WacDiscoveryManager.Instance == null)
            {
                throw new NullReferenceException("Retail assert: WacDiscoveryManager.Instance is null.");
            }
            if (WacDiscoveryManager.Instance.WacDiscoveryResult == null)
            {
                throw new NullReferenceException("Retail assert: WacDiscoveryManager.Instance.WacDiscoveryResult is null.");
            }
            if (!WacConfiguration.Instance.BlockWacViewingThroughUI)
            {
                if (userContext.FeaturesManager.ClientServerSettings.DocCollab.Enabled || userContext.FeaturesManager.ClientServerSettings.ModernAttachments.Enabled)
                {
                    wacConfigData.IsWacEditingEnabled = WacConfiguration.Instance.EditingEnabled;
                }
                else
                {
                    wacConfigData.IsWacEditingEnabled = false;
                }
                try
                {
                    wacConfigData.WacViewableFileTypes  = WacDiscoveryManager.Instance.WacDiscoveryResult.WacViewableFileTypes;
                    wacConfigData.WacEditableFileTypes  = WacDiscoveryManager.Instance.WacDiscoveryResult.WacEditableFileTypes;
                    wacConfigData.WacDiscoverySucceeded = true;
                }
                catch (WacDiscoveryFailureException ex)
                {
                    OwaDiagnostics.PublishMonitoringEventNotification(ExchangeComponent.OwaDependency.Name, "DocCollab", ex.Message, ResultSeverityLevel.Error);
                    wacConfigData.WacViewableFileTypes  = new string[0];
                    wacConfigData.WacEditableFileTypes  = new string[0];
                    wacConfigData.WacDiscoverySucceeded = false;
                    wacConfigData.IsWacEditingEnabled   = false;
                }
            }
            if (userContext.IsBposUser)
            {
                string text;
                string text2;
                wacConfigData.OneDriveDiscoverySucceeded   = OneDriveProAttachmentDataProvider.TryGetBposDocumentsInfoFromBox(userContext, CallContext.Current, out text, out text2);
                wacConfigData.OneDriveDocumentsUrl         = (text ?? string.Empty);
                wacConfigData.OneDriveDocumentsDisplayName = (text2 ?? string.Empty);
            }
            else
            {
                wacConfigData.OneDriveDiscoverySucceeded   = true;
                wacConfigData.OneDriveDocumentsUrl         = string.Empty;
                wacConfigData.OneDriveDocumentsDisplayName = string.Empty;
            }
            return(wacConfigData);
        }
Example #23
0
 public InstantSearchRemoteNotificationHandler(UserContext userContext)
 {
     this.userContext = userContext;
 }
 internal HierarchyNotifier(string subscriptionId, UserContext userContext) : base(subscriptionId, userContext)
 {
     this.folderCountTable = new Dictionary <StoreObjectId, HierarchyNotificationPayload>();
 }
 internal BposShellInfoAssetReader(string userPrincipalName, CultureInfo culture, BposHeaderFlight currentHeaderFlight, UserContext userContext) : base(userPrincipalName, culture)
 {
     this.currentHeaderFlight = currentHeaderFlight;
     this.userContext         = userContext;
     this.isGemini            = (this.currentHeaderFlight == BposHeaderFlight.E16Gemini1 || this.currentHeaderFlight == BposHeaderFlight.E16Gemini2);
 }
Example #26
0
        // Token: 0x0600160C RID: 5644 RVA: 0x00050308 File Offset: 0x0004E508
        public static bool IsDownLevelClient(HttpContext httpContext, bool avoidUserContextAccess = false)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext cannot be null");
            }
            HttpCookie httpCookie = httpContext.Request.Cookies["PALEnabled"];

            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
            {
                return(false);
            }
            if (httpContext.Items.Contains("IsDownLevelClient"))
            {
                return((bool)httpContext.Items["IsDownLevelClient"]);
            }
            if (Utility.IsResourceRequest(httpContext.Request.Url.LocalPath))
            {
                avoidUserContextAccess = true;
            }
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = true;
            bool isAndroidPremiumEnabled = false;

            if (httpContext.User != null && httpContext.User.Identity.IsAuthenticated && !avoidUserContextAccess)
            {
                UserContext userContext = UserContextManager.GetMailboxContext(httpContext, null, true) as UserContext;
                if (userContext != null)
                {
                    bool flag4 = Culture.GetPreferredCultureInfo(userContext.ExchangePrincipal) != null;
                    if (flag4)
                    {
                        ConfigurationContext configurationContext = new ConfigurationContext(userContext);
                        flag3 = configurationContext.IsFeatureEnabled(Feature.RichClient);
                        flag2 = userContext.IsOptimizedForAccessibility;
                        flag  = true;
                        ExTraceGlobals.CoreCallTracer.TraceDebug(0L, string.Format("isOptimizedForAccessibility: {0}, isRichClientFeatureEnabled: {1}", flag2, flag3));
                    }
                    if (userContext.FeaturesManager.ServerSettings.AndroidPremium.Enabled)
                    {
                        isAndroidPremiumEnabled = true;
                    }
                }
                else
                {
                    ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "userContext is null when process IsDownLevelClient");
                }
            }
            bool flag5 = RequestDispatcherUtilities.IsDownLevelClient(httpContext.Request, flag2, flag3, isAndroidPremiumEnabled);

            if (flag)
            {
                httpContext.Items["IsDownLevelClient"] = flag5;
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, string.Format("Cache result '{0}' for IsDownLevelClient", flag5));
            }
            else
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, string.Format("Result '{0}' for IsDownLevelClient is not cached.", flag5));
            }
            return(flag5);
        }
Example #27
0
        // Token: 0x060007D1 RID: 2001 RVA: 0x00019B1C File Offset: 0x00017D1C
        internal static IRecipientSession CreateADRecipientSession(int lcid, bool readOnly, ConsistencyMode consistencyMode, bool useDirectorySearchRoot, UserContext userContext, bool scopeToGal, IBudget budget)
        {
            ADSessionSettings adsessionSettings;

            if (scopeToGal)
            {
                adsessionSettings = ADSessionSettings.FromOrganizationIdWithAddressListScopeServiceOnly(userContext.ExchangePrincipal.MailboxInfo.OrganizationId, (userContext.GetGlobalAddressList(budget) != null) ? userContext.GetGlobalAddressList(budget).Id : null);
            }
            else if (userContext.ExchangePrincipal.MailboxInfo.Configuration.AddressBookPolicy != null)
            {
                adsessionSettings = ADSessionSettings.FromOrganizationIdWithAddressListScopeServiceOnly(userContext.ExchangePrincipal.MailboxInfo.OrganizationId, userContext.GlobalAddressListId);
            }
            else
            {
                adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(userContext.ExchangePrincipal.MailboxInfo.OrganizationId);
            }
            adsessionSettings.AccountingObject = budget;
            return(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, useDirectorySearchRoot ? userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN : null, lcid, readOnly, consistencyMode, null, adsessionSettings, 436, "CreateADRecipientSession", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\common\\UserContextUtilities.cs"));
        }
Example #28
0
        // Token: 0x06001619 RID: 5657 RVA: 0x00050A1C File Offset: 0x0004EC1C
        internal static void SetXFrameOptionsHeader(RequestContext requestContext, OwaRequestType requestType)
        {
            if (requestContext == null)
            {
                return;
            }
            HttpContext httpContext = requestContext.HttpContext;

            if (httpContext == null || !httpContext.Request.HttpMethod.Equals("GET") || (httpContext.Request.UserAgent != null && httpContext.Request.UserAgent.Contains("MSAppHost")))
            {
                return;
            }
            switch (requestType)
            {
            case OwaRequestType.EsoRequest:
            case OwaRequestType.Oeh:
            case OwaRequestType.ProxyPing:
            case OwaRequestType.KeepAlive:
            case OwaRequestType.Resource:
            case OwaRequestType.PublishedCalendarView:
            case OwaRequestType.ICalHttpHandler:
            case OwaRequestType.HealthPing:
            case OwaRequestType.SpeechReco:
                break;

            case OwaRequestType.Form15:
            case OwaRequestType.ProxyLogon:
            case OwaRequestType.LanguagePage:
            case OwaRequestType.LanguagePost:
            case OwaRequestType.Attachment:
            case OwaRequestType.WebPart:
            case OwaRequestType.ServiceRequest:
                goto IL_9D;

            default:
                if (requestType != OwaRequestType.SuiteServiceProxyPage)
                {
                    goto IL_9D;
                }
                break;
            }
            return;

IL_9D:
            string value = "SAMEORIGIN";

            if (RequestDispatcherUtilities.IsCmdWebPart(httpContext.Request))
            {
                UserContext userContext = (requestContext.UserContext ?? UserContextManager.GetMailboxContext(httpContext, null, true)) as UserContext;
                if (userContext != null)
                {
                    ConfigurationContext configurationContext = new ConfigurationContext(userContext);
                    if (configurationContext != null)
                    {
                        switch ((int)configurationContext.GetFeaturesEnabled(Feature.WebPartsDefaultOrigin | Feature.WebPartsEnableOrigins))
                        {
                        case 0:
                        case 1:
                            value = "DENY";
                            break;

                        case 2:
                            value = null;
                            break;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(value))
            {
                httpContext.Response.Headers.Set("X-Frame-Options", value);
            }
        }
 internal PlayOnPhoneNotificationManager(UserContext userContext)
 {
     this.userContext = userContext;
 }
        // Token: 0x060019D0 RID: 6608 RVA: 0x0005C974 File Offset: 0x0005AB74
        internal static void UploadAndAttachReferenceAttachment(Guid operationId, UserContext userContext, CallContext callContext, ItemId itemId, string fileName, byte[] fileContent, IdConverter idConverter, string subscriptionId, string channelId, CancellationToken cancellationToken, string cancellationId)
        {
            AttachmentResultCode errorCode    = AttachmentResultCode.GenericFailure;
            AttachmentIdType     attachmentId = null;
            Exception            exception    = null;

            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate()
                {
                    try
                    {
                        AttachmentDataProvider attachmentDataProvider = userContext.AttachmentDataProviderManager.GetDefaultUploadDataProvider(callContext);
                        if (attachmentDataProvider == null)
                        {
                            throw new InvalidOperationException("The user has no default data provider");
                        }
                        UploadItemAsyncResult uploadResult = await attachmentDataProvider.UploadItemAsync(fileContent, fileName, cancellationToken, callContext).ConfigureAwait(false);
                        CreateAttachmentNotificationPayload notificationPayload = new CreateAttachmentNotificationPayload
                        {
                            SubscriptionId = subscriptionId,
                            Id             = operationId.ToString(),
                            Item           = uploadResult.Item,
                            ResultCode     = uploadResult.ResultCode
                        };
                        if (uploadResult.ResultCode == AttachmentResultCode.Success)
                        {
                            notificationPayload.Response = CreateReferenceAttachmentFromAttachmentDataProvider.AttachReferenceAttachment(attachmentDataProvider, userContext, uploadResult.Item.Location, string.Empty, itemId.Id, idConverter, null, uploadResult.Item.ProviderEndpointUrl);
                            attachmentId = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(notificationPayload.Response);
                        }
                        if (!userContext.IsDisposed)
                        {
                            try
                            {
                                userContext.LockAndReconnectMailboxSession();
                                CreateAttachmentHelper.SendPendingGetNotification(userContext, notificationPayload, channelId);
                            }
                            finally
                            {
                                userContext.UnlockAndDisconnectMailboxSession();
                            }
                        }
                    }
                    catch (OperationCanceledException exception)
                    {
                        errorCode = AttachmentResultCode.Cancelled;
                        exception = exception;
                        if (cancellationId != null)
                        {
                            userContext.CancelAttachmentManager.CreateAttachmentCancelled(cancellationId);
                        }
                    }
                });
            }
            catch (GrayException ex)
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "CreateReferenceAttachmentFromLocalFile.UploadAndAttachReferenceAttachment Exception while trying to upload and attach file async : {0}", ex.StackTrace);
                exception = ex;
            }
            finally
            {
                if (cancellationId != null)
                {
                    userContext.CancelAttachmentManager.CreateAttachmentCompleted(cancellationId, attachmentId);
                }
                if (exception != null)
                {
                    CreateAttachmentHelper.SendFailureNotification(userContext, subscriptionId, operationId.ToString(), errorCode, channelId, exception);
                }
            }
        }