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]); } }
public override OperationResult DeleteSyncItem(SyncCommandItem syncCommandItem, bool deletesAsMoves) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.DeleteSyncItem(SyncCommandItem)"); EntitySyncProviderFactory entitySyncProviderFactory = (EntitySyncProviderFactory)base.SyncProviderFactory; StoreObjectId folderId = entitySyncProviderFactory.FolderId; if (AirSyncUtility.GetAirSyncFolderTypeClass(folderId) == "Calendar") { CancelEventParameters parameters; if (syncCommandItem.XmlNode != null) { try { parameters = EventParametersParser.ParseCancel(syncCommandItem.XmlNode); goto IL_72; } catch (RequestParsingException ex) { throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, ex.LocalizedString, ex, false) { ErrorStringForProtocolLogger = ex.LogMessage }; } } parameters = new CancelEventParameters(); IL_72: this.DeleteItem(syncCommandItem.Id, parameters); return(OperationResult.Succeeded); } return(this.DeleteSyncItem(syncCommandItem.ServerId, deletesAsMoves)); }
// Token: 0x0600056A RID: 1386 RVA: 0x000200D0 File Offset: 0x0001E2D0 private void BlockDevice(AutoblockThresholdType autoblockThresholdType) { AirSyncDiagnostics.TraceInfo <AutoblockThresholdType>(ExTraceGlobals.RequestsTracer, this, "BlockDevice {0}", autoblockThresholdType); EnhancedTimeSpan deviceBlockDuration = ADNotificationManager.GetAutoBlockThreshold(autoblockThresholdType).DeviceBlockDuration; ExDateTime utcNow = ExDateTime.UtcNow; lock (this.instanceLock) { if (this.blockTime > utcNow || this.nextUnblockTime < utcNow) { this.blockTime = utcNow; this.nextUnblockTime = utcNow + deviceBlockDuration; this.autoBlockReason = DeviceAccessStateReason.UserAgentsChanges + (int)autoblockThresholdType; this.timeToUpdateAD = utcNow; this.SaveDeviceBehavior(true); if (deviceBlockDuration != EnhancedTimeSpan.Zero) { AirSyncCounters.AutoBlockedDevices.Increment(); } if (this.ProtocolLogger != null) { this.ProtocolLogger.SetValue(ProtocolLoggerData.AutoBlockEvent, autoblockThresholdType.ToString()); } } } }
public override void ConvertServerToClientObject(ISyncItem syncItem, XmlNode airSyncParentNode, SyncOperation changeObject, GlobalInfo globalInfo) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "EntitySyncCollection.ConvertServerToClientObject"); IItem item = ((EntitySyncItem)syncItem).Item; Item item2 = ((EntitySyncItem)syncItem).NativeItem as Item; if (item2 == null || !this.EntityDataObject.CanConvertItemClassUsingCurrentSchema(item2.ClassName)) { throw new ConversionException(string.Format("Cannot convert item '{0}' of .NET type \"{1}\" using current schema. ClassName: '{2}'", item.Id, item.GetType().FullName, (item2 == null) ? "<NULL>" : item2.ClassName)); } try { base.AirSyncDataObject.Bind(airSyncParentNode); this.EntityDataObject.Bind(item); AirSyncDiagnostics.FaultInjectionTracer.TraceTest(2170957117U); base.AirSyncDataObject.CopyFrom(this.EntityDataObject); } finally { this.EntityDataObject.Unbind(); base.AirSyncDataObject.Unbind(); } base.ApplyChangeTrackFilter(changeObject, airSyncParentNode); base.SetHasChanges(changeObject); }
// Token: 0x060002F7 RID: 759 RVA: 0x0000F8AC File Offset: 0x0000DAAC BackOffValue IAirSyncUser.GetBudgetBackOffValue() { BackOffValue backOffValue = null; if (((IAirSyncUser)this).Budget != null) { ITokenBucket budgetTokenBucket = ((IAirSyncUser)this).GetBudgetTokenBucket(); if (budgetTokenBucket == null) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.GetBudgetBackOffDuration] Budget does not contain a token bucket. Likely unthrottled."); return(BackOffValue.NoBackOffValue); } float balance = budgetTokenBucket.GetBalance(); AirSyncDiagnostics.TraceInfo <float, int>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.GetBudgetBackOffDuration]. Balance :{0}, RechargeRate:{1}", balance, budgetTokenBucket.RechargeRate); backOffValue = new BackOffValue { BackOffReason = "Budget" }; if ((double)balance < GlobalSettings.BudgetBackOffMinThreshold.TotalMilliseconds) { backOffValue.BackOffDuration = Math.Ceiling((GlobalSettings.BudgetBackOffMinThreshold.TotalMilliseconds - (double)balance) * 60.0 * 60.0 / (double)budgetTokenBucket.RechargeRate); backOffValue.BackOffType = ((balance > (float)(ulong.MaxValue * (ulong)((IAirSyncUser)this).Budget.ThrottlingPolicy.EasMaxBurst.Value)) ? BackOffType.Medium : BackOffType.High); } else { backOffValue.BackOffDuration = Math.Ceiling((GlobalSettings.BudgetBackOffMinThreshold.TotalMilliseconds - (double)balance) / 1000.0); } } AirSyncDiagnostics.TraceInfo <double, BackOffType>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.GetBudgetBackOffDuration]. BudgetBackOff Duration:{0} sec. BackOffType:{1}", backOffValue.BackOffDuration, backOffValue.BackOffType); return(backOffValue ?? BackOffValue.NoBackOffValue); }
// Token: 0x06000562 RID: 1378 RVA: 0x0001F9A8 File Offset: 0x0001DBA8 private BackOffValue GetAutoBlockBackOffTimeForSyncCommands() { int behaviorTypeIncidenceLimit = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands).BehaviorTypeIncidenceLimit; EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands).BehaviorTypeIncidenceDuration; if (behaviorTypeIncidenceDuration.TotalSeconds == 0.0) { return(BackOffValue.NoBackOffValue); } if (this.syncTimes == null || this.syncTimes.Count == 0 || this.syncTimes.Count <= behaviorTypeIncidenceLimit / 2) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: Skip calculating backOff time."); return(new BackOffValue { BackOffDuration = -1.0 * behaviorTypeIncidenceDuration.TotalSeconds, BackOffType = BackOffType.Low, BackOffReason = AutoblockThresholdType.SyncCommands.ToString() }); } TimeSpan currentDuration = ExDateTime.UtcNow.Subtract(this.syncTimes[0]); BackOffValue backOffValue = this.CalculateAutoBlockBackOffTime(behaviorTypeIncidenceLimit, behaviorTypeIncidenceDuration, this.syncTimes.Count, currentDuration, AutoblockThresholdType.SyncCommands.ToString()); AirSyncDiagnostics.TraceInfo <int, double>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: SyncCommandLimit:{0}, backOffDuration:{1}", behaviorTypeIncidenceLimit, backOffValue.BackOffDuration); return(backOffValue); }
// 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(); }
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)); }
private void InitializeResponseXmlDocument() { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "GIE.InitializeResponseXmlDocument"); base.XmlResponse = new SafeXmlDocument(); XmlElement newChild = base.XmlResponse.CreateElement("GetItemEstimate", "GetItemEstimate:"); base.XmlResponse.AppendChild(newChild); this.getItemEstimateXmlNode = newChild; }
public override bool GetNewOperations(ISyncWatermark minSyncWatermark, ISyncWatermark maxSyncWatermark, bool enumerateDeletes, int numOperations, QueryFilter filter, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest) { if (maxSyncWatermark != null) { throw new NotSupportedException("First Time Sync behavior needs to be accessed via the FirstTimeSync method. Only call GetNewOperations for ICS changes."); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.SyncProcessTracer, this, "[FirstTimeSyncProvider.GetNewOperations] Getting new ICS operations"); return(base.GetNewOperations(minSyncWatermark, maxSyncWatermark, enumerateDeletes, numOperations, filter, newServerManifest)); }
private ExDateTime?GetFilterTypeBoundary(ComparisonFilter comparisonFilter) { if (comparisonFilter != null && comparisonFilter.Property == ItemSchema.ReceivedTime) { AirSyncDiagnostics.TraceInfo <ExDateTime>(ExTraceGlobals.SyncProcessTracer, this, "[FirstTimeSyncProvider.GetFilterTypeBoundary] ReceivedTime boundary: {0}", (ExDateTime)comparisonFilter.PropertyValue); return(new ExDateTime?((ExDateTime)comparisonFilter.PropertyValue)); } AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.SyncProcessTracer, this, "[FirstTimeSyncProvider.GetFilterTypeBoundary] Filter was not on received time, but on: {0}", (comparisonFilter == null) ? "<NULL>" : comparisonFilter.Property.Name); return(null); }
private int?ComputeHash(XmlNode rootNode, bool shouldChangeTrack) { int? result = null; List <int> list = new List <int>(50); list.Add(ChangeTrackingNode.GetQualifiedName(rootNode).GetHashCode()); foreach (object obj in rootNode.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; string qualifiedName = ChangeTrackingNode.GetQualifiedName(xmlNode); if (shouldChangeTrack && this.changeTrackingNodes.ContainsKey(qualifiedName)) { int num = this.changeTrackingNodes[qualifiedName]; this.seenNodes[num] = xmlNode; if (ChangeTrackingFilter.IsContainer(xmlNode)) { AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Recursively computing hash for change tracked container {0}", qualifiedName); this.newChangeTrackingInformation[num] = this.ComputeHash(xmlNode, shouldChangeTrack); AirSyncDiagnostics.TraceInfo <string, int?>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Returned hash for change tracked container {0} = {1}", qualifiedName, this.newChangeTrackingInformation[num]); } else { int value = ChangeTrackingNode.GetQualifiedName(xmlNode).GetHashCode() ^ this.GetHashCode(xmlNode); this.newChangeTrackingInformation[num] = new int?(value); AirSyncDiagnostics.TraceInfo <string, int?>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Calculated change tracked node hash {0} {1}", qualifiedName, this.newChangeTrackingInformation[num]); } } else if (ChangeTrackingFilter.IsContainer(xmlNode)) { int?arg = this.ComputeHash(xmlNode, false); if (arg != null) { list.Add(arg.Value); AirSyncDiagnostics.TraceInfo <string, string, int?>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Returned container node hash {0}{1} = {2}", xmlNode.NamespaceURI, xmlNode.Name, arg); } } else { int item = ChangeTrackingNode.GetQualifiedName(xmlNode).GetHashCode() ^ this.GetHashCode(xmlNode); list.Add(item); AirSyncDiagnostics.TraceInfo <string, string, int>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Calculated node hash {0}{1} = {2}", xmlNode.NamespaceURI, xmlNode.Name, item.GetHashCode()); } } if (list.Count > 1) { list.Sort(); StringBuilder stringBuilder = new StringBuilder(list.Count * 10); foreach (int num2 in list) { stringBuilder.Append(num2.ToString(CultureInfo.InvariantCulture)); } result = new int?(stringBuilder.ToString().GetHashCode()); } return(result); }
protected void DeleteItem(ISyncItemId syncItemId, CancelEventParameters parameters) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.DeleteItem"); string key = EntitySyncItem.GetKey(base.StoreSession.MailboxGuid, (StoreId)syncItemId.NativeId); this.Events.Cancel(key, parameters, null); base.ItemIdMapping.Delete(new ISyncItemId[] { syncItemId }); }
// Token: 0x0600055D RID: 1373 RVA: 0x0001F608 File Offset: 0x0001D808 public void AddSyncKey(ExDateTime syncAttemptTime, string collectionId, uint syncKey) { AirSyncDiagnostics.TraceInfo <string, uint>(ExTraceGlobals.RequestsTracer, this, "AddSyncKey collectionId:{0} syncKey:{1}", collectionId, syncKey); DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands); lock (this.instanceLock) { int num = this.syncTimes.Count - 1; while (num > -1 && !(this.syncTimes[num] == syncAttemptTime)) { num--; } if (num == -1) { this.RecordSyncCommand(syncAttemptTime); num = this.syncTimes.Count - 1; if (this.syncTimes[num] != syncAttemptTime) { throw new InvalidOperationException("Recently added sync record is not the last one!"); } if (this.BlockOnFrequency()) { return; } } int num2 = this.syncKeys[num] ^ ((collectionId != null) ? collectionId.GetHashCode() : 0) ^ syncKey.GetHashCode(); this.syncKeys[num] = num2; AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "AddSyncKey new hashcode {0}", num2); if (this.ProtocolLogger != null) { this.ProtocolLogger.SetValue(ProtocolLoggerData.SyncHashCode, num2); } int num3 = 0; ExDateTime t = syncAttemptTime - autoBlockThreshold.BehaviorTypeIncidenceDuration; for (int i = 0; i < this.syncTimes.Count; i++) { if (!(this.syncTimes[i] < t) && this.syncKeys[i] == num2) { num3++; } } int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit > 0 && num3 >= behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.SyncCommands); } else if (this.AutoBlockReason != DeviceAccessStateReason.Unknown) { this.UnblockDevice(); } } }
// Token: 0x06000561 RID: 1377 RVA: 0x0001F93C File Offset: 0x0001DB3C public BackOffValue GetAutoBlockBackOffTime() { BackOffValue autoBlockBackOffTimeForSyncCommands = this.GetAutoBlockBackOffTimeForSyncCommands(); BackOffValue autoBlockBackOffTimeForCommandsFrequency = this.GetAutoBlockBackOffTimeForCommandsFrequency(); if (autoBlockBackOffTimeForSyncCommands.CompareTo(autoBlockBackOffTimeForCommandsFrequency) > 0) { AirSyncDiagnostics.TraceInfo <double, BackOffType, string>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: BackOffTime-{0} sec, BackOffType-{1}, BackOffReason:{2}", autoBlockBackOffTimeForSyncCommands.BackOffDuration, autoBlockBackOffTimeForSyncCommands.BackOffType, autoBlockBackOffTimeForSyncCommands.BackOffReason); return(autoBlockBackOffTimeForSyncCommands); } AirSyncDiagnostics.TraceInfo <double, BackOffType, string>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: BackOffTime-{0} sec, BackOffType-{1}, BackOffReason:{2}", autoBlockBackOffTimeForCommandsFrequency.BackOffDuration, autoBlockBackOffTimeForCommandsFrequency.BackOffType, autoBlockBackOffTimeForCommandsFrequency.BackOffReason); return(autoBlockBackOffTimeForCommandsFrequency); }
// Token: 0x060002FF RID: 767 RVA: 0x0000FD28 File Offset: 0x0000DF28 private void InitializeFromRehydratedIdentity() { if (this.clientSecurityContextWrapper != null) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromRehydratedIdentity]. clientSecurityContextWrapper is not null. calling dispose."); this.clientSecurityContextWrapper.Dispose(); } this.clientSecurityContextWrapper = ClientSecurityContextWrapper.FromIdentity(((IAirSyncUser)this).Identity); this.username = ((IAirSyncUser)this).Identity.Name; AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromRehydratedIdentity] Hyrdating CSC from user {0}", this.username); ((IAirSyncUser)this).InitializeADUser(); ((IAirSyncUser)this).AcquireBudget(); }
// Token: 0x06000559 RID: 1369 RVA: 0x0001F20C File Offset: 0x0001D40C public void RecordCommand(Command command) { if (command == null) { throw new ArgumentNullException("command"); } AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "RecordCommand {0}", command.GetType().Name); int num; if (command.Request.CommandXml == null) { num = command.Request.CommandType.ToString().GetHashCode(); foreach (string text in command.Request.GetRawHttpRequest().QueryString.AllKeys) { num ^= text.GetHashCode(); num ^= command.Request.GetRawHttpRequest().QueryString[text].GetHashCode(); } if (command.InputStream != null) { int num2 = 0; uint num3 = 0U; command.InputStream.Seek(0L, SeekOrigin.Begin); int num4; while ((num4 = command.InputStream.ReadByte()) != -1) { if (num2 < 4) { num3 = (num3 << 8) + (uint)((byte)num4); num2++; } else { num ^= num3.GetHashCode(); num3 = 0U; num2 = 0; } } if (num2 > 0) { num ^= num3.GetHashCode(); } command.InputStream.Seek(0L, SeekOrigin.Begin); } } else { num = command.Request.CommandXml.OuterXml.ToString().GetHashCode(); } this.RecordCommand(num); }
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); }
// Token: 0x0600056B RID: 1387 RVA: 0x000201B4 File Offset: 0x0001E3B4 private void UnblockDevice() { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "UnblockDevice"); TimeSpan timeSpan = ADNotificationManager.Started ? (ADNotificationManager.GetAutoBlockThreshold(this.AutoBlockReason).BehaviorTypeIncidenceDuration *(long)GlobalSettings.AutoBlockADWriteDelay) : TimeSpan.Zero; lock (this.instanceLock) { switch (this.autoBlockReason) { case DeviceAccessStateReason.UserAgentsChanges: this.userAgentTimes.Clear(); this.userAgentStrings.Clear(); break; case DeviceAccessStateReason.RecentCommands: this.recentCommandTimes.Clear(); this.recentCommandHashCodes.Clear(); break; case DeviceAccessStateReason.Watsons: this.watsons.Clear(); break; case DeviceAccessStateReason.OutOfBudgets: this.outOfBudgets.Clear(); break; case DeviceAccessStateReason.SyncCommands: this.syncTimes.Clear(); this.syncKeys.Clear(); break; case DeviceAccessStateReason.CommandFrequency: this.recentCommandTimes.Clear(); this.recentCommandHashCodes.Clear(); this.syncTimes.Clear(); this.syncKeys.Clear(); break; } if (timeSpan > DeviceBehavior.MaxADUpdateDelay) { timeSpan = DeviceBehavior.MaxADUpdateDelay; } this.timeToUpdateAD = ExDateTime.UtcNow + timeSpan; this.nextUnblockTime = ExDateTime.MinValue; this.autoBlockReason = DeviceAccessStateReason.Unknown; this.SaveDeviceBehavior(true); } }
public override bool GetNewOperations(ISyncWatermark minSyncWatermark, ISyncWatermark maxSyncWatermark, bool enumerateDeletes, int numOperations, QueryFilter filter, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest) { base.CheckDisposed("GetNewOperations"); AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "EntitySyncProvider.GetNewOperations. numOperations = {0}", numOperations); if (newServerManifest == null) { throw new ArgumentNullException("newServerManifest"); } if (!enumerateDeletes) { throw new NotImplementedException("enumerateDeletes is false!"); } if (filter != null) { throw new NotImplementedException("filter is non-null! Filters are not supported on EntitySyncProvider"); } SyncCalendar syncCalendar = new SyncCalendar(this.CalendarSyncState, base.Folder.Session, base.Folder.Id.ObjectId, (CalendarFolder folder) => EntitySyncProvider.PropertiesToSync, this.WindowStart, this.WindowEnd, false, numOperations); IFolderSyncState folderSyncState; IList <KeyValuePair <StoreId, LocalizedException> > list; SyncCalendarResponse syncCalendarResponse = syncCalendar.Execute(out folderSyncState, out list); AirSyncDiagnostics.TraceInfo <IFolderSyncState>(ExTraceGlobals.RequestsTracer, this, "newSyncState:{0}", folderSyncState); SyncCalendarFolderSyncState syncCalendarFolderSyncState = (SyncCalendarFolderSyncState)folderSyncState; this.CalendarSyncState = new AirSyncCalendarSyncState(syncCalendarFolderSyncState.SerializeAsBase64String(), syncCalendarResponse.QueryResumptionPoint, syncCalendarResponse.OldWindowEnd); if (list.Count > 0 && Command.CurrentCommand.MailboxLogger != null) { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <StoreId, LocalizedException> keyValuePair in list) { stringBuilder.AppendFormat("Exception caught for item {0}\r\n{1}\r\n\r\n", keyValuePair.Key, keyValuePair.Value); } Command.CurrentCommand.MailboxLogger.SetData(MailboxLogDataName.CalendarSync_Exception, stringBuilder.ToString()); } AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "DeletedItems:{0}", syncCalendarResponse.DeletedItems.Count); foreach (StoreId storeId in syncCalendarResponse.DeletedItems) { ISyncItemId syncItemId = EntitySyncItemId.CreateFromId(storeId); newServerManifest.Add(syncItemId, new ServerManifestEntry(ChangeType.Delete, syncItemId, null)); } this.CopyListToDictionary(syncCalendarResponse.UpdatedItems, "UpdatedItems", newServerManifest); this.CopyListToDictionary(syncCalendarResponse.RecurrenceMastersWithInstances, "RecurrenceMastersWithInstances", newServerManifest); this.CopyListToDictionary(syncCalendarResponse.RecurrenceMastersWithoutInstances, "RecurrenceMastersWithoutInstances", newServerManifest); this.CopyListToDictionary(syncCalendarResponse.UnchangedRecurrenceMastersWithInstances, "UnchangedRecurrenceMastersWithInstances", newServerManifest); AirSyncDiagnostics.TraceInfo <bool>(ExTraceGlobals.RequestsTracer, this, "MoreAvailable:{0}", !syncCalendarResponse.IncludesLastItemInRange); return(!syncCalendarResponse.IncludesLastItemInRange); }
public override ISyncItem CreateSyncItem(SyncCommandItem item) { string classType = item.ClassType; AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "EntitySyncCollection.CreateSyncItem({0})", classType); base.CheckFullAccess(); string a; if ((a = classType) != null && a == "Calendar") { return(EntitySyncItem.Bind(new Event())); } throw new AirSyncPermanentException(HttpStatusCode.NotImplemented, StatusCode.UnexpectedItemClass, null, false) { ErrorStringForProtocolLogger = "BadClassType(" + classType + ")onSync" }; }
public static void LogPeriodicEvent(ExEventLog.EventTuple tuple, string eventKey, params string[] messageArgs) { AirSyncDiagnostics.TraceInfo <uint, string>(ExTraceGlobals.ProtocolTracer, null, "LogPeriodicEvent eventId:{0} eventKey:{1}", tuple.EventId, eventKey); if (messageArgs != null) { for (int i = 0; i < messageArgs.Length; i++) { if (messageArgs[i].Length > 32000) { messageArgs[i] = messageArgs[i].Remove(32000).TrimEnd(new char[0]); } } } if (!AirSyncDiagnostics.eventLogger.LogEvent(tuple, eventKey, messageArgs)) { AirSyncDiagnostics.TraceError <uint>(ExTraceGlobals.ProtocolTracer, null, "Failed to log periodic event {0}", tuple.EventId); } }
public bool GetNewOperations(ISyncWatermark minSyncWatermark, ISyncWatermark maxSyncWatermark, bool enumerateDeletes, int numOperations, QueryFilter filter, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest) { this.CheckDisposed("GetNewOperations"); AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.SyncTracer, this, "RecipientInfoCacheSyncProvider.GetNewOperations. numOperations = {0}", numOperations); if (newServerManifest == null) { throw new ArgumentNullException("newServerManifest"); } if (!enumerateDeletes) { throw new NotImplementedException("enumerateDeletes is false!"); } if (filter != null) { throw new NotImplementedException("filter is non-null! Filters are not supported on RecipientInfoCacheSyncProvider"); } return(this.ComputeNewItems(minSyncWatermark as RecipientInfoCacheSyncWatermark, maxSyncWatermark as RecipientInfoCacheSyncWatermark, numOperations, newServerManifest)); }
// Token: 0x06000556 RID: 1366 RVA: 0x0001EDD0 File Offset: 0x0001CFD0 public static DeviceBehavior GetDeviceBehavior(Guid userGuid, DeviceIdentity deviceIdentity, GlobalInfo globalInfo, object traceObject, ProtocolLogger protocolLogger) { string token = DeviceBehaviorCache.GetToken(userGuid, deviceIdentity); globalInfo.DeviceBehavior.ProtocolLogger = protocolLogger; globalInfo.DeviceBehavior.CacheToken = token; DeviceBehavior deviceBehavior; if (globalInfo.DeviceADObjectId == null || !DeviceBehaviorCache.TryGetAndRemoveValue(userGuid, deviceIdentity, out deviceBehavior)) { if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorLoaded, 7); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, traceObject, "No device in cache, return GlobalInfo.DeviceBehavior"); return(globalInfo.DeviceBehavior); } if (deviceBehavior.AutoBlockReason != globalInfo.DeviceBehavior.AutoBlockReason) { if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorLoaded, 1); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, traceObject, "AutoBlockReason changed, return GlobalInfo.DeviceBehavior"); return(globalInfo.DeviceBehavior); } int num = globalInfo.DeviceBehavior.IsNewerThan(deviceBehavior.WhenLoaded); if (num > -1) { string arg = DeviceBehavior.dateCollections[num]; if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorLoaded, num + 2); } AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, traceObject, "{0} is newer, return GlobalInfo.DeviceBehavior", arg); return(globalInfo.DeviceBehavior); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, traceObject, "Return cached DeviceBehavior"); deviceBehavior.Owner = globalInfo; deviceBehavior.ProtocolLogger = protocolLogger; return(deviceBehavior); }
// Token: 0x0600055C RID: 1372 RVA: 0x0001F55C File Offset: 0x0001D75C public void RecordOutOfBudget() { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "RecordOutOfBudget"); ExDateTime utcNow = ExDateTime.UtcNow; DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.OutOfBudgets); ExDateTime windowStartTime = utcNow - autoBlockThreshold.BehaviorTypeIncidenceDuration; lock (this.instanceLock) { DeviceBehavior.ClearOldRecords(windowStartTime, this.outOfBudgets); this.outOfBudgets.Add(utcNow); this.SaveDeviceBehavior(false); int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit > 0 && this.outOfBudgets.Count > behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.OutOfBudgets); } } }
// Token: 0x0600055A RID: 1370 RVA: 0x0001F358 File Offset: 0x0001D558 public void RecordCommand(int commandHashcode) { AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "RecordCommand HC:{0}", commandHashcode); ExDateTime utcNow = ExDateTime.UtcNow; DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.RecentCommands); EnhancedTimeSpan behaviorTypeIncidenceDuration = autoBlockThreshold.BehaviorTypeIncidenceDuration; if (behaviorTypeIncidenceDuration < ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration) { behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration; } ExDateTime exDateTime = utcNow - behaviorTypeIncidenceDuration; lock (this.instanceLock) { DeviceBehavior.ClearOldRecords(exDateTime, this.recentCommandTimes, this.recentCommandHashCodes); this.recentCommandTimes.Add(utcNow); this.recentCommandHashCodes.Add(commandHashcode); this.SaveDeviceBehavior(false); if (this.ProtocolLogger != null) { this.ProtocolLogger.SetValue(ProtocolLoggerData.CommandHashCode, commandHashcode); } if (!this.BlockOnFrequency()) { exDateTime = utcNow - autoBlockThreshold.BehaviorTypeIncidenceDuration; int num = 0; for (int i = 0; i < this.recentCommandTimes.Count; i++) { if (!(this.recentCommandTimes[i] < exDateTime) && this.recentCommandHashCodes[i] == commandHashcode) { num++; } } int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit > 0 && num > behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.RecentCommands); } } } }
// Token: 0x06000563 RID: 1379 RVA: 0x0001FAA8 File Offset: 0x0001DCA8 private BackOffValue GetAutoBlockBackOffTimeForCommandsFrequency() { EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration; if (behaviorTypeIncidenceDuration.TotalSeconds == 0.0) { return(BackOffValue.NoBackOffValue); } BackOffValue backOffValue; if ((this.recentCommandTimes != null && this.recentCommandTimes.Count >= 0) || (this.syncTimes != null && this.syncTimes.Count >= 0)) { int behaviorTypeIncidenceLimit = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceLimit; ExDateTime exDateTime = ExDateTime.MaxValue; ExDateTime exDateTime2 = ExDateTime.MaxValue; int num = 0; if (this.syncTimes != null && this.syncKeys.Count > 0) { num += this.syncTimes.Count; exDateTime = this.syncTimes[0]; } if (this.recentCommandTimes != null && this.recentCommandTimes.Count > 0) { num += this.recentCommandTimes.Count; exDateTime2 = this.recentCommandTimes[0]; } TimeSpan currentDuration = (exDateTime < exDateTime2) ? ExDateTime.UtcNow.Subtract(exDateTime) : ExDateTime.UtcNow.Subtract(exDateTime2); backOffValue = this.CalculateAutoBlockBackOffTime(behaviorTypeIncidenceLimit, behaviorTypeIncidenceDuration, num, currentDuration, AutoblockThresholdType.CommandFrequency.ToString()); AirSyncDiagnostics.TraceInfo <int, double>(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: SyncCommandLimit:{0}, backOffDuration:{1}", behaviorTypeIncidenceLimit, backOffValue.BackOffDuration); } else { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "GetAutoblockBackOffTime: Skip calculating backOff time."); backOffValue = new BackOffValue { BackOffType = BackOffType.Low, BackOffReason = AutoblockThresholdType.CommandFrequency.ToString(), BackOffDuration = -1.0 * behaviorTypeIncidenceDuration.TotalSeconds }; } return(backOffValue); }
// Token: 0x06000569 RID: 1385 RVA: 0x0001FF98 File Offset: 0x0001E198 private bool BlockOnFrequency() { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "BlockOnFrequency"); int behaviorTypeIncidenceLimit = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit == 0) { return(false); } ExDateTime utcNow = ExDateTime.UtcNow; ExDateTime t = utcNow - ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration; int num = 0; lock (this.instanceLock) { foreach (ExDateTime t2 in this.recentCommandTimes) { if (t2 > t) { num++; } } if (num >= behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.CommandFrequency); return(true); } foreach (ExDateTime t3 in this.syncTimes) { if (t3 > t) { num++; } } if (num >= behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.CommandFrequency); return(true); } } return(false); }
// Token: 0x06000568 RID: 1384 RVA: 0x0001FEDC File Offset: 0x0001E0DC private void RecordSyncCommand(ExDateTime syncAttemptTime) { AirSyncDiagnostics.TraceInfo <ExDateTime>(ExTraceGlobals.RequestsTracer, this, "RecordSyncCommand syncAttemptTime:{0:o}", syncAttemptTime); ExDateTime utcNow = ExDateTime.UtcNow; EnhancedTimeSpan behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands).BehaviorTypeIncidenceDuration; if (behaviorTypeIncidenceDuration < ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration) { behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration; } ExDateTime windowStartTime = utcNow - behaviorTypeIncidenceDuration; lock (this.instanceLock) { DeviceBehavior.ClearOldRecords(windowStartTime, this.syncTimes, this.syncKeys); this.syncTimes.Add(syncAttemptTime); this.syncKeys.Add(0); this.SaveDeviceBehavior(false); } }
void IOrganizationSettingsData.RemoveDeviceAccessRule(string distinguishedName) { for (int i = 0; i < this.deviceAccessRules.Length; i++) { List <DeviceAccessRuleData> list = this.deviceAccessRules[i]; if (list != null && list.Count > 0) { for (int j = 0; j < list.Count; j++) { if (list[j].Identity.Equals(distinguishedName)) { AirSyncDiagnostics.TraceInfo <ADObjectId, ADObjectId>(ExTraceGlobals.RequestsTracer, this, "Removing rule {0} from Org {1} cache.", list[j].Identity, this.Identity); list.RemoveAt(j); return; } } } } AirSyncDiagnostics.TraceError <ADObjectId, string>(ExTraceGlobals.RequestsTracer, this, "Trying to remove a rule not in this Organization. OrganizationId: {0}, rule: {1}", this.Identity, distinguishedName); }