コード例 #1
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);
 }
コード例 #2
0
        public static object ConvertValueFromString(string valueToConvert, Type destinationType, string propName, object defaultValue)
        {
            if (string.IsNullOrEmpty(valueToConvert))
            {
                return(defaultValue);
            }
            bool flag;

            if (destinationType == typeof(bool) && bool.TryParse(valueToConvert, out flag))
            {
                return(flag);
            }
            object result;

            if (destinationType.IsEnum && EnumValidator.TryParse(destinationType, valueToConvert, EnumParseOptions.Default, out result))
            {
                return(result);
            }
            if (destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                bool flag2 = valueToConvert == null || "null".Equals(valueToConvert, StringComparison.OrdinalIgnoreCase) || "$null".Equals(valueToConvert, StringComparison.OrdinalIgnoreCase);
                if (flag2)
                {
                    return(null);
                }
            }
            object result2;

            try
            {
                result2 = LanguagePrimitives.ConvertTo(valueToConvert, destinationType);
            }
            catch (PSInvalidCastException)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueNotParsable, new string[]
                {
                    propName,
                    destinationType.Name,
                    valueToConvert,
                    defaultValue.ToString()
                });
                result2 = defaultValue;
            }
            return(result2);
        }
コード例 #3
0
        internal object DefaultGetter(GlobalSettingsPropertyDefinition propDef)
        {
            string appSetting = GlobalSettingsSchema.GetAppSetting(propDef);

            if (appSetting == null)
            {
                if (propDef.LogMissingEntries)
                {
                    AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueHasBeenDefaulted, new string[]
                    {
                        propDef.Name,
                        propDef.DefaultValue.ToString()
                    });
                }
                return(propDef.DefaultValue);
            }
            return(GlobalSettingsPropertyDefinition.ConvertValueFromString(propDef, appSetting));
        }
コード例 #4
0
        private static object LoadSetting(GlobalSettingsPropertyDefinition propDef)
        {
            object obj = propDef.Getter(propDef);
            PropertyConstraintViolationError propertyConstraintViolationError = propDef.Validate(obj);

            if (propertyConstraintViolationError != null)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueOutOfRange, new string[]
                {
                    propDef.Name,
                    propDef.ReadConstraint.ToString(),
                    obj.ToString(),
                    propDef.DefaultValue.ToString()
                });
                return(propDef.DefaultValue);
            }
            return(obj);
        }
コード例 #5
0
 // Token: 0x060000B0 RID: 176 RVA: 0x0000716C File Offset: 0x0000536C
 internal void UpdateMobileDevice(MobileDevice mobileDevice, GlobalInfo globalInfo)
 {
     if (mobileDevice == null)
     {
         throw new ArgumentNullException("mobileDevice");
     }
     GlobalInfo.CopyValuesFromGlobalInfo(mobileDevice, globalInfo);
     try
     {
         if (this.user != null)
         {
             mobileDevice.UserDisplayName = this.user.ToString();
         }
         ADNotificationAdapter.RunADOperation(delegate()
         {
             this.session.Save(mobileDevice);
         });
         if (this.protocolLogger != null)
         {
             this.protocolLogger.SetValue(ProtocolLoggerData.DomainController, this.session.LastUsedDc);
         }
     }
     catch (ADOperationException ex)
     {
         DirectoryOperationException ex2 = ex.InnerException as DirectoryOperationException;
         if (ex2 != null && ex2.Response != null && ex2.Response.ResultCode == ResultCode.InsufficientAccessRights)
         {
             AirSyncDiagnostics.TraceDebug <string, ADOperationException>(this.tracer, this, "Failed to save MobileDevice data to Active Directory for \"{0}\". \r\nException:\r\n{1}", this.userName, ex);
             AirSyncDiagnostics.LogEvent(this.directoryAccessDeniedEventTuple, new string[]
             {
                 this.userName
             });
             throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.AccessDenied, ex, false)
                   {
                       ErrorStringForProtocolLogger = ex2.GetType().FullName + ":ADDeviceSaveAccessDenied"
                   };
         }
         throw;
     }
 }
