コード例 #1
0
        internal static void DeleteAttachments(IItem parentItem, List <string> fileReferences)
        {
            AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, null, "AttachmentHelper:DeleteAttachments. Try to delete attachment. delete Count:{0}, Actual AttachmentCount:{1}", fileReferences.Count, parentItem.IAttachmentCollection.Count);
            if (parentItem.IAttachmentCollection.Count < fileReferences.Count)
            {
                throw new ConversionException(string.Format("Invalid number of attachments to delete:{0}. Actual Attachment Count:{1}", fileReferences.Count, parentItem.IAttachmentCollection.Count));
            }
            List <int> list = new List <int>();

            foreach (string text in fileReferences)
            {
                string text2 = text.Substring(text.LastIndexOf(':') + 1);
                int    num;
                if ("DRMLicense".Equals(text2, StringComparison.OrdinalIgnoreCase) || !int.TryParse(text2, out num) || num < 0)
                {
                    throw new ConversionException(string.Format("Invalid attachmentId {0} for delete. AttachmentCount:{1}", text2, parentItem.IAttachmentCollection.Count));
                }
                if (num >= parentItem.IAttachmentCollection.Count)
                {
                    throw new ConversionException(string.Format("Invalid attachmentId {0} for delete. AttachmentCount:{1}", text, parentItem.IAttachmentCollection.Count));
                }
                AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, null, "AttachmentHelper:DeleteAttachments. DeleteAttachment with Index {0}.", num);
                list.Add(num);
            }
            foreach (int index in from x in list
                     orderby x descending
                     select x)
            {
                parentItem.IAttachmentCollection.Remove(parentItem.IAttachmentCollection.GetHandles()[index]);
            }
        }
コード例 #2
0
 private static void CopyCommonAttachmentProperties(IAttachment attachment, Attachment16Data attachmentData)
 {
     if (!string.IsNullOrEmpty(attachmentData.DisplayName))
     {
         attachment.FileName = attachmentData.DisplayName;
         if (!string.IsNullOrEmpty(attachmentData.ContentType))
         {
             attachment.ContentType = attachmentData.ContentType;
         }
         attachment.IsInline = attachmentData.IsInline;
         if (!string.IsNullOrEmpty(attachmentData.ContentId))
         {
             attachment[AttachmentSchema.AttachContentId] = attachmentData.ContentId;
         }
         if (!string.IsNullOrEmpty(attachmentData.ContentLocation))
         {
             attachment[AttachmentSchema.AttachContentLocation] = attachmentData.ContentLocation;
         }
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "Attachment Properties copied:FileName: {0}, ContentType:{1}, IsInline:{2}, ContentId:{3}, ContentLocation:{4}", new object[]
         {
             attachmentData.DisplayName,
             attachmentData.ContentType,
             attachmentData.IsInline,
             attachmentData.ContentId,
             attachmentData.ContentLocation
         });
         return;
     }
     throw new ConversionException(" Attachment DisplayName can not be null.");
 }
コード例 #3
0
        // Token: 0x060000BB RID: 187 RVA: 0x0000858C File Offset: 0x0000678C
        private void SetActiveSyncDeviceContainerPermissions(ActiveSyncDevices container)
        {
            ADDeviceManager.ReadStaticADData(this.protocolLogger);
            RawSecurityDescriptor rawSecurityDescriptor = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                rawSecurityDescriptor = this.session.ReadSecurityDescriptor(container.Id);
            });
            if (rawSecurityDescriptor == null)
            {
                if (this.protocolLogger != null)
                {
                    this.protocolLogger.SetValue(ProtocolLoggerData.Error, "ADObjectWithNoSecurityDescriptor");
                }
                AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, EASServerStrings.NullNTSD(container.Id.DistinguishedName), true);
                throw ex;
            }
            AirSyncDiagnostics.TraceDebug <string>(this.tracer, this, "Setting ACL on device container for user \"{0}\".", this.userName);
            ActiveDirectorySecurity acl = new ActiveDirectorySecurity();

            byte[] array = new byte[rawSecurityDescriptor.BinaryLength];
            rawSecurityDescriptor.GetBinaryForm(array, 0);
            acl.SetSecurityDescriptorBinaryForm(array);
            acl.AddAccessRule(new ActiveDirectoryAccessRule(ADDeviceManager.exchangeServersGroupSid, ActiveDirectoryRights.CreateChild | ActiveDirectoryRights.DeleteChild | ActiveDirectoryRights.ListChildren | ActiveDirectoryRights.ReadProperty | ActiveDirectoryRights.WriteProperty | ActiveDirectoryRights.ListObject, AccessControlType.Allow, ADDeviceManager.activeSyncDeviceClass, ActiveDirectorySecurityInheritance.None));
            acl.AddAccessRule(new ActiveDirectoryAccessRule(ADDeviceManager.exchangeServersGroupSid, ActiveDirectoryRights.Delete | ActiveDirectoryRights.ReadProperty | ActiveDirectoryRights.WriteProperty | ActiveDirectoryRights.ListObject, AccessControlType.Allow, ActiveDirectorySecurityInheritance.Children, ADDeviceManager.activeSyncDeviceClass));
            ADNotificationAdapter.RunADOperation(delegate()
            {
                this.session.SaveSecurityDescriptor(container, new RawSecurityDescriptor(acl.GetSecurityDescriptorBinaryForm(), 0));
            });
        }
