// Token: 0x06000583 RID: 1411 RVA: 0x00020AD8 File Offset: 0x0001ECD8
 internal static bool DeviceCanHandleRedirect(IAirSyncContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (context.Request.Version < DeviceCapability.MinDcRedirectVersion)
     {
         AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, null, "Request protocol version {0} is lower than required for redirect {1}; will be proxied.", context.Request.Version, DeviceCapability.MinDcRedirectVersion);
         return(false);
     }
     if (context.Request.CommandType == CommandType.Options || string.IsNullOrEmpty(context.Request.DeviceIdentity.DeviceType))
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "Device Type is not known (OPTIONS command); request must be proxied.");
         return(false);
     }
     foreach (string deviceType in DeviceCapability.RedirectDeviceTypes)
     {
         if (context.Request.DeviceIdentity.IsDeviceType(deviceType))
         {
             AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Request device type {0} can be redirected.", context.Request.DeviceIdentity.DeviceType);
             return(true);
         }
     }
     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "DeviceCapability.DeviceCanHandleRedirect: request will be proxied");
     return(false);
 }
예제 #2
0
        public static ISyncLogger GetSyncLogger()
        {
            IAirSyncContext airSyncContext = (Command.CurrentCommand == null) ? null : Command.CurrentCommand.Context;

            if (airSyncContext != null)
            {
                return(airSyncContext);
            }
            return(TracingLogger.Singleton);
        }
        // Token: 0x06000D92 RID: 3474 RVA: 0x0004AE00 File Offset: 0x00049000
        internal static bool NeedToSendBootstrapMailForWM61(IAirSyncContext airSyncContext, GlobalInfo globalInfo)
        {
            if (airSyncContext == null)
            {
                throw new ArgumentNullException("airSyncContext");
            }
            if (globalInfo == null)
            {
                throw new ArgumentNullException("globalInfo");
            }
            PolicyData policyData = ADNotificationManager.GetPolicyData(airSyncContext.User);

            if (policyData == null || !policyData.AllowMobileOTAUpdate)
            {
                return(false);
            }
            if (airSyncContext.Request.Version != 121)
            {
                return(false);
            }
            if (globalInfo.HaveSentBoostrapMailForWM61)
            {
                return(false);
            }
            if (globalInfo.BootstrapMailForWM61TriggeredTime != null)
            {
                return(false);
            }
            string deviceOS = globalInfo.DeviceOS;

            if (deviceOS == null || !deviceOS.StartsWith("Windows CE", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            try
            {
                Version v = new Version(deviceOS.Substring("Windows CE".Length).Trim());
                if (v < OTABootstrapMail.WM61VersionStartRange || v > OTABootstrapMail.WM61VersionEndRange)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException || ex is ArgumentOutOfRangeException || ex is FormatException || ex is OverflowException)
                {
                    return(false);
                }
                throw ex;
            }
            return(GlobalSettings.BootstrapCABForWM61HostingURL != null && GlobalSettings.MobileUpdateInformationURL != null);
        }
예제 #4
0
        internal static StatusCode GetThumbnailPhotoFromMailbox(IAirSyncContext context, string targetPrimarySmtpAddress, out byte[] thumbnailPhoto)
        {
            thumbnailPhoto = null;
            ClientContext clientContext = ClientContext.Create(context.User.ClientSecurityContextWrapper.ClientSecurityContext, context.User.ExchangePrincipal.MailboxInfo.OrganizationId, null, null, CultureInfo.InvariantCulture, Guid.NewGuid().ToString());

            clientContext.RequestSchemaVersion = ExchangeVersionType.Exchange2012;
            if (!SmtpAddress.IsValidSmtpAddress(targetPrimarySmtpAddress))
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ProtocolTracer, null, "Target SMTP address is not valid: {0}", targetPrimarySmtpAddress);
                return(StatusCode.NoPicture);
            }
            GetUserPhotoQuery getUserPhotoQuery = new GetUserPhotoQuery(clientContext, new PhotoRequest
            {
                Requestor = new PhotoPrincipal
                {
                    EmailAddresses = new string[]
                    {
                        context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()
                    },
                    OrganizationId = context.User.ExchangePrincipal.MailboxInfo.OrganizationId
                },
                Size = UserPhotoSize.HR648x648,
                TargetSmtpAddress = targetPrimarySmtpAddress,
                Trace             = ExTraceGlobals.ProtocolTracer.IsTraceEnabled(TraceType.DebugTrace),
                HostOwnedTargetMailboxSessionGetter = new Func <ExchangePrincipal, IMailboxSession>(AirSyncPhotoRetriever.GetCachedMailboxSessionForPhotoRequest)
            }, null, false, AirSyncPhotoRetriever.PhotosConfiguration, ExTraceGlobals.ProtocolTracer);
            StatusCode result;

            try
            {
                thumbnailPhoto = getUserPhotoQuery.Execute();
                if (thumbnailPhoto == null || thumbnailPhoto.Length == 0)
                {
                    AirSyncDiagnostics.TraceError(ExTraceGlobals.ProtocolTracer, "Unable to retrieve thumbnailPhoto via GetUserPhoto for {0}", targetPrimarySmtpAddress);
                    result = StatusCode.NoPicture;
                }
                else
                {
                    result = StatusCode.Success;
                }
            }
            catch (AccessDeniedException arg)
            {
                AirSyncDiagnostics.TraceError <AccessDeniedException>(ExTraceGlobals.ProtocolTracer, "Access denied retrieving thumbnailPhoto via GetUserPhoto for {0}.  Exception: {1}", targetPrimarySmtpAddress, arg);
                result = StatusCode.NoPicture;
            }
            return(result);
        }
 // Token: 0x06000584 RID: 1412 RVA: 0x00020BC0 File Offset: 0x0001EDC0
 internal static bool IsDirectPushAllowed(IAirSyncContext context, out bool directPushAllowedByGeo)
 {
     directPushAllowedByGeo = true;
     if (GlobalSettings.AllowDirectPush == GlobalSettings.DirectPushEnabled.On)
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "DeviceCapability.IsDirectPushAllowed: ON by registry key");
         return(true);
     }
     if (GlobalSettings.AllowDirectPush == GlobalSettings.DirectPushEnabled.OnWithAddressCheck)
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "DeviceCapability.IsDirectPushAllowed: ONWithAddressCheck registry key and no geolocation logic");
         return(true);
     }
     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "DeviceCapability.IsDirectPushAllowed: OFF by registry key");
     return(false);
 }
