Exemple #1
0
 // Token: 0x0600036D RID: 877 RVA: 0x00013CC0 File Offset: 0x00011EC0
 private ABSession GetAddressBookSession()
 {
     if (this.addressBookSession == null)
     {
         IABSessionSettings sessionSettings = ABDiscoveryManager.GetSessionSettings(this.user.ExchangePrincipal, new int?(this.lcid), new ConsistencyMode?(ConsistencyMode.IgnoreInvalid), GlobalSettings.SyncLog, this.user.ClientSecurityContextWrapper.ClientSecurityContext);
         this.addressBookSession = ADABSession.Create(sessionSettings);
     }
     return(this.addressBookSession);
 }
Exemple #2
0
        private static string GetProviderName(IABSessionSettings addressBookSessionSettings)
        {
            string text = addressBookSessionSettings.Get <string>("Provider");

            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException("addressBookSessionSettings[Provider]");
            }
            return(text);
        }
Exemple #3
0
        private static void ThrowIfDisabled(IABSessionSettings addressBookSessionSettings)
        {
            bool flag;

            if (addressBookSessionSettings.TryGet <bool>("Disabled", out flag) && flag)
            {
                Guid guid = addressBookSessionSettings.Get <Guid>("SubscriptionGuid");
                throw new ABSubscriptionDisabledException(DirectoryStrings.SessionSubscriptionDisabled(guid));
            }
        }
Exemple #4
0
        internal static ABProviderCapabilities GetProviderCapabilities(IABSessionSettings addressBookSessionSettings)
        {
            if (addressBookSessionSettings == null)
            {
                throw new ArgumentNullException("addressBookSessionSettings");
            }
            string providerName = ABFactory.GetProviderName(addressBookSessionSettings);

            ExTraceGlobals.FrameworkTracer.TraceDebug <string>(0L, "Getting provider capabilities for provider '{0}'.", providerName);
            IABProviderFactory providerFactory = ABFactory.GetProviderFactory(providerName);

            return(providerFactory.GetProviderCapabilities(addressBookSessionSettings));
        }
Exemple #5
0
        internal static ABSession CreateABSession(IABSessionSettings addressBookSessionSettings)
        {
            if (addressBookSessionSettings == null)
            {
                throw new ArgumentNullException("addressBookSessionSettings");
            }
            string providerName = ABFactory.GetProviderName(addressBookSessionSettings);

            ExTraceGlobals.FrameworkTracer.TraceDebug <string>(0L, "Creating session for provider '{0}'.", providerName);
            ABFactory.ThrowIfDisabled(addressBookSessionSettings);
            IABProviderFactory providerFactory = ABFactory.GetProviderFactory(providerName);

            return(providerFactory.Create(addressBookSessionSettings));
        }
Exemple #6
0
        public static ABSession Create(IABSessionSettings sessionSettings)
        {
            if (sessionSettings == null)
            {
                throw new ArgumentNullException("sessionSettings");
            }
            ADABSession adabsession = null;
            bool        flag        = false;

            try
            {
                adabsession = new ADABSession(sessionSettings.Get <OrganizationId>("OrganizationId"), sessionSettings.Get <ADObjectId>("SearchRoot"), sessionSettings.Get <int>("Lcid"), sessionSettings.Get <ConsistencyMode>("ConsistencyMode"), sessionSettings.Get <ClientSecurityContext>("ClientSecurityContext"));
                flag        = true;
            }
            finally
            {
                if (!flag && adabsession != null)
                {
                    adabsession.Dispose();
                    adabsession = null;
                }
            }
            return(adabsession);
        }
        public void Execute()
        {
            Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.SearchQueryLength, this.searchQuery.Length);
            if (this.user.IsConsumerOrganizationUser)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch command not supported for consumer users");
                return;
            }
            if (this.minRange >= GlobalSettings.MaxGALSearchResults)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch command min range specified is outside our configured maximum. No results will be returned");
                return;
            }
            UnicodeCategory unicodeCategory = char.GetUnicodeCategory(this.searchQuery, 0);

            if (this.searchQuery.Length < GlobalSettings.MinGALSearchLength && unicodeCategory != UnicodeCategory.OtherLetter)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "GalSearch search string is shorter than MinGALSearchLength. No results will be returned");
                Command.CurrentCommand.ProtocolLogger.SetValueIfNotSet(ProtocolLoggerData.Error, "SearchStringTooShort");
                return;
            }
            OperationRetryManagerResult operationRetryManagerResult = GalSearchProvider.retryManager.TryRun(delegate
            {
                IABSessionSettings sessionSettings = ABDiscoveryManager.GetSessionSettings(this.user.ExchangePrincipal, new int?(this.lcid), null, GlobalSettings.SyncLog, this.user.ClientSecurityContextWrapper.ClientSecurityContext);
                using (ABSession absession = ADABSession.Create(sessionSettings))
                {
                    this.addressBookObjects = absession.FindByANR(this.searchQuery, GlobalSettings.MaxGALSearchResults);
                }
            });

            if (operationRetryManagerResult.Succeeded)
            {
                if (this.pictureOptions != null && this.user.Features.IsEnabled(EasFeature.HDPhotos) && this.user.Context.Request.Version >= 160)
                {
                    this.photoRetriever = new AirSyncPhotoRetriever(this.user.Context);
                    List <string> list = new List <string>();
                    int           num  = this.minRange;
                    while (this.addressBookObjects != null && num <= this.maxRange && num < this.addressBookObjects.Count)
                    {
                        ABObject abobject = this.addressBookObjects[num];
                        if (abobject == null)
                        {
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ABSession.FindByAnr returned null  addresBookObject. Continue.");
                        }
                        else
                        {
                            ABContact abcontact = abobject as ABContact;
                            if (abcontact == null)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ABSession.FindByAnr returned object that is not a \"ABContact\". Continue.");
                            }
                            else
                            {
                                list.Add(abcontact.EmailAddress);
                            }
                        }
                        num++;
                    }
                    this.photoRetriever.BeginGetThumbnailPhotoFromMailbox(list, this.pictureOptions.PhotoSize);
                }
                return;
            }
            if (operationRetryManagerResult.Exception is ABSubscriptionDisabledException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "ABSubsDisabled"
                      };
            }
            if (operationRetryManagerResult.Exception is DataValidationException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "BadADDataInGalSearch"
                      };
            }
            if (operationRetryManagerResult.Exception is DataSourceOperationException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, operationRetryManagerResult.Exception, false)
                      {
                          ErrorStringForProtocolLogger = "BadADDataSource"
                      };
            }
            if (operationRetryManagerResult.Exception != null)
            {
                throw operationRetryManagerResult.Exception;
            }
            throw new InvalidOperationException("GalSearch failed with result code: " + operationRetryManagerResult.ResultCode);
        }