コード例 #4
0
        internal static string GetAttachment(MailboxSession mailboxSession, string attachmentId, Stream outStream, int offset, int count, Unlimited <ByteQuantifiedSize> maxAttachmentSize, ItemIdMapping idmapping, bool rightsManagementSupport, out int total)
        {
            string[] array = attachmentId.Split(new char[]
            {
                ':'
            });
            if (array.Length != 2 && array.Length != 3)
            {
                return(AttachmentHelper.GetAttachmentByUrlCompName(mailboxSession, attachmentId, outStream, offset, count, maxAttachmentSize, out total));
            }
            StoreObjectId itemId;
            string        text;

            if (array.Length == 2)
            {
                itemId = AttachmentHelper.GetItemId(array[0]);
                text   = array[1];
            }
            else
            {
                itemId = AttachmentHelper.GetItemId(idmapping, array[0], array[1]);
                text   = array[2];
            }
            if (itemId == null)
            {
                throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentId));
            }
            AirSyncDiagnostics.TraceDebug <StoreObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Getting attachment with itemId {0} and attachmentIndex {1}.", itemId, text);
            return(AttachmentHelper.GetAttachment(mailboxSession, itemId, text, outStream, offset, count, maxAttachmentSize, rightsManagementSupport, out total));
        }
コード例 #5
0
        // Token: 0x0600156B RID: 5483 RVA: 0x0007E290 File Offset: 0x0007C490
        private Participant ResolveUnresolvedParticipant(Participant participant)
        {
            Participant result;

            if (participant.RoutingType == null && participant.DisplayName != null && participant.EmailAddress == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "DefaultDomain = '{0}', OriginalDisplayName = '{1}', NewEmailAddress = '{2}{3}'", new object[]
                {
                    SendMailBase.DefaultDomain,
                    participant.DisplayName,
                    participant.DisplayName,
                    SendMailBase.DefaultDomain
                });
                result = Participant.Parse(participant.DisplayName + SendMailBase.DefaultDomain);
            }
            else
            {
                if (!(participant.RoutingType == "SMTP") || participant.EmailAddress == null || participant.EmailAddress.IndexOf('@') != -1)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CouldNotResolveAllRecipients");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MessageRecipientUnresolved, null, false);
                }
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "DefaultDomain = '{0}', OriginalEmailAddress = '{1}', NewEmailAddress = '{2}{3}'", new object[]
                {
                    SendMailBase.DefaultDomain,
                    participant.EmailAddress,
                    participant.EmailAddress,
                    SendMailBase.DefaultDomain
                });
                result = new Participant(participant.DisplayName, participant.EmailAddress + SendMailBase.DefaultDomain, participant.RoutingType);
            }
            return(result);
        }
コード例 #6
0
        // Token: 0x060000BA RID: 186 RVA: 0x0000843C File Offset: 0x0000663C
        private bool CleanUpMangledDevices(List <MobileDevice> mobileDevices, out int noOfDevicesRemoved)
        {
            noOfDevicesRemoved = 0;
            ExDateTime utcNow = ExDateTime.UtcNow;

            for (int i = mobileDevices.Count - 1; i >= 0; i--)
            {
                MobileDevice device = mobileDevices[i];
                if (ADDeviceManager.DnIsMangled(device.Name) || ADDeviceManager.DnIsMangled(device.DeviceId))
                {
                    ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                    {
                        this.session.Delete(device);
                    });
                    if (!adoperationResult.Succeeded)
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during . Message:{0}", adoperationResult.Exception.Message);
                    }
                    noOfDevicesRemoved++;
                    mobileDevices.RemoveAt(i);
                }
                TimeSpan t = ExDateTime.UtcNow.Subtract(utcNow);
                if (t >= GlobalSettings.MaxCleanUpExecutionTime)
                {
                    AirSyncDiagnostics.TraceDebug <int, double>(ExTraceGlobals.RequestsTracer, null, "Done Cleaning up stale devices. DevicesCleaned:{0}, ExecutionTime(in ms):{1}", noOfDevicesRemoved, t.TotalMilliseconds);
                    return(false);
                }
            }
            return(true);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        private bool EnqueueEvent(NotificationManager.AsyncEvent evt)
        {
            bool result;

            lock (this.eventQueue)
            {
                if (this.disposed && evt.Type != NotificationManager.AsyncEventType.Release)
                {
                    result = false;
                }
                else if (evt.Type == NotificationManager.AsyncEventType.Acquire && (!this.subscriptionCanBeTaken || ExDateTime.UtcNow > this.policyExpirationTime))
                {
                    result = false;
                }
                else
                {
                    if (evt.Type != NotificationManager.AsyncEventType.Timeout && evt.Type != NotificationManager.AsyncEventType.Acquire && evt.Type != NotificationManager.AsyncEventType.Release)
                    {
                        this.subscriptionCanBeTaken = false;
                        this.EnqueueDiagOperation(NotificationManager.DiagnosticEvent.Locked);
                    }
                    this.eventQueue.Enqueue(evt);
                    AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.ThreadingTracer, this, "Enqueue event for {0}. processingEnabled:{1}", this.uniqueId, (this.command == null) ? "<null command>" : this.command.ProcessingEventsEnabled.ToString());
                    if (this.command == null || this.command.ProcessingEventsEnabled)
                    {
                        this.ProcessQueuedEvents(null);
                    }
                    result = true;
                }
            }
            return(result);
        }