예제 #6
0
 public ABQMailHelper(IGlobalInfo globalInfo, IAirSyncContext context, IOrganizationSettingsData organizationSettings)
 {
     if (globalInfo == null)
     {
         throw new ArgumentNullException("globalInfo");
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (organizationSettings == null)
     {
         throw new ArgumentNullException("organizationSettings");
     }
     this.globalInfo           = globalInfo;
     this.context              = context;
     this.organizationSettings = organizationSettings;
 }
 public static void Start(IAirSyncContext context)
 {
     lock (ADNotificationManager.startLock)
     {
         if (!ADNotificationManager.started)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "ADNotificationManager is being started ...");
             ADNotificationManager.topoSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 189, "Start", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADNotificationManager.cs");
             ADNotificationManager.LoadAutoBlockThresholds();
             ADNotificationManager.started = true;
             context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, ADNotificationManager.topoSession.LastUsedDc);
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "ADNotificationManager is started.");
             int expireTimeInMinutes = (GlobalSettings.ADCacheExpirationTimeout.TotalMinutes < 1.0) ? 1 : ((int)GlobalSettings.ADCacheExpirationTimeout.TotalMinutes);
             ADNotificationManager.policies = new MruDictionaryCache <string, ADNotificationManager.ADSettingsInfo <PolicyData> >(GlobalSettings.ADCacheMaxOrgCount, GlobalSettings.ADCacheMaxOrgCount, expireTimeInMinutes);
             ADNotificationManager.organizationSettingsCache = new MruDictionaryCache <string, ADNotificationManager.ADSettingsInfo <IOrganizationSettingsData> >(GlobalSettings.ADCacheMaxOrgCount, GlobalSettings.ADCacheMaxOrgCount, expireTimeInMinutes);
             ADNotificationManager.vDirSettingsCache         = new ADObjIdToVDirMap();
         }
     }
 }
