Пример #1
0
        private void ExecuteApplicationStart(object sender, EventArgs e)
        {
            int num = 0;

            num = Privileges.RemoveAllExcept(new string[]
            {
                "SeAuditPrivilege",
                "SeChangeNotifyPrivilege",
                "SeCreateGlobalPrivilege",
                "SeImpersonatePrivilege",
                "SeIncreaseQuotaPrivilege",
                "SeAssignPrimaryTokenPrivilege",
                "SeTcbPrivilege"
            }, "MSExchangeServicesSyncPool");
            if (num != 0)
            {
                string name;
                using (WindowsIdentity current = WindowsIdentity.GetCurrent())
                {
                    name = current.Name;
                }
                AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_SetPrivilegesFailure, "SetPrivilegesFailure: " + name, new string[]
                {
                    name,
                    num.ToString(CultureInfo.InvariantCulture)
                });
                Environment.Exit(num);
            }
            ExWatson.Init("E12");
            AppDomain.CurrentDomain.UnhandledException += Global.HandledExceptionProxy;
            Globals.InitializeMultiPerfCounterInstance("AirSync");
            ExRpcModule.Bind();
            AirSyncDiagnostics.TraceInfo <ResourceManagerHandle>(ExTraceGlobals.RequestsTracer, null, "AuthzAuthorization.ResourceManagerHandle static instance loaded", AuthzAuthorization.ResourceManagerHandle);
            AirSyncSyncStateTypeFactory.EnsureSyncStateTypesRegistered();
            FolderSyncState.RegisterCustomDataVersioningHandler(new FolderSyncState.HandleCustomDataVersioningDelegate(FolderSyncStateCustomDataInfo.HandlerCustomDataVersioning));
            FolderHierarchySyncState.RegisterCustomDataVersioningHandler(new FolderHierarchySyncState.HandleCustomDataVersioningDelegate(FolderHierarchySyncStateCustomDataInfo.HandlerCustomDataVersioning));
            EventQueue.PollingInterval = GlobalSettings.EventQueuePollingInterval;
            this.resetAutoBlockedDeviceCounterTimer = new Timer(new TimerCallback(Global.ResetAutoBlockedDeviceCounter), null, 86400000, 86400000);
        }
        internal static void HandlerCustomDataVersioning(FolderHierarchySyncState syncState)
        {
            if (syncState == null)
            {
                throw new ArgumentNullException("syncState");
            }
            if (syncState.CustomVersion == null)
            {
                return;
            }
            bool flag = true;

            if (syncState.CustomVersion < 2 || syncState.CustomVersion > 5)
            {
                flag = false;
            }
            else if (syncState.CustomVersion.Value != 5)
            {
                int valueOrDefault = syncState.CustomVersion.GetValueOrDefault();
                int?num;
                if (num != null)
                {
                    switch (valueOrDefault)
                    {
                    case 2:
                        syncState["RecoverySyncKey"] = new Int32Data(0);
                        break;

                    case 3:
                        break;

                    case 4:
                        goto IL_DD;

                    default:
                        goto IL_11E;
                    }
                    syncState[CustomStateDatumType.AirSyncProtocolVersion] = new ConstStringData(StaticStringPool.Instance.Intern("2.0"));
IL_DD:
                    object obj = syncState[CustomStateDatumType.AirSyncProtocolVersion];
                    if (obj is ConstStringData)
                    {
                        string data  = syncState.GetData <ConstStringData, string>(CustomStateDatumType.AirSyncProtocolVersion, null);
                        int    data2 = 20;
                        if (data != null)
                        {
                            data2 = AirSyncUtility.ParseVersionString(data);
                        }
                        syncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data(data2);
                        goto IL_120;
                    }
                    goto IL_120;
                }
IL_11E:
                flag = false;
            }
IL_120:
            if (!flag)
            {
                syncState.HandleCorruptSyncState();
            }
        }
        // Token: 0x0600088E RID: 2190 RVA: 0x00032DC8 File Offset: 0x00030FC8
        private void LoadSyncState(int syncKey)
        {
            FolderIdMappingSyncStateInfo syncStateInfo = new FolderIdMappingSyncStateInfo();

            if (syncKey == 0)
            {
                base.SendServerUpgradeHeader  = true;
                this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
                if (this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
                {
                    CustomSyncState customSyncState = base.SyncStateStorage.GetCustomSyncState(new GlobalSyncStateInfo(), new PropertyDefinition[0]);
                    if (customSyncState == null)
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Could not find policy sync state.  Deleting all sync states.");
                        base.SyncStateStorage.DeleteAllSyncStates();
                    }
                    else
                    {
                        customSyncState.Dispose();
                        using (FolderHierarchySyncState folderHierarchySyncState = base.SyncStateStorage.GetFolderHierarchySyncState())
                        {
                            if (folderHierarchySyncState != null)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Deleting all sync states.");
                                base.SyncStateStorage.DeleteAllSyncStates();
                            }
                        }
                    }
                    this.folderIdMappingSyncState = base.SyncStateStorage.CreateCustomSyncState(syncStateInfo);
                    this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] = new FolderIdMapping();
                    this.folderHierarchySyncState = base.SyncStateStorage.CreateFolderHierarchySyncState();
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Deleting folder hierarchy sync state.");
                    base.SyncStateStorage.DeleteFolderHierarchySyncState();
                    this.folderHierarchySyncState = base.SyncStateStorage.CreateFolderHierarchySyncState();
                    ((FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping]).CommitChanges();
                }
                this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree]         = new FolderTree();
                this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                base.InitializeSyncStatusSyncState();
                base.SyncStatusSyncData.ClearClientCategoryHash();
                this.shouldSaveSyncStatus = true;
                Interlocked.Exchange(ref this.validToCommitSyncStatusSyncState, 1);
            }
            else
            {
                this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
                this.folderHierarchySyncState = base.SyncStateStorage.GetFolderHierarchySyncState();
                if (this.folderHierarchySyncState == null || this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoHierarchyState");
                    throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                }
                FolderIdMapping   folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
                StoreObjectId     defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
                MailboxSyncItemId mailboxId       = MailboxSyncItemId.CreateForNewItem(defaultFolderId);
                if (!folderIdMapping.Contains(mailboxId))
                {
                    base.SyncStateStorage.DeleteAllSyncStates();
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InboxStoreObjectIdChanged");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateCorrupt, new LocalizedString("The sync state is corrupt.  It is most likely due to a recent mailbox migration."), false);
                }
            }
            if (this.folderHierarchySyncState.CustomVersion != null && this.folderHierarchySyncState.CustomVersion.Value > 5)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SyncStateVersionMismatch");
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateVersionInvalid, EASServerStrings.MismatchSyncStateError, true);
            }
        }