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 static PolicyData LoadPolicySetting(IConfigurationSession scopedSession, IAirSyncUser user, ADObjectId policyId, bool forceLoad) { MobileMailboxPolicy mobileMailboxPolicy = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { mobileMailboxPolicy = scopedSession.Read <MobileMailboxPolicy>(policyId); }); if (!adoperationResult.Succeeded) { AirSyncDiagnostics.TraceDebug <ADObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during LoadPolicySettings {0}. Exception Message - {1}", policyId, adoperationResult.Exception.Message); throw adoperationResult.Exception; } if (user != null) { user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc); } if (mobileMailboxPolicy != null && (forceLoad || mobileMailboxPolicy.IsDefault)) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "LoadPolicySetting from AD"); return(ADNotificationManager.AddPolicyToCache(mobileMailboxPolicy, scopedSession.SessionSettings.CurrentOrganizationId.PartitionId)); } return(null); }