예제 #8
0
        // Token: 0x060002D9 RID: 729 RVA: 0x0000F458 File Offset: 0x0000D658
        internal AirSyncUser(IAirSyncContext context)
        {
            this.context = context;
            bool flag  = false;
            bool flag2 = true;

            try
            {
                if (this.context.Request.WasFromCafe)
                {
                    this.InitializeFromRehydratedIdentity();
                }
                else if (this.context.Request.WasProxied)
                {
                    flag2 = false;
                    this.InitializeFromClientSecurityContext();
                }
                else
                {
                    this.InitializeFromLoggedOnIdentity();
                }
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    ((IAirSyncUser)this).DisposeBudget();
                    if (flag2 && this.clientSecurityContextWrapper != null)
                    {
                        this.clientSecurityContextWrapper.Dispose();
                        this.clientSecurityContextWrapper = null;
                    }
                }
            }
        }
예제 #9
0
 internal AirSyncPhotoRetriever(IAirSyncContext context)
 {
     this.Context = context;
 }
        public QueryFilter ParseTopLevelClassAndFolders(XmlNode queryNode, bool contentIndexingEnabled, IAirSyncVersionFactory versionFactory, IAirSyncContext context)
        {
            this.Clear();
            if (queryNode.ChildNodes.Count != 1)
            {
                throw new SearchFilterTooComplexException
                      {
                          ErrorStringForProtocolLogger = "SearchTooComplexError1"
                      };
            }
            XmlNode xmlNode = queryNode.ChildNodes[0];

            if ("Search:" != xmlNode.NamespaceURI || "And" != xmlNode.Name)
            {
                throw new SearchFilterTooComplexException
                      {
                          ErrorStringForProtocolLogger = "SearchTooComplexError1"
                      };
            }
            List <string>  list  = new List <string>();
            List <string>  list2 = new List <string>();
            List <XmlNode> list3 = new List <XmlNode>();

            this.contentIndexingEnabled = contentIndexingEnabled;
            foreach (object obj in xmlNode.ChildNodes)
            {
                XmlNode xmlNode2 = (XmlNode)obj;
                if ("AirSync:" == xmlNode2.NamespaceURI && "CollectionId" == xmlNode2.Name)
                {
                    if (xmlNode2.ChildNodes.Count != 1 || xmlNode2.FirstChild.NodeType != XmlNodeType.Text)
                    {
                        throw new SearchProtocolErrorException
                              {
                                  ErrorStringForProtocolLogger = "SearchProtocolError1"
                              };
                    }
                    list2.Add(xmlNode2.InnerText);
                }
                else if ("AirSync:" == xmlNode2.NamespaceURI && "Class" == xmlNode2.Name)
                {
                    if (xmlNode2.ChildNodes.Count != 1 || xmlNode2.FirstChild.NodeType != XmlNodeType.Text)
                    {
                        throw new SearchProtocolErrorException
                              {
                                  ErrorStringForProtocolLogger = "SearchProtocolError2"
                              };
                    }
                    list.Add(xmlNode2.InnerText);
                }
                else
                {
                    list3.Add(xmlNode2);
                }
            }
            if (list3.Count < 1)
            {
                throw new SearchProtocolErrorException
                      {
                          ErrorStringForProtocolLogger = "SearchProtocolError3"
                      };
            }
            this.folderScope    = list2;
            this.airSyncClasses = list;
            this.schemaCache    = new Dictionary <string, MailboxSearchCriteriaBuilder.SchemaCacheItem>();
            List <QueryFilter> list4 = new List <QueryFilter>();

            new List <QueryFilter>();
            if (list.Count == 0)
            {
                list.Add("Email");
                list.Add("Calendar");
                list.Add("Contacts");
                list.Add("Tasks");
                if (context.Request.Version >= 140)
                {
                    list.Add("Notes");
                    list.Add("SMS");
                }
            }
            foreach (string text in list)
            {
                string key;
                switch (key = text)
                {
                case "Email":
                    this.schemaCache["Email"] = new MailboxSearchCriteriaBuilder.SchemaCacheItem(versionFactory.CreateEmailSchema(null), versionFactory.CreateMissingPropertyStrategy(null));
                    continue;

                case "Calendar":
                    this.schemaCache["Calendar"] = new MailboxSearchCriteriaBuilder.SchemaCacheItem(versionFactory.CreateCalendarSchema(), versionFactory.CreateMissingPropertyStrategy(null));
                    continue;

                case "Contacts":
                    this.schemaCache["Contacts"] = new MailboxSearchCriteriaBuilder.SchemaCacheItem(versionFactory.CreateContactsSchema(), versionFactory.CreateMissingPropertyStrategy(null));
                    continue;

                case "Tasks":
                    this.schemaCache["Tasks"] = new MailboxSearchCriteriaBuilder.SchemaCacheItem(versionFactory.CreateTasksSchema(), versionFactory.CreateMissingPropertyStrategy(null));
                    continue;

                case "Notes":
                    if (context.Request.Version < 140)
                    {
                        throw new SearchProtocolErrorException
                              {
                                  ErrorStringForProtocolLogger = "SearchProtocolError4"
                              };
                    }
                    this.schemaCache["Notes"] = new MailboxSearchCriteriaBuilder.SchemaCacheItem(versionFactory.CreateNotesSchema(), versionFactory.CreateMissingPropertyStrategy(null));
                    continue;

                case "SMS":
                    if (context.Request.Version < 140)
                    {
                        throw new SearchProtocolErrorException
                              {
                                  ErrorStringForProtocolLogger = "SearchProtocolError5"
                              };
                    }
                    this.schemaCache["SMS"] = new MailboxSearchCriteriaBuilder.SchemaCacheItem(versionFactory.CreateSmsSchema(), versionFactory.CreateMissingPropertyStrategy(null));
                    continue;
                }
                throw new SearchProtocolErrorException
                      {
                          ErrorStringForProtocolLogger = "SearchProtocolError6"
                      };
            }
            foreach (XmlNode node in list3)
            {
                QueryFilter queryFilter = this.ParseSearchNamespace(node);
                if (queryFilter == null)
                {
                    return(null);
                }
                list4.Add(queryFilter);
            }
            return(MailboxSearchCriteriaBuilder.ConstructAndOrOperator(list4, "And"));
        }
