Ejemplo n.º 1
0
        internal static MobileDevicePolicyData GetMobileDevicePolicyDataFromAD(IConfigurationSession session, ADObjectId mobileMailboxPolicyId)
        {
            ExTraceGlobals.MobileDevicePolicyTracer.TraceDebug <ADObjectId>(0L, "Looking up mobile device policy object in AD: '{0}'", mobileMailboxPolicyId);
            MobileMailboxPolicy mobileMailboxPolicy = session.Read <MobileMailboxPolicy>(mobileMailboxPolicyId);

            return(MobileDevicePolicyDataFactory.GetMobileDevicePolicyDataFromMobileMailboxPolicy(mobileMailboxPolicy));
        }
Ejemplo n.º 2
0
        public static void CheckMobileDevicePolicyIsCorrect(string methodName, CallContext callContext)
        {
            if (!callContext.IsMowa)
            {
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.MobileDevicePolicyTracer.TraceDebug(0L, "[OWAMessageInspector::CheckMobileDevicePolicyIsCorrect] Request is not coming from a MOWA session. Skipping policy check.");
                return;
            }
            if (string.IsNullOrEmpty(callContext.MobileDevicePolicyId))
            {
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.MobileDevicePolicyTracer.TraceDebug(0L, "[OWAMessageInspector::CheckMobileDevicePolicyIsCorrect] Client isn't passing policy information (old client). Skipping policy check.");
                return;
            }
            if (methodName.Equals("GetOwaUserConfiguration", StringComparison.OrdinalIgnoreCase))
            {
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.MobileDevicePolicyTracer.TraceDebug(0L, "[OWAMessageInspector::CheckMobileDevicePolicyIsCorrect] Executing GetOwaUserConfiguration method. Skipping policy check.");
                callContext.UpdateLastPolicyTime();
                return;
            }
            if (methodName.Equals("PingOwa", StringComparison.OrdinalIgnoreCase))
            {
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.MobileDevicePolicyTracer.TraceDebug(0L, "[OWAMessageInspector::CheckMobileDevicePolicyIsCorrect] Executing PingOwa method. Skipping policy check.");
                return;
            }
            ADObjectId             policy     = null;
            MobileDevicePolicyData policyData = MobileDevicePolicyDataFactory.GetPolicyData(callContext.AccessingPrincipal, out policy);

            callContext.UpdatePolicyApplied(policy);
            string mobileDevicePolicyId = callContext.MobileDevicePolicyId;

            if (policyData != null && !string.Equals(policyData.PolicyIdentifier, mobileDevicePolicyId, StringComparison.Ordinal))
            {
                callContext.MarkDeviceAsBlockedByPolicy();
                string effectiveAccessingSmtpAddress = callContext.GetEffectiveAccessingSmtpAddress();
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.MobileDevicePolicyTracer.TraceWarning(0L, "[OWAMessageInspector::CheckMobileDevicePolicyIsCorrect] Policy Identifier does not match expected value. Expected: '{0}'. Actual: '{1}'. Method: '{2}'. User: '******'.", new object[]
                {
                    policyData.PolicyIdentifier,
                    mobileDevicePolicyId,
                    methodName,
                    effectiveAccessingSmtpAddress
                });
                throw new OwaInvalidMobileDevicePolicyException(string.Format("The presented mobile device policy id '{0}' is not valid. Method '{1}' is being rejected.", mobileDevicePolicyId, methodName), effectiveAccessingSmtpAddress, policyData.PolicyIdentifier);
            }
            callContext.MarkDeviceAsAllowed();
        }
        private MobileDevicePolicyData GetPolicyFromAD(OrgIdADObjectWrapper key)
        {
            ExTraceGlobals.MobileDevicePolicyTracer.Information <OrgIdADObjectWrapper>(0L, "MobileDevicePolicyCache.GetPolicyFromAD({0})", key);
            ADSessionSettings      settings   = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(key.OrgId);
            IConfigurationSession  session    = this.GetConfigSession(settings);
            MobileDevicePolicyData policyData = null;

            try
            {
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    policyData = MobileDevicePolicyDataFactory.GetMobileDevicePolicyDataFromAD(session, key.AdObject);
                });
            }
            catch (LocalizedException arg)
            {
                ExTraceGlobals.MobileDevicePolicyTracer.TraceError <OrgIdADObjectWrapper, LocalizedException>((long)this.GetHashCode(), "MobileDevicePolicyCache.GetPolicyFromAD({0}) threw exception: {1}", key, arg);
                throw;
            }
            ExTraceGlobals.MobileDevicePolicyTracer.Information <OrgIdADObjectWrapper, MobileDevicePolicyData>((long)this.GetHashCode(), "MobileDevicePolicyCache.GetPolicyFromAD({0}) returned: {1}", key, policyData);
            return(policyData);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 private MobileDevicePolicyData ReadAggregatedMobileDevicePolicyData(UserConfigurationManager.IAggregationContext ctx, ExchangePrincipal principal)
 {
     return(UserContextUtilities.ReadAggregatedType <MobileDevicePolicyData>(ctx, "OWA.MobileDevicePolicy", () => MobileDevicePolicyDataFactory.GetPolicyData(principal)));
 }
        private ADObjectId GetPolicyIdFromAD(OrganizationId key)
        {
            ExTraceGlobals.MobileDevicePolicyTracer.Information <OrganizationId>((long)this.GetHashCode(), "MobileDevicePolicyIdCacheByOrganization.GetPolicyFromAD({0})", key);
            ADSessionSettings     settings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(key);
            IConfigurationSession session  = this.GetConfigSession(settings);
            ADObjectId            rootId   = session.GetOrgContainerId();
            QueryFilter           filter   = new BitMaskAndFilter(MobileMailboxPolicySchema.MobileFlags, 4096UL);
            SortBy     sortBy   = new SortBy(ADObjectSchema.WhenChanged, SortOrder.Descending);
            ADObjectId policyId = null;

            try
            {
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    MobileMailboxPolicy[] array = session.Find <MobileMailboxPolicy>(rootId, QueryScope.SubTree, filter, sortBy, 1);
                    if (array != null && array.Length > 0)
                    {
                        policyId = array[0].Id;
                        OrgIdADObjectWrapper key2 = new OrgIdADObjectWrapper(policyId, key);
                        if (!MobileDevicePolicyCache.Instance.Contains(key2))
                        {
                            MobileDevicePolicyData mobileDevicePolicyDataFromMobileMailboxPolicy = MobileDevicePolicyDataFactory.GetMobileDevicePolicyDataFromMobileMailboxPolicy(array[0]);
                            MobileDevicePolicyCache.Instance.TryAdd(key2, ref mobileDevicePolicyDataFromMobileMailboxPolicy);
                        }
                    }
                });
            }
            catch (LocalizedException arg)
            {
                ExTraceGlobals.MobileDevicePolicyTracer.TraceError <OrganizationId, LocalizedException>((long)this.GetHashCode(), "MobileDevicePolicyIdCacheByOrganization.GetPolicyIdFromAD({0}) threw exception: {1}", key, arg);
                throw;
            }
            ExTraceGlobals.MobileDevicePolicyTracer.Information <OrganizationId, ADObjectId>((long)this.GetHashCode(), "MobileDevicePolicyIdCacheByOrganization.GetPolicyFromAD({0}) returned: {1}", key, policyId);
            return(policyId);
        }
Ejemplo n.º 7
0
        internal static MobileDevicePolicyData GetPolicyData(ExchangePrincipal principal)
        {
            ADObjectId adobjectId = null;

            return(MobileDevicePolicyDataFactory.GetPolicyData(principal, out adobjectId));
        }
Ejemplo n.º 8
0
        internal static MobileDevicePolicySettingsType GetPolicySettings(ExchangePrincipal principal)
        {
            MobileDevicePolicyData policyData = MobileDevicePolicyDataFactory.GetPolicyData(principal);

            return(MobileDevicePolicyDataFactory.GetPolicySettings(policyData));
        }