コード例 #9
0
        private static PolicyData LoadDefaultPolicySetting(IConfigurationSession scopedSession, ProtocolLogger protocolLogger)
        {
            MobileMailboxPolicy[] mobileMaiboxPolicies = null;
            ADOperationResult     adoperationResult    = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                mobileMaiboxPolicies = scopedSession.Find <MobileMailboxPolicy>(scopedSession.GetOrgContainerId().GetDescendantId(new ADObjectId("CN=Mobile Mailbox Policies")), QueryScope.OneLevel, ADNotificationManager.filter, ADNotificationManager.sortBy, 3);
            });

            if (!adoperationResult.Succeeded)
            {
                AirSyncDiagnostics.TraceDebug <ADObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during LoadDefaultPolicySettings for OrgID {0}. Message - {1}", scopedSession.GetOrgContainerId(), adoperationResult.Exception.Message);
                throw adoperationResult.Exception;
            }
            protocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc);
            if (mobileMaiboxPolicies == null || mobileMaiboxPolicies.Length == 0)
            {
                AirSyncDiagnostics.TraceInfo <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "no default policy setting found for OrgId {0}", scopedSession.GetOrgContainerId());
                return(null);
            }
            AirSyncDiagnostics.TraceInfo <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "LoadDefaultPolicySetting from AD.Policy Id {0}", mobileMaiboxPolicies[0].Id);
            if (mobileMaiboxPolicies.Length > 1)
            {
                ADNotificationManager.HandleMultipleDefaultPolicies(mobileMaiboxPolicies, scopedSession.GetOrgContainerId(), protocolLogger);
                protocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc);
            }
            return(ADNotificationManager.AddPolicyToCache(mobileMaiboxPolicies[0], scopedSession.SessionSettings.CurrentOrganizationId.PartitionId));
        }
コード例 #10
0
        private static bool LoadADSettingsData <T>(MruDictionaryCache <string, ADNotificationManager.ADSettingsInfo <T> > cachedData, string adObjectDN, Func <T> loadDataAction, PartitionId partitionId, out ADNotificationManager.ADSettingsInfo <T> adSettingDataInfo)
        {
            bool result = false;

            if (GlobalSettings.DisableCaching || !cachedData.TryGetValue(adObjectDN, out adSettingDataInfo) || adSettingDataInfo.WhenCreated.Add(GlobalSettings.ADCacheExpirationTimeout) < ExDateTime.UtcNow)
            {
                lock (ADNotificationManager.lockObject)
                {
                    if (GlobalSettings.DisableCaching || !cachedData.TryGetValue(adObjectDN, out adSettingDataInfo) || adSettingDataInfo.WhenCreated.Add(GlobalSettings.ADCacheExpirationTimeout) < ExDateTime.UtcNow)
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Load user settings from AD for DN {0}", adObjectDN);
                        T adSettings = loadDataAction();
                        adSettingDataInfo = new ADNotificationManager.ADSettingsInfo <T>(partitionId, adSettings, ExDateTime.UtcNow);
                        result            = true;
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Load user adsettings from cache2 for DN {0}", adObjectDN);
                    }
                    return(result);
                }
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Load user adsettings from cache for DN {0}", adObjectDN);
            return(result);
        }
コード例 #11
0
        private static PolicyData GetDefaultPolicySetting(IAirSyncUser user)
        {
            ADObjectId configurationUnit = user.ADUser.ConfigurationUnit;

            if (configurationUnit == null)
            {
                if (ADNotificationManager.enterpriseConfigurationID == null)
                {
                    IConfigurationSession configurationSession = ADNotificationManager.CreateScopedADSession(user);
                    ADNotificationManager.enterpriseConfigurationID = configurationSession.GetOrgContainerId();
                    user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, configurationSession.LastUsedDc);
                }
                configurationUnit = ADNotificationManager.enterpriseConfigurationID;
            }
            Func <PolicyData> loadDataAction = () => ADNotificationManager.LoadDefaultPolicySetting(ADNotificationManager.CreateScopedADSession(user), user.Context.ProtocolLogger);

            ADNotificationManager.ADSettingsInfo <PolicyData> adsettingsInfo;
            bool flag = ADNotificationManager.LoadADSettingsData <PolicyData>(ADNotificationManager.policies, configurationUnit.DistinguishedName, loadDataAction, user.OrganizationId.PartitionId, out adsettingsInfo);

            if (flag && adsettingsInfo.ADSettingsData == null)
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Default PolicySettings not found. Save null in cache.Policy DN {0}", configurationUnit.DistinguishedName);
                ADNotificationManager.policies.Add(configurationUnit.DistinguishedName, new ADNotificationManager.ADSettingsInfo <PolicyData>(user.OrganizationId.PartitionId, null, ExDateTime.UtcNow));
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Returning Default PolicySettings data. DN {0}", configurationUnit.DistinguishedName);
            return(adsettingsInfo.ADSettingsData);
        }