예제 #11
0
 internal AirSyncRequest(IAirSyncContext context, HttpRequest httpRequest)
 {
     this.context     = context;
     this.httpRequest = httpRequest;
 }
예제 #12
0
 // Token: 0x0600026B RID: 619 RVA: 0x0000E1AA File Offset: 0x0000C3AA
 internal AirSyncResponse(IAirSyncContext context, HttpResponse httpResponse)
 {
     this.context      = context;
     this.httpResponse = httpResponse;
     ((IAirSyncResponse)this).TimeToRespond = ExDateTime.UtcNow;
 }
 // Token: 0x060000AC RID: 172 RVA: 0x00006E8C File Offset: 0x0000508C
 internal ADDeviceManager(IAirSyncContext context) : this(context.DeviceIdentity, MobileClientType.EAS, context.User.OrganizationId, context.User.Name, context.User.ExchangePrincipal.ObjectId, context.User.ADUser, context.ProtocolLogger, context.User.Budget, ExTraceGlobals.RequestsTracer, AirSyncEventLogConstants.Tuple_UnableToCreateADDevice, AirSyncEventLogConstants.Tuple_DirectoryAccessDenied)
 {
 }
        public static IOrganizationSettingsData GetOrganizationSettingsData(OrganizationId organizationId, IAirSyncContext context)
        {
            if (organizationId == null)
            {
                throw new ArgumentException("OrganizationId is null");
            }
            if (!ADNotificationManager.started)
            {
                throw new InvalidOperationException("ADNotificationManager should be started first!");
            }
            IConfigurationSession scopedSession     = null;
            ADObjectId            configurationUnit = organizationId.ConfigurationUnit;

            if (configurationUnit == null)
            {
                if (ADNotificationManager.enterpriseConfigurationID == null)
                {
                    scopedSession = ADNotificationManager.CreateScopedADSession(organizationId, ConsistencyMode.IgnoreInvalid);
                    ADNotificationManager.enterpriseConfigurationID = scopedSession.GetOrgContainerId();
                    if (context != null)
                    {
                        context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc);
                    }
                }
                configurationUnit = ADNotificationManager.enterpriseConfigurationID;
            }
            ADNotificationManager.ADSettingsInfo <IOrganizationSettingsData> adsettingsInfo = null;
            AirSyncDiagnostics.TraceDebug <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "Loaded ConfigurationUnit {0}", configurationUnit);
            Func <IOrganizationSettingsData> loadDataAction = () => ADNotificationManager.LoadOrganizationSettings(scopedSession ?? ADNotificationManager.CreateScopedADSession(organizationId, ConsistencyMode.PartiallyConsistent), context);

            ADNotificationManager.LoadADSettingsData <IOrganizationSettingsData>(ADNotificationManager.organizationSettingsCache, configurationUnit.DistinguishedName, loadDataAction, organizationId.PartitionId, out adsettingsInfo);
            return(adsettingsInfo.ADSettingsData);
        }
        private static IOrganizationSettingsData LoadOrganizationSettings(IConfigurationSession scopedSession, IAirSyncContext context)
        {
            ADObjectId organizationId = scopedSession.GetOrgContainerId();
            ActiveSyncOrganizationSettings organizationSettings = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                organizationSettings = scopedSession.Read <ActiveSyncOrganizationSettings>(organizationId.GetDescendantId(new ADObjectId("CN=Mobile Mailbox Settings")));
            });

            if (!adoperationResult.Succeeded)
            {
                AirSyncDiagnostics.TraceDebug <ADObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during LoadOrganizationSettings {0}. Exception Message- {1}", organizationId, adoperationResult.Exception.Message);
            }
            ValidationError[] array = organizationSettings.Validate();
            bool flag = false;

            if (array != null)
            {
                foreach (ValidationError validationError in array)
                {
                    if (string.Equals(validationError.PropertyName, "ConfigurationXMLRaw", StringComparison.OrdinalIgnoreCase))
                    {
                        flag = true;
                    }
                }
            }
            if (flag)
            {
                organizationSettings.DeviceFiltering = null;
            }
            ADRawEntry adrawEntry = scopedSession.ReadADRawEntry(organizationId, new PropertyDefinition[]
            {
                OrganizationSchema.IntuneManagedStatus
            });

            organizationSettings.IsIntuneManaged = (adrawEntry != null && (bool)adrawEntry[OrganizationSchema.IntuneManagedStatus]);
            AirSyncDiagnostics.TraceInfo <bool>(ExTraceGlobals.RequestsTracer, null, "LoadOrganizationSettings from AD.IntuneManagedStatus {0}.", organizationSettings.IsIntuneManaged);
            if (context != null)
            {
                context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc);
            }
            if (organizationSettings != null)
            {
                AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, null, "LoadOrganizationSettings from AD. Found {0} OrganizationSettings.", 1);
                return(ADNotificationManager.AddOrganizationSettingsToCache(organizationSettings, scopedSession));
            }
            AirSyncDiagnostics.TraceError <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "Cannot find ActiveSyncOrganizationSettings object in AD for organization {0}", organizationId);
            return(null);
        }
예제 #16
0
 internal MailboxSearchProvider(MailboxSession mailboxSession, SyncStateStorage syncStateStorage, IAirSyncContext context)
 {
     if (context.Request.Version < 120)
     {
         throw new SearchProtocolErrorException
               {
                   ErrorStringForProtocolLogger = "SearchProtocolError10"
               };
     }
     this.mailboxSession   = mailboxSession;
     this.syncStateStorage = syncStateStorage;
     this.context          = context;
     this.versionFactory   = AirSyncProtocolVersionParserBuilder.FromVersion(context.Request.Version);
     AirSyncCounters.NumberOfMailboxSearches.Increment();
 }