コード例 #6
0
        private static T LoadSetting <T>(GlobalSettingsPropertyDefinition propDef)
        {
            if (propDef.Type != typeof(T))
            {
                throw new ArgumentException(string.Format("Property {0} is not of the correct type {1}, but is a {2} property", propDef.Name, typeof(T).Name, propDef.Type.Name));
            }
            object obj = propDef.Getter(propDef);
            PropertyConstraintViolationError propertyConstraintViolationError = propDef.Validate(obj);

            if (propertyConstraintViolationError != null)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueOutOfRange, new string[]
                {
                    propDef.Name,
                    propDef.ReadConstraint.ToString(),
                    obj.ToString(),
                    propDef.DefaultValue.ToString()
                });
                return((T)((object)propDef.DefaultValue));
            }
            return((T)((object)obj));
        }
コード例 #7
0
        public static HeartBeatInterval Read()
        {
            string text  = GlobalSettingsSchema.GetAppSetting(GlobalSettingsSchema.Supporting_MinHeartbeatInterval);
            string text2 = GlobalSettingsSchema.GetAppSetting(GlobalSettingsSchema.Supporting_MaxHeartbeatInterval);

            if (string.IsNullOrEmpty(text))
            {
                text = 60.ToString();
            }
            if (string.IsNullOrEmpty(text2))
            {
                text2 = 3540.ToString();
            }
            int num;

            if (!int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueNotParsable, new string[]
                {
                    "MinHeartbeatInterval",
                    typeof(int).Name,
                    text ?? "$null",
                    60.ToString()
                });
                num = 60;
            }
            int num2;

            if (!int.TryParse(text2, NumberStyles.Integer, CultureInfo.InvariantCulture, out num2))
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_GlobalValueNotParsable, new string[]
                {
                    "MaxHeartbeatInterval",
                    typeof(int).Name,
                    text2 ?? "$null",
                    3540.ToString()
                });
                num2 = 3540;
            }
            if (num > num2)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_InvalidHbiLimits, new string[]
                {
                    60.ToString(CultureInfo.InvariantCulture),
                    3540.ToString(CultureInfo.InvariantCulture)
                });
                num  = 60;
                num2 = 3540;
            }
            else if (num2 > 3540)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_MaxHbiTooHigh, new string[]
                {
                    3540.ToString(CultureInfo.InvariantCulture),
                    3540.ToString(CultureInfo.InvariantCulture),
                    60.ToString(CultureInfo.InvariantCulture)
                });
                num  = 60;
                num2 = 3540;
            }
            else if (num < 1)
            {
                AirSyncDiagnostics.LogEvent(AirSyncEventLogConstants.Tuple_MinHbiTooLow, new string[]
                {
                    60.ToString(CultureInfo.InvariantCulture),
                    3540.ToString(CultureInfo.InvariantCulture)
                });
                num  = 60;
                num2 = 3540;
            }
            return(new HeartBeatInterval(num, num2));
        }