コード例 #12
0
 // 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);
 }
コード例 #13
0
 // Token: 0x06000592 RID: 1426 RVA: 0x00021394 File Offset: 0x0001F594
 private static ActiveSyncDeviceClasses GetActiveSyncDeviceClassContainer(IConfigurationSession scopedSession, OrganizationId orgId)
 {
     ActiveSyncDeviceClasses[] deviceClasses = null;
     ADNotificationAdapter.RunADOperation(delegate()
     {
         deviceClasses = scopedSession.Find <ActiveSyncDeviceClasses>(orgId.ConfigurationUnit, QueryScope.SubTree, DeviceClassCache.deviceClassesFilter, DeviceClassCache.deviceClassesSortOrder, 0);
     });
     DeviceClassCache.UpdateProtocolLogLastUsedDC(scopedSession);
     if (deviceClasses == null)
     {
         AirSyncDiagnostics.TraceDebug <OrganizationId>(ExTraceGlobals.RequestsTracer, null, "Oragnization \"{0}\" has no DeviceClass container in AD.", orgId);
         AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_NoDeviceClassContainer, new string[]
         {
             orgId.ToString()
         });
         return(null);
     }
     AirSyncDiagnostics.TraceDebug <OrganizationId, int>(ExTraceGlobals.RequestsTracer, null, "Oragnization '{0}' has '{1}' DeviceClass container in AD.", orgId, deviceClasses.Length);
     if (deviceClasses.Length == 1)
     {
         return(deviceClasses[0]);
     }
     if (Command.CurrentCommand != null)
     {
         Command.CurrentCommand.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "TooManyDeviceClassContainers");
     }
     return(DeviceClassCache.CleanMangledObjects(scopedSession, deviceClasses, "ExchangeDeviceClasses") as ActiveSyncDeviceClasses);
 }
コード例 #14
0
 // Token: 0x06000591 RID: 1425 RVA: 0x00021220 File Offset: 0x0001F420
 private static void ProcessForADCleanup(IConfigurationSession scopedSession, DeviceClassCache.DeviceClassDataSet localDataSet, DeviceClassCache.DeviceClassDataSet dataSetFromAD, ref int totalADWriteCount, ref int perOrgDeleteCount)
 {
     foreach (DeviceClassCache.DeviceClassData deviceClassData in dataSetFromAD)
     {
         if (totalADWriteCount >= GlobalSettings.DeviceClassCacheMaxADUploadCount)
         {
             AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.RequestsTracer, null, "3. Stop updating AD because the cap is reached: adUpdateCount={0}", totalADWriteCount);
             break;
         }
         if (localDataSet.Contains(deviceClassData))
         {
             if ((ExDateTime.UtcNow - deviceClassData.LastUpdateTime).Days >= TimeSpan.FromDays((double)GlobalSettings.DeviceClassCacheADCleanupInterval).Days)
             {
                 AirSyncDiagnostics.TraceDebug <ExDateTime, int>(ExTraceGlobals.RequestsTracer, null, "Update or Create DeviceClass in AD. LastUpdateTime :{0}. adUpdateCount: {1}", deviceClassData.LastUpdateTime, totalADWriteCount);
                 DeviceClassCache.CreateOrUpdateActiveSyncDeviceClass(scopedSession, deviceClassData, localDataSet.OrganizationId);
                 totalADWriteCount++;
             }
         }
         else if ((ExDateTime.UtcNow - deviceClassData.LastUpdateTime).Days > TimeSpan.FromDays((double)GlobalSettings.DeviceClassCacheADCleanupInterval).Days * 2)
         {
             AirSyncDiagnostics.TraceDebug <ExDateTime, int>(ExTraceGlobals.RequestsTracer, null, "Delete DeviceClass in AD. LastUpdateTime :{0}, adUpdateCount: {1} ", deviceClassData.LastUpdateTime, totalADWriteCount);
             DeviceClassCache.DeleteActiveSyncDeviceClass(scopedSession, deviceClassData, localDataSet.OrganizationId);
             perOrgDeleteCount++;
             totalADWriteCount++;
         }
     }
 }
コード例 #15
0
 private bool QueryAvailability(AvailabilityQuery availabilityQuery, List <ResolvedRecipient> availabilityList, out AvailabilityQueryResult result)
 {
     result = null;
     AirSyncCounters.NumberOfAvailabilityRequests.Increment();
     try
     {
         result = availabilityQuery.Execute();
     }
     catch (ClientDisconnectedException)
     {
         AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "AvailabilityQuery has thrown ClientDisconnectedException");
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ClientDisconnectedException");
         foreach (ResolvedRecipient resolvedRecipient in availabilityList)
         {
             resolvedRecipient.AvailabilityStatus = StatusCode.AvailabilityTransientFailure;
         }
         return(false);
     }
     finally
     {
         AirSyncDiagnostics.TraceDebug <StringBuilder>(ExTraceGlobals.RequestsTracer, this, "AvailabilityQuery log:{0}", availabilityQuery.RequestLogger.LogData);
     }
     if (result == null)
     {
         AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "AvailabilityQuery has returned null result");
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EmptyAvailabilityResult");
         foreach (ResolvedRecipient resolvedRecipient2 in availabilityList)
         {
             resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityFailure;
         }
         return(false);
     }
     return(true);
 }
