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)); }
// Token: 0x060000B6 RID: 182 RVA: 0x000077F0 File Offset: 0x000059F0 private static void ReadStaticADData(ProtocolLogger logger) { if (!ADDeviceManager.initialized) { lock (ADDeviceManager.syncLock) { if (!ADDeviceManager.initialized) { ITopologyConfigurationSession configSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 587, "ReadStaticADData", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADDeviceManager.cs"); configSession.UseConfigNC = false; configSession.UseGlobalCatalog = true; ADGroup exchangeServersGroup = null; ADNotificationAdapter.RunADOperation(delegate() { exchangeServersGroup = configSession.ResolveWellKnownGuid <ADGroup>(WellKnownGuid.ExSWkGuid, configSession.ConfigurationNamingContext); }); if (exchangeServersGroup == null) { throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, EASServerStrings.FailedToResolveWellKnownGuid(WellKnownGuid.ExSWkGuid.ToString(), "Exchange Server Security Group"), true) { ErrorStringForProtocolLogger = "ExSrvGrpSchemaGuidNotFound" }; } ADDeviceManager.exchangeServersGroupSid = exchangeServersGroup.Sid; if (logger != null) { logger.SetValue(ProtocolLoggerData.DomainController, configSession.LastUsedDc); } configSession.UseGlobalCatalog = false; ADSchemaClassObject[] objClass = null; ADNotificationAdapter.RunADOperation(delegate() { objClass = configSession.Find <ADSchemaClassObject>(configSession.SchemaNamingContext, QueryScope.OneLevel, new ComparisonFilter(ComparisonOperator.Equal, ADSchemaObjectSchema.DisplayName, "msExchActiveSyncDevice"), ADDeviceManager.defaultSortOrder, 2); }); if (objClass == null || objClass.Length == 0 || objClass[0].SchemaIDGuid == Guid.Empty) { throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, EASServerStrings.CannotFindSchemaClassException("msExchActiveSyncDevice", configSession.SchemaNamingContext.DistinguishedName), true); } if (objClass.Length > 1 && logger != null) { logger.SetValue(ProtocolLoggerData.Error, "DisplayNameIsNotUniqueForClassMsExchActiveSyncDevice"); } ADDeviceManager.activeSyncDeviceClass = objClass[0].SchemaIDGuid; if (logger != null) { logger.SetValue(ProtocolLoggerData.DomainController, configSession.LastUsedDc); } ADDeviceManager.initialized = true; } } } }
internal static ActiveSyncMiniRecipient TryGetADUser(IAirSyncUser user, ProtocolLogger logger) { ADUserCache.< > c__DisplayClass1 CS$ < > 8__locals1 = new ADUserCache.< > c__DisplayClass1(); AirSyncDiagnostics.Assert(user != null, "IAirSyncUser cannot be null in GetADUser", new object[0]); CS$ < > 8__locals1.sid2 = user.ClientSecurityContextWrapper.UserSid; ActiveSyncMiniRecipient activeSyncMiniRecipient = null; if (!GlobalSettings.DisableCaching && ADUserCache.TryGetADUser(CS$ < > 8__locals1.sid2.Value, out activeSyncMiniRecipient)) { return(activeSyncMiniRecipient); } string value = user.Name; if (GlobalSettings.IsWindowsLiveIDEnabled) { value = user.WindowsLiveId; } if (string.IsNullOrEmpty(value)) { logger.SetValue(ProtocolLoggerData.Error, "BadAuthUsername"); throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false); } AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUser:: user IdentityType {0}", user.Identity.GetType().FullName); ADSessionSettings sessionSettings = ADUserCache.GetSessionSettings(GlobalSettings.IsMultiTenancyEnabled ? (user.Identity as LiveIDIdentity).UserOrganizationId : OrganizationId.ForestWideOrgId, logger); IRecipientSession recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, 0, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 124, "TryGetADUser", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADUserCache.cs"); ActiveSyncMiniRecipient recipient = null; ADNotificationAdapter.RunADOperation(delegate() { recipient = recipientSession.FindMiniRecipientBySid <ActiveSyncMiniRecipient>(CS$ < > 8__locals1.sid2, ObjectSchema.GetInstance <ClientAccessRulesRecipientFilterSchema>().AllProperties); }); logger.SetValue(ProtocolLoggerData.DomainController, recipientSession.LastUsedDc); if (recipient == null) { AirSyncDiagnostics.TraceDebug <SecurityIdentifier>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUserFromSid can't find ActiveSyncMiniRecipient for sid {0}", CS$ < > 8__locals1.sid2); return(null); } activeSyncMiniRecipient = ((recipient.RecipientType == RecipientType.UserMailbox || recipient.RecipientType == RecipientType.MailUser) ? recipient : null); if (activeSyncMiniRecipient == null) { AirSyncDiagnostics.TraceDebug <RecipientType>(ExTraceGlobals.RequestsTracer, null, "ADUserCache.TryGetADUserFromSid recipient type is {0} when expected UserMailbox/MailUser", recipient.RecipientType); return(null); } if (!GlobalSettings.DisableCaching) { ADUserCache.AddADUserToCache(CS$ < > 8__locals1.sid2.Value, activeSyncMiniRecipient); } return(activeSyncMiniRecipient); }
// 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); }
private static void HandleMultipleDefaultPolicies(MobileMailboxPolicy[] defaultPolicies, ADObjectId organizationalUnitRoot, ProtocolLogger protocollogger) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < defaultPolicies.Length; i++) { if (i != 0) { stringBuilder.Append(","); } stringBuilder.Append(defaultPolicies[i].Identity); } AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_MultipleDefaultMobileMailboxPoliciesDetected, "MultipleDefaultMobileMailboxPoliciesDetected", new string[] { organizationalUnitRoot.Parent.Name, stringBuilder.ToString() }); protocollogger.SetValue(ProtocolLoggerData.Error, "MultipleDefaultPoliciesDetected"); }
// Token: 0x06000AAA RID: 2730 RVA: 0x0003B168 File Offset: 0x00039368 public static GlobalInfo LoadFromMailbox(MailboxSession mailboxSession, SyncStateStorage syncStateStorage, ProtocolLogger protocolLogger, out bool updateUserHasPartnership) { if (mailboxSession == null) { throw new ArgumentNullException("mailboxSession"); } if (syncStateStorage == null) { throw new ArgumentNullException("syncStateStorage"); } updateUserHasPartnership = false; CustomSyncState customSyncState = null; GlobalInfo globalInfo = null; bool isDirty = false; bool hasNewSyncData = false; bool hasNewAutdData = false; bool isSyncStateJustUpgraded = false; bool flag = false; GlobalInfo result; try { GlobalSyncStateInfo syncStateInfo = new GlobalSyncStateInfo(); customSyncState = syncStateStorage.GetCustomSyncState(syncStateInfo, GlobalInfo.ExtraGlobalInfoPropertiesToFetch); if (customSyncState == null) { isDirty = true; using (CustomSyncState customSyncState2 = syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0])) { if (customSyncState2 == null) { updateUserHasPartnership = true; syncStateStorage.DeleteAllSyncStates(); } } customSyncState = syncStateStorage.CreateCustomSyncState(syncStateInfo); isDirty = true; } else { try { object obj = customSyncState.StoreObject.TryGetProperty(AirSyncStateSchema.LastSyncAttemptTime); hasNewSyncData = (obj != null && !(obj is PropertyError)); } catch (Exception arg) { AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, null, "[GlobalInfo.LoadFromMailbox] Encountered exception when checking for new syncStatus properties. Exception: {0}", arg); } try { object obj2 = customSyncState.StoreObject.TryGetProperty(AirSyncStateSchema.LastPingHeartbeatInterval); hasNewAutdData = (obj2 != null && !(obj2 is PropertyError)); } catch (Exception arg2) { AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, null, "[GlobalInfo.LoadFromMailbox] Encountered exception when checking for new syncStatus properties. Exception: {0}", arg2); } if (customSyncState.BackendVersion != null && customSyncState.BackendVersion.Value != customSyncState.Version) { isDirty = true; isSyncStateJustUpgraded = true; if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.Ssu, "2007"); } } } globalInfo = new GlobalInfo(customSyncState); globalInfo.IsDirty = isDirty; globalInfo.HasNewSyncData = hasNewSyncData; globalInfo.HasNewAutdData = hasNewAutdData; globalInfo.IsSyncStateJustUpgraded = isSyncStateJustUpgraded; if (Command.CurrentCommand != null) { globalInfo.WriteNewSyncData = Command.CurrentCommand.User.Features.IsEnabled(EasFeature.SyncStatusOnGlobalInfo); } flag = true; result = globalInfo; } finally { if (!flag) { if (globalInfo != null) { globalInfo.Dispose(); } else if (customSyncState != null) { customSyncState.Dispose(); } } } return(result); }