コード例 #8
0
        // Token: 0x060000B8 RID: 184 RVA: 0x00007D00 File Offset: 0x00005F00
        private MobileDevice CreateMobileDevice(GlobalInfo globalInfo, ExDateTime syncStorageCreationTime, bool checkForMaxDevices, bool retryIfFailed, MailboxSession mailboxSession)
        {
            ActiveSyncDevices activeSyncDevices = this.GetActiveSyncDeviceContainer();

            if (activeSyncDevices == null)
            {
                activeSyncDevices = this.CreateActiveSyncDeviceContainer(true);
            }
            AirSyncDiagnostics.TraceInfo <MobileClientType, DeviceIdentity, string>(ExTraceGlobals.RequestsTracer, null, "ADDeviceManager::CreateMobileDevice - ClientType: {0}, DeviceIdentity: {1}, mailboxSession from: {2}", this.clientType, this.deviceIdentity, (mailboxSession == null) ? "CurrentCommand" : "parameter");
            this.CleanUpOldDevices(mailboxSession ?? Command.CurrentCommand.MailboxSession);
            MobileDevice      mobileDevice     = this.InternalCreateDevice(globalInfo, syncStorageCreationTime);
            IThrottlingPolicy throttlingPolicy = (this.budget != null) ? this.budget.ThrottlingPolicy : null;

            if (checkForMaxDevices && throttlingPolicy != null)
            {
                if (!throttlingPolicy.EasMaxDevices.IsUnlimited)
                {
                    MobileDevice[] easDevices = null;
                    ADNotificationAdapter.RunADOperation(delegate()
                    {
                        easDevices = this.session.Find <MobileDevice>(MobileDevice.GetRootId(this.userId), QueryScope.OneLevel, new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ADObjectSchema.ExchangeVersion, ExchangeObjectVersion.Exchange2012), null, 0);
                    });
                    if (this.protocolLogger != null)
                    {
                        this.protocolLogger.SetValue(ProtocolLoggerData.DomainController, this.session.LastUsedDc);
                    }
                    if (easDevices != null && (long)easDevices.Length >= (long)((ulong)throttlingPolicy.EasMaxDevices.Value))
                    {
                        this.SendMaxDevicesExceededMailIfNeeded(easDevices.Length, throttlingPolicy.EasMaxDevices.Value);
                        throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.MaximumDevicesReached, null, false)
                              {
                                  ErrorStringForProtocolLogger = "MaxDevicesExceeded"
                              };
                    }
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(this.tracer, this, "throttlingPolicy.EasMaxDevices is unlimited. Skipping max devices check.");
                }
            }
            else
            {
                AirSyncDiagnostics.TraceDebug(this.tracer, this, "No throttling policy is found. Skipping max devices check.");
            }
            switch (mobileDevice.ClientType)
            {
            case MobileClientType.EAS:
                mobileDevice.SetId(activeSyncDevices.Id.GetChildId(ADDeviceManager.EasDeviceCnString(mobileDevice)));
                break;

            case MobileClientType.MOWA:
                mobileDevice.SetId(activeSyncDevices.Id.GetChildId(ADDeviceManager.MowaDeviceCnString(mobileDevice)));
                break;

            default:
                throw new PlatformNotSupportedException("New MobileClientType is not supported.");
            }
            try
            {
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    this.session.Save(mobileDevice);
                });
            }
            catch (ADObjectAlreadyExistsException)
            {
                mobileDevice = this.GetMobileDevice();
                if (mobileDevice == null)
                {
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerErrorRetryLater, EASServerStrings.FailedToCreateNewActiveDevice(this.deviceIdentity.DeviceId, this.deviceIdentity.DeviceType, this.userName), true)
                          {
                              ErrorStringForProtocolLogger = "CreateActiveSyncDevice:ADObjectAlreadyExistsException"
                          };
                }
                if (globalInfo != null)
                {
                    this.UpdateMobileDevice(mobileDevice, globalInfo);
                }
            }
            catch (ADOperationException ex)
            {
                DirectoryOperationException ex2 = ex.InnerException as DirectoryOperationException;
                if (retryIfFailed)
                {
                    if (ex.ErrorCode != 5)
                    {
                        if (ex2 == null || ex2.Response == null || ex2.Response.ResultCode != ResultCode.InsufficientAccessRights)
                        {
                            goto IL_308;
                        }
                    }
                    try
                    {
                        this.SetActiveSyncDeviceContainerPermissions(activeSyncDevices);
                    }
                    catch (ADOperationException ex3)
                    {
                        throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerErrorRetryLater, EASServerStrings.FailedToApplySecurityToContainer(activeSyncDevices.DistinguishedName), ex3, true)
                              {
                                  ErrorStringForProtocolLogger = "SetEASDevContainerPerms:ADOperationException:" + ex3.Message
                              };
                    }
                    return(this.CreateMobileDevice(globalInfo, syncStorageCreationTime, checkForMaxDevices, false, mailboxSession));
                }
IL_308:
                AirSyncDiagnostics.LogEvent(this.unableToCreateADDeviceEventTuple, new string[]
                {
                    mobileDevice.DeviceType,
                    mobileDevice.DeviceId,
                    activeSyncDevices.Id.ToDNString(),
                    ex.Message
                });
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerErrorRetryLater, ex, false)
                      {
                          ErrorStringForProtocolLogger = "CreateActiveSyncDevice:ADOperationException" + ex.Message
                      };
            }
            return(mobileDevice);
        }