コード例 #16
0
        public static NotificationManager CreateNotificationManager(INotificationManagerContext context, IAsyncCommand command)
        {
            string text = NotificationManager.GetUniqueId(context);
            uint   num  = context.PolicyKey;
            int    mailboxPolicyHash = context.MailboxPolicyHash;
            NotificationManager notificationManager = new NotificationManager(command, text, mailboxPolicyHash, num);
            NotificationManager notificationManager2;

            lock (NotificationManager.notificationManagerCache)
            {
                if (NotificationManager.notificationManagerCache.TryGetValue(text, out notificationManager2))
                {
                    NotificationManager.cacheContentionsPerMinute.Add(1U);
                    notificationManager2.EnqueueDiagOperation(NotificationManager.DiagnosticEvent.Removed);
                    NotificationManager.notificationManagerCache.Remove(text);
                    NotificationManager.removedInstances[text] = notificationManager2;
                }
                NotificationManager.createsPerMinute.Add(1U);
                notificationManager.EnqueueDiagOperation(NotificationManager.DiagnosticEvent.Cached);
                NotificationManager.notificationManagerCache.Add(text, notificationManager);
                AirSyncCounters.NumberOfNotificationManagerInCache.RawValue = (long)NotificationManager.notificationManagerCache.Count;
            }
            if (notificationManager2 != null)
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ThreadingTracer, notificationManager, "Disposing existing NotificationManager for {0}", text);
                notificationManager2.EnqueueEvent(new NotificationManager.AsyncEvent(NotificationManager.AsyncEventType.Acquire, null));
                notificationManager2.EnqueueDispose();
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ThreadingTracer, notificationManager, "Created notification manager for {0}", text);
            return(notificationManager);
        }
コード例 #17
0
 // Token: 0x060000AE RID: 174 RVA: 0x0000708C File Offset: 0x0000528C
 internal MobileDevice GetMobileDevice()
 {
     MobileDevice[] devices = null;
     ADNotificationAdapter.RunADOperation(delegate()
     {
         devices = this.session.Find <MobileDevice>(MobileDevice.GetRootId(this.userId), QueryScope.OneLevel, this.defaultDeviceFilter, ADDeviceManager.defaultSortOrder, 50);
     });
     if (this.protocolLogger != null)
     {
         this.protocolLogger.SetValue(ProtocolLoggerData.DomainController, this.session.LastUsedDc);
     }
     if (devices.Length == 1)
     {
         return(devices[0]);
     }
     if (devices.Length == 0)
     {
         return(null);
     }
     AirSyncDiagnostics.TraceDebug <string>(this.tracer, this, "User \"{0}\" has more than one device with same device ID and device type.", this.userName);
     if (this.protocolLogger != null)
     {
         this.protocolLogger.SetValue(ProtocolLoggerData.Error, "UserHasMoreThanOneDeviceWithSameDeviceIDandDeviceType-Cleaned");
     }
     return(this.CleanMangledObjects(devices));
 }
コード例 #18
0
        // Token: 0x06001569 RID: 5481 RVA: 0x0007E1B0 File Offset: 0x0007C3B0
        protected bool IsIrmOperation(out Guid templateId)
        {
            string templateID = this.TemplateID;

            if (templateID == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "IRM operation not requested by device");
                templateId = Guid.Empty;
                return(false);
            }
            AirSyncCounters.NumberOfSendIRMMails.Increment();
            if (!base.User.IrmEnabled || !base.Request.IsSecureConnection)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "IRM feature disabled for user {0}", base.User.DisplayName);
                throw new AirSyncPermanentException(StatusCode.IRM_FeatureDisabled, false)
                      {
                          ErrorStringForProtocolLogger = "smbIioFeatureDisabled"
                      };
            }
            if (!DrmClientUtils.TryParseGuid(templateID, out templateId))
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "Invalid template Guid {0}", templateID);
                throw new AirSyncPermanentException(StatusCode.IRM_InvalidTemplateID, false)
                      {
                          ErrorStringForProtocolLogger = "smbIioInvalidTemplateID"
                      };
            }
            return(true);
        }
コード例 #19
0
 // Token: 0x060008AB RID: 2219 RVA: 0x00033E60 File Offset: 0x00032060
 private void AddVirtualFolders(XmlDocument doc, string nameSpaceUri, Dictionary <ISyncItemId, XmlNode> changeNodes)
 {
     for (int i = 0; i < FolderSyncCommand.virtualFolders.Length; i++)
     {
         FolderSyncCommand.VirtualFolder virtualFolder = FolderSyncCommand.virtualFolders[i];
         if (base.Version < virtualFolder.MinimumVersion)
         {
             AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Skipping virtual folder for {0} due to version!", virtualFolder.DisplayName);
         }
         else
         {
             AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Adding virtual folder for {0}!", virtualFolder.DisplayName);
             XmlNode xmlNode = doc.CreateElement("Add", nameSpaceUri);
             changeNodes[new VirtualFolderItemId(virtualFolder.ShortId)] = xmlNode;
             base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ServerAdds);
             XmlNode xmlNode2 = doc.CreateElement("ServerId", nameSpaceUri);
             xmlNode2.InnerText = virtualFolder.ShortId;
             xmlNode.AppendChild(xmlNode2);
             XmlNode xmlNode3 = doc.CreateElement("ParentId", nameSpaceUri);
             xmlNode3.InnerText = "0";
             xmlNode.AppendChild(xmlNode3);
             XmlNode xmlNode4 = doc.CreateElement("DisplayName", nameSpaceUri);
             xmlNode4.InnerText = virtualFolder.DisplayName;
             xmlNode.AppendChild(xmlNode4);
             XmlNode xmlNode5 = doc.CreateElement("Type", nameSpaceUri);
             xmlNode5.InnerText = virtualFolder.Type;
             xmlNode.AppendChild(xmlNode5);
         }
     }
 }
コード例 #20
0
        internal void BeginGetThumbnailPhotoFromMailbox(List <string> targetPrimarySmtpAddresses, UserPhotoSize photoSize)
        {
            foreach (string text in targetPrimarySmtpAddresses)
            {
                if (AirSyncPhotoRetriever.userPhotosCache.ContainsKey(text))
                {
                    if ((from s in AirSyncPhotoRetriever.userPhotosCache[text]
                         where s.PhotoSize == photoSize
                         select s).Count <AirSyncPhotoRetriever.UserPhotoWithSize>() != 0)
                    {
                        goto IL_111;
                    }
                }
                if (!this.delegatesCollection.ContainsKey(text))
                {
                    AirSyncDiagnostics.TraceDebug <string, string, UserPhotoSize>(ExTraceGlobals.ProtocolTracer, null, "AirSyncPhotoRetriever::BeginGetThumbnailPhotoFromMailbox - {0} requesting photo for {1} , with photosize {2}", this.Context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), text, photoSize);
                    AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate getThumbnailPhotoFromMailboxDelegate = new AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate(AirSyncPhotoRetriever.GetThumbnailPhotoFromMailbox);
                    IAsyncResult value = getThumbnailPhotoFromMailboxDelegate.BeginInvoke(this.Context, text, photoSize, null, new AirSyncPhotoRetriever.UserPhotoWithSize
                    {
                        UserEmail = text,
                        PhotoSize = photoSize
                    });
                    this.delegatesCollection.TryAdd(text, value);
                    this.NumberOfPhotosRequested++;
                    continue;
                }
IL_111:
                this.NumberOfPhotosFromCache++;
            }
        }
コード例 #21
0
        // Token: 0x06000590 RID: 1424 RVA: 0x000210DC File Offset: 0x0001F2DC
        private static void ProcessForADAdds(IConfigurationSession scopedSession, DeviceClassCache.DeviceClassDataSet localDataSet, DeviceClassCache.DeviceClassDataSet dataSetFromAD, ref int totalADWriteCount, int perOrgDeleteCount)
        {
            int num = 0;

            foreach (DeviceClassCache.DeviceClassData deviceClassData in localDataSet)
            {
                if (totalADWriteCount >= GlobalSettings.DeviceClassCacheMaxADUploadCount)
                {
                    AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.RequestsTracer, null, "2. Stop updating AD because the cap is reached: adUpdateCount={0}", totalADWriteCount);
                    break;
                }
                if (!dataSetFromAD.Contains(deviceClassData))
                {
                    if (dataSetFromAD.Count + num - perOrgDeleteCount >= GlobalSettings.DeviceClassPerOrgMaxADCount)
                    {
                        AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, null, "Stop adding new device class node to AD because the cap is reached: dataSetFromAD.Count={0}, DeviceClassPerOrgMaxADCount={1}", dataSetFromAD.Count, GlobalSettings.DeviceClassPerOrgMaxADCount);
                        break;
                    }
                    if (dataSetFromAD.Count + num >= DeviceClassCache.ADCapWarningThreshold)
                    {
                        AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, null, "Still adding new device class node to AD but the cap is close to be reached: dataSetFromAD.Count={0}, DeviceClassPerOrgMaxADCount={1}", dataSetFromAD.Count, DeviceClassCache.ADCapWarningThreshold);
                        AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_TooManyDeviceClassNodes, localDataSet.OrganizationId.ToString(), new string[]
                        {
                            dataSetFromAD.Count.ToString(),
                            localDataSet.OrganizationId.ToString(),
                            GlobalSettings.DeviceClassPerOrgMaxADCount.ToString()
                        });
                    }
                    DeviceClassCache.CreateOrUpdateActiveSyncDeviceClass(scopedSession, deviceClassData, localDataSet.OrganizationId);
                    num++;
                    totalADWriteCount++;
                }
            }
        }
コード例 #22
0
 // Token: 0x060004C8 RID: 1224 RVA: 0x0001D6DC File Offset: 0x0001B8DC
 protected override void ProcessCommand(MailboxSession mailboxSession, XmlDocument doc)
 {
     if (base.CollectionRequest.CollectionName == null || base.CollectionRequest.ParentId == null)
     {
         base.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidURLParameters");
         throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
     }
     AirSyncDiagnostics.TraceDebug <string, StoreObjectId>(ExTraceGlobals.RequestsTracer, this, "Creating collection with name {0} and parent Id {1}.", base.CollectionRequest.CollectionName, base.CollectionRequest.ParentId);
     using (Folder folder = Folder.Create(mailboxSession, base.CollectionRequest.ParentId, StoreObjectType.Folder))
     {
         folder.DisplayName = base.CollectionRequest.CollectionName;
         folder.ClassName   = "IPF.Note";
         folder.Save();
         XmlNode xmlNode  = doc.CreateElement("Response", "FolderHierarchy:");
         XmlNode xmlNode2 = doc.CreateElement("Status", "FolderHierarchy:");
         XmlNode xmlNode3 = doc.CreateElement("Folder", "FolderHierarchy:");
         XmlNode xmlNode4 = doc.CreateElement("ServerId", "FolderHierarchy:");
         xmlNode2.InnerText = "1";
         folder.Load();
         xmlNode4.InnerText = ((FolderIdMapping)base.SyncState[CustomStateDatumType.IdMapping]).Add(MailboxSyncItemId.CreateForNewItem(folder.Id.ObjectId));
         doc.AppendChild(xmlNode);
         xmlNode.AppendChild(xmlNode2);
         xmlNode.AppendChild(xmlNode3);
         xmlNode3.AppendChild(xmlNode4);
     }
 }
コード例 #23
0
        // Token: 0x060002FE RID: 766 RVA: 0x0000FC2C File Offset: 0x0000DE2C
        private void InitializeFromClientSecurityContext()
        {
            string proxyHeader = this.context.Request.ProxyHeader;

            if (this.clientSecurityContextWrapper != null)
            {
                AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromClientSecurityContext]. clientSecurityContextWrapper is not null. calling dispose.");
                this.clientSecurityContextWrapper.Dispose();
            }
            this.clientSecurityContextWrapper = (ClientSecurityContextWrapper)HttpRuntime.Cache.Get(proxyHeader);
            if (this.clientSecurityContextWrapper == null)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromClientSecurityContext] ProxyHeader key '{0}' was missing from HttpRuntime cache.  Returning HttpStatusNeedIdentity.", proxyHeader);
                this.context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MissingCscCacheEntry");
                AirSyncPermanentException ex = new AirSyncPermanentException((HttpStatusCode)441, StatusCode.None, null, false);
                throw ex;
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromClientSecurityContext] ProxyHeader key '{0}' was found in the HttpRuntime cache.  Reusing CSC for user.", proxyHeader);
            string[] array = proxyHeader.Split(",".ToCharArray(), 2);
            if (array.Length != 2)
            {
                this.context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadProxyHeader");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
            }
            this.username = array[1];
            ((IAirSyncUser)this).InitializeADUser();
            ((IAirSyncUser)this).AcquireBudget();
        }
コード例 #24
0
        public string Add(ISyncItemId mailboxItemId)
        {
            AirSyncDiagnostics.Assert(mailboxItemId != null);
            if (mailboxItemId != null && mailboxItemId.NativeId != null)
            {
                StoreObjectId storeObjectId = mailboxItemId.NativeId as StoreObjectId;
                if (storeObjectId != null && storeObjectId.ObjectType == StoreObjectType.CalendarItemOccurrence)
                {
                    AirSyncDiagnostics.TraceDebug <ISyncItemId>(ExTraceGlobals.RequestsTracer, this, "CalendarItemOccurrence ItemId is being added to the ItemIdMapping! Id:{0}.", mailboxItemId);
                }
            }
            string text;

            if (base.OldIds.ContainsKey(mailboxItemId))
            {
                text = base.OldIds[mailboxItemId];
            }
            else
            {
                text = this.parentSyncId + ":" + base.UniqueCounter.ToString(CultureInfo.InvariantCulture);
            }
            AirSyncDiagnostics.Assert(text.Length <= 64);
            base.Add(mailboxItemId, text);
            return(text);
        }
コード例 #25
0
        // Token: 0x06000757 RID: 1879 RVA: 0x00028C74 File Offset: 0x00026E74
        public static bool IsInternalUri(Uri uri)
        {
            AirSyncDiagnostics.Assert(uri != null);
            string host = uri.Host;

            if (DocumentLibraryUtility.RemoteDocumentsInternalDomainSuffixList != null)
            {
                foreach (string value in DocumentLibraryUtility.RemoteDocumentsInternalDomainSuffixList)
                {
                    if (host.EndsWith(value, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }
            IPAddress ipaddress = new IPAddress(0L);
            bool      result;

            try
            {
                result = (!IPAddress.TryParse(host, out ipaddress) && host.IndexOf('.') < 0);
            }
            catch (ArgumentException)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, null, "Invalid Uri Format in internal URI determination");
                result = false;
            }
            return(result);
        }
コード例 #26
0
 private void ProxyLoginWriteCompleteCallback(IAsyncResult iar)
 {
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginWriteCompleteCallback: {0}, {1}.", this.remoteUri, this.userName);
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.ProxyLoginWriteCompleteCallback() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         this.UnregisterTimeoutWaitHandle();
         this.backEndRequestStream.EndWrite(iar);
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.ProxyLoginGettingResponse;
         IAsyncResult asyncResult = this.backEndWebRequest.BeginGetResponse(new AsyncCallback(this.ProxyLoginGetResponseCompleteCallback), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
     }
     catch (Exception ex)
     {
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginWriteCompleteCallback: completed {0}, {1}.", this.remoteUri, this.userName);
 }
コード例 #27
0
 private void ProxyLoginGetStreamCompleteCallback(IAsyncResult iar)
 {
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginRequestCompleteCallback: {0}, {1}.", this.remoteUri, this.userName);
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.ProxyLoginGetStreamCompleteCallback() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         this.UnregisterTimeoutWaitHandle();
         this.backEndRequestStream  = this.backEndWebRequest.EndGetRequestStream(iar);
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.ProxyLoginWritingCsc;
         IAsyncResult asyncResult = this.backEndRequestStream.BeginWrite(this.proxyInfo.CscBuffer, 0, this.proxyInfo.CscBuffer.Length, new AsyncCallback(this.ProxyLoginWriteCompleteCallback), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginRequestCompleteCallback caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginRequestCompleteCallback: completed {0}, {1}.", this.remoteUri, this.userName);
 }
コード例 #28
0
 private void BackEndWriteContent(IAsyncResult asynchronousResult)
 {
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndWriteContent() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         AirSyncDiagnostics.TraceDebug <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndWriteContent called for serverName: {0}, user {1}", this.remoteUri, this.userName);
         this.UnregisterTimeoutWaitHandle();
         this.backEndRequestStream.EndWrite(asynchronousResult);
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.FrontEndReadContentFromClient;
         IAsyncResult asyncResult = this.clientRequestStream.BeginRead(this.asyncBuffer, 0, this.asyncBuffer.Length, new AsyncCallback(this.FrontEndReadContentFromClient), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndWriteContent caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
 }
コード例 #29
0
 private void ProxyLoginGetResponseCompleteCallback(IAsyncResult iar)
 {
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginGetResponseCompleteCallback: {0}, {1}.", this.remoteUri, this.userName);
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.ProxyLoginGetResponseCompleteCallback() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         this.TryUnregisterTimeoutWaitHandle();
         this.httpWebResponse = (HttpWebResponse)this.backEndWebRequest.EndGetResponse(iar);
     }
     catch (WebException ex)
     {
         this.HandleException(ex);
         return;
     }
     finally
     {
         if (this.backEndRequestStream != null)
         {
             this.backEndRequestStream.Flush();
             this.backEndRequestStream.Dispose();
             this.backEndRequestStream = null;
         }
         if (this.httpWebResponse != null)
         {
             this.httpWebResponse.Close();
         }
     }
     if (this.httpWebResponse == null)
     {
         this.HandleException(new WebException("Received null response object."));
     }
     else
     {
         if (this.httpWebResponse.StatusCode != HttpStatusCode.OK)
         {
             this.HandleException(new WebException("Received HTTP status " + this.httpWebResponse.StatusCode + " from second CAS."));
             return;
         }
         this.backEndWebRequest = this.CopyClientRequest(this.frontEndHttpContext.Request, this.cachedUri);
         this.cachedRequestBody.Seek(0L, SeekOrigin.Begin);
         this.clientRequestStream   = this.cachedRequestBody;
         this.cachedRequestBody     = null;
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndGetRequestStream;
         IAsyncResult asyncResult = this.backEndWebRequest.BeginGetRequestStream(new AsyncCallback(this.BackEndGetRequestStream), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
         AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginGetResponseCompleteCallback: completed {0}, {1}.", this.remoteUri, this.userName);
         return;
     }
 }
コード例 #30
0
 private void FrontEndReadContentFromClient(IAsyncResult asynchronousResult)
 {
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.FrontEndReadContentFromClient() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         AirSyncDiagnostics.TraceDebug <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.FrontEndReadContentFromClient called for serverName: {0}, user {1}", this.remoteUri, this.userName);
         this.UnregisterTimeoutWaitHandle();
         if (this.proxyLoginAttempts == 0 && this.cachedRequestBody == null)
         {
             this.cachedRequestBody = new MemoryStream(this.frontEndHttpContext.Request.ContentLength);
         }
         int num = this.clientRequestStream.EndRead(asynchronousResult);
         if (num > 0)
         {
             if (this.proxyLoginAttempts == 0)
             {
                 this.cachedRequestBody.Write(this.asyncBuffer, 0, num);
             }
             lock (this)
             {
                 this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndWriteContent;
                 IAsyncResult asyncResult = this.backEndRequestStream.BeginWrite(this.asyncBuffer, 0, num, new AsyncCallback(this.BackEndWriteContent), null);
                 if (!asyncResult.CompletedSynchronously)
                 {
                     this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
                 }
                 goto IL_16D;
             }
         }
         this.backEndRequestStream.Flush();
         this.backEndRequestStream.Dispose();
         this.backEndRequestStream  = null;
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndGetResponse;
         IAsyncResult asyncResult2 = this.backEndWebRequest.BeginGetResponse(new AsyncCallback(this.BackEndGetResponse), null);
         if (!asyncResult2.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult2, (int)GlobalSettings.ProxyHandlerLongTimeout.TotalMilliseconds);
         }
         IL_16D :;
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.FrontEndReadContentFromClient caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
 }