protected override void CheckObjectReadOnly()
        {
            bool isObjectReadOnly = false;
            ExchangeObjectVersion exchangeObjectVersion = ExchangeObjectVersion.Exchange2003;

            foreach (string name in this.dataObjectStore.GetKeys())
            {
                IVersionable versionable = this.dataObjectStore.GetDataObject(name) as IVersionable;
                if (versionable != null && versionable.IsReadOnly)
                {
                    isObjectReadOnly = true;
                }
                if (versionable != null && exchangeObjectVersion.IsOlderThan(versionable.ExchangeVersion))
                {
                    exchangeObjectVersion = versionable.ExchangeVersion;
                }
            }
            base.IsObjectReadOnly = isObjectReadOnly;
            if (base.IsObjectReadOnly)
            {
                base.ObjectReadOnlyReason = Strings.VersionMismatchWarning(exchangeObjectVersion.ExchangeBuild);
                return;
            }
            base.ObjectReadOnlyReason = string.Empty;
        }
        private void EnableControlsByVersion(BindingSource bindingSource, IVersionable dataSource)
        {
            List <Control> list = new List <Control>();

            foreach (Control item in this.removedBindings[bindingSource].Keys)
            {
                list.Add(item);
            }
            foreach (Control control in list)
            {
                List <Binding> list2 = new List <Binding>(this.removedBindings[bindingSource][control]);
                foreach (Binding binding in list2)
                {
                    ExchangeObjectVersion propertyDefinitionVersion = PropertyConstraintProvider.GetPropertyDefinitionVersion(dataSource, binding.BindingMemberInfo.BindingMember);
                    if (!dataSource.ExchangeVersion.IsOlderThan(propertyDefinitionVersion))
                    {
                        control.DataBindings.Add(binding);
                        this.removedBindings[bindingSource][control].Remove(binding);
                        if (this.removedBindings[bindingSource][control].Count == 0)
                        {
                            ISpecifyPropertyState specifyPropertyState = control as ISpecifyPropertyState;
                            if (specifyPropertyState != null)
                            {
                                specifyPropertyState.SetPropertyState(binding.PropertyName, PropertyState.Normal, string.Empty);
                            }
                            else
                            {
                                control.Enabled = true;
                            }
                        }
                    }
                }
            }
        }
        // Token: 0x06000F80 RID: 3968 RVA: 0x0002DF3C File Offset: 0x0002C13C
        protected override void FillProperties(Type type, PSObject psObject, object dummyObject, IList <string> properties)
        {
            ConfigurableObject configurableObject = dummyObject as ConfigurableObject;

            if (configurableObject == null)
            {
                throw new ArgumentException("This method only support ConfigurableObject; please override this method if not this type!");
            }
            if (psObject.Members["ExchangeVersion"] != null)
            {
                PropertyBag           propertyBag           = configurableObject.propertyBag;
                ExchangeObjectVersion exchangeObjectVersion = MockObjectCreator.GetPropertyBasedOnDefinition(propertyBag.ObjectVersionPropertyDefinition, psObject.Members["ExchangeVersion"].Value) as ExchangeObjectVersion;
                if (exchangeObjectVersion != null)
                {
                    configurableObject.SetExchangeVersion(exchangeObjectVersion);
                }
            }
            foreach (PSMemberInfo psmemberInfo in psObject.Members)
            {
                if (properties.Contains(psmemberInfo.Name))
                {
                    this.FillProperty(type, psObject, configurableObject, psmemberInfo.Name);
                }
            }
            configurableObject.ResetChangeTracking();
        }
        private void DisableControlsByVersion(BindingSource bindingSource, IVersionable dataSource)
        {
            BindingManagerBase bindingManagerBase = this.ContainerBindingContext[bindingSource];

            for (int i = bindingManagerBase.Bindings.Count - 1; i >= 0; i--)
            {
                Binding binding = bindingManagerBase.Bindings[i];
                ExchangeObjectVersion propertyDefinitionVersion = PropertyConstraintProvider.GetPropertyDefinitionVersion(dataSource, binding.BindingMemberInfo.BindingMember);
                if (dataSource.ExchangeVersion.IsOlderThan(propertyDefinitionVersion))
                {
                    if (!this.removedBindings[bindingSource].ContainsKey(binding.Control))
                    {
                        this.removedBindings[bindingSource][binding.Control] = new List <Binding>();
                    }
                    this.removedBindings[bindingSource][binding.Control].Add(binding);
                    ISpecifyPropertyState specifyPropertyState = binding.Control as ISpecifyPropertyState;
                    if (specifyPropertyState != null)
                    {
                        specifyPropertyState.SetPropertyState(binding.PropertyName, PropertyState.UnsupportedVersion, Strings.FeatureVersionMismatchDescription(propertyDefinitionVersion.ExchangeBuild));
                    }
                    else
                    {
                        binding.Control.Enabled = false;
                    }
                    binding.Control.DataBindings.Remove(binding);
                }
            }
        }
        private static bool ValidateExchangeObjectVersion(ExchangeObjectVersion version, string versionPattern)
        {
            string[] array = versionPattern.Split(new char[]
            {
                '.'
            });
            int[] array2 = new int[]
            {
                (int)version.ExchangeBuild.Major,
                (int)version.ExchangeBuild.Minor,
                (int)version.ExchangeBuild.Build,
                (int)version.ExchangeBuild.BuildRevision
            };
            int num = 0;

            while (num < array.Length && !(array[num] == "*"))
            {
                if (int.Parse(array[num]) != array2[num])
                {
                    return(false);
                }
                num++;
            }
            return(true);
        }
        private SyncPropertyDefinition(string name, string msoPropertyName, ExchangeObjectVersion versionAdded, Type type, Type externalType, string ldapDisplayName, ADPropertyDefinitionFlags flags, SyncPropertyDefinitionFlags syncFlags, ServerVersion syncVersionAdded, object defaultValue, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate, ADPropertyDefinition shadowProperty) : base(name, versionAdded, type, ldapDisplayName, SyncPropertyDefinition.CalculateFlags(ldapDisplayName, (ADPropertyDefinitionFlags)(syncFlags | (SyncPropertyDefinitionFlags)flags)), defaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate, null, null)
        {
            this.externalType             = externalType;
            this.MsoPropertyName          = msoPropertyName;
            this.SyncPropertyVersionAdded = syncVersionAdded;
            SyncPropertyDefinitionFlags syncPropertyDefinitionFlags = syncFlags & ~(SyncPropertyDefinitionFlags.ForwardSync | SyncPropertyDefinitionFlags.BackSync);

            syncPropertyDefinitionFlags |= SyncPropertyDefinitionFlags.Shadow;
            if (shadowProperty != null)
            {
                Type type2 = shadowProperty.Type;
                if (type2 == typeof(ADObjectId))
                {
                    type2 = typeof(SyncLink);
                }
                this.shadowProperty = new SyncPropertyDefinition(shadowProperty, msoPropertyName, type2, externalType, syncPropertyDefinitionFlags, syncVersionAdded);
                return;
            }
            if (this.IsBackSync && base.SupportingProperties.Count == 1 && ((ADPropertyDefinition)base.SupportingProperties[0]).ShadowProperty != null)
            {
                this.shadowProperty = new SyncPropertyDefinition(string.Format(CultureInfo.InvariantCulture, "Shadow{0}", new object[]
                {
                    base.Name
                }), msoPropertyName, base.Type, this.ExternalType, syncPropertyDefinitionFlags, syncVersionAdded, base.DefaultValue, new ProviderPropertyDefinition[]
                {
                    ((ADPropertyDefinition)base.SupportingProperties[0]).ShadowProperty
                }, base.GetterDelegate, base.SetterDelegate);
            }
        }
 public static void ValidateAsExchangeVersion(ExchangeObjectVersion exchangeVersion)
 {
     if (exchangeVersion.ExchangeBuild < ExchangeObjectVersion.Exchange2012.ExchangeBuild)
     {
         throw new ConfigurationSettingsUnsupportedVersionException(exchangeVersion.ToString());
     }
 }
Ejemplo n.º 8
0
		protected override void UpgradeExchangeVersion(ADObject adObject)
		{
			string text = (string)adObject[ADMailboxRecipientSchema.ServerLegacyDN];
			if (!string.IsNullOrEmpty(text))
			{
				Server server = base.GlobalConfigSession.FindServerByLegacyDN(text);
				if (server == null)
				{
					base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorServerNotFound(text)), ExchangeErrorCategory.Client, null);
				}
				ExchangeObjectVersion exchangeVersion = ExchangeObjectVersion.Exchange2003;
				if (server.IsE14OrLater)
				{
					ADRecipient adrecipient = adObject as ADRecipient;
					MailEnabledRecipient mailEnabledRecipient = adObject as MailEnabledRecipient;
					RecipientTypeDetails recipientTypeDetails = (adrecipient != null) ? adrecipient.RecipientTypeDetails : ((mailEnabledRecipient != null) ? mailEnabledRecipient.RecipientTypeDetails : RecipientTypeDetails.None);
					exchangeVersion = ADUser.GetMaximumSupportedExchangeObjectVersion(recipientTypeDetails, false);
				}
				else if (server.IsExchange2007OrLater)
				{
					exchangeVersion = ExchangeObjectVersion.Exchange2007;
				}
				adObject.SetExchangeVersion(exchangeVersion);
			}
		}
 public static LocalizedString InvalidOrganizationVersion(string org, ExchangeObjectVersion version)
 {
     return(new LocalizedString("InvalidOrganizationVersion", UpgradeHandlerStrings.ResourceManager, new object[]
     {
         org,
         version
     }));
 }
Ejemplo n.º 10
0
 private static ExchangeObjectVersion GetExchangeObjectVersion(ConfigDiagnosticArgument argument, string argumentName)
 {
     if (!argument.HasArgument(argumentName))
     {
         return(null);
     }
     return(ExchangeObjectVersion.Parse(argument.GetArgument <string>(argumentName)));
 }
Ejemplo n.º 11
0
 public static void Convert(DataRow dataRow)
 {
     foreach (object obj in dataRow.Table.Columns)
     {
         DataColumn dataColumn = (DataColumn)obj;
         Type       type       = dataColumn.ExtendedProperties["ExpectedType"] as Type;
         string     text       = dataRow[dataColumn] as string;
         if (type != null && dataRow[dataColumn].GetType() != type && text != null)
         {
             if (type == typeof(Unlimited <int>))
             {
                 dataRow[dataColumn] = Unlimited <int> .Parse(text);
             }
             else if (type == typeof(Unlimited <EnhancedTimeSpan>))
             {
                 dataRow[dataColumn] = Unlimited <EnhancedTimeSpan> .Parse(text);
             }
             else if (type == typeof(EmailAddressPolicyPriority))
             {
                 dataRow[dataColumn] = EmailAddressPolicyPriority.Parse(text);
             }
             else if (type == typeof(SmtpDomainWithSubdomains))
             {
                 dataRow[dataColumn] = SmtpDomainWithSubdomains.Parse(text);
             }
             else if (type == typeof(SmtpAddress))
             {
                 dataRow[dataColumn] = SmtpAddress.Parse(text);
             }
             else if (type == typeof(ProxyAddress))
             {
                 dataRow[dataColumn] = ProxyAddress.Parse(text);
             }
             else if (type == typeof(MailboxId))
             {
                 dataRow[dataColumn] = MailboxId.Parse(text);
             }
             else if (type == typeof(UMLanguage))
             {
                 dataRow[dataColumn] = UMLanguage.Parse(text);
             }
             else
             {
                 if (!(type == typeof(ExchangeObjectVersion)))
                 {
                     throw new ArgumentException(string.Format("Type {0} is not supported convert from string yet", type));
                 }
                 Regex regex = new Regex("^(?<Major>\\d+)\\.(?<Minor>\\d+) \\((?<buildMajor>\\d+)\\.(?<buildMinor>\\d+)\\.(?<buildVersion>\\d+)\\.(?<buildRevison>\\d+)\\)$");
                 Match match = regex.Match(text);
                 if (!match.Success)
                 {
                     throw new ArgumentException(string.Format("{0} is not a valid ExchangeObjectVersion", text));
                 }
                 dataRow[dataColumn] = new ExchangeObjectVersion(byte.Parse(match.Result("${Major}")), byte.Parse(match.Result("${Minor}")), byte.Parse(match.Result("${buildMajor}")), byte.Parse(match.Result("${buildMinor}")), ushort.Parse(match.Result("${buildVersion}")), ushort.Parse(match.Result("${buildRevison}")));
             }
         }
     }
 }
Ejemplo n.º 12
0
 public InvalidOrganizationStateException(string org, string servicePlan, ExchangeObjectVersion version, bool isUpgrading, bool isPiloting, bool isUpgradeInProgress, Exception innerException) : base(UpgradeHandlerStrings.InvalidOrganizationState(org, servicePlan, version, isUpgrading, isPiloting, isUpgradeInProgress), innerException)
 {
     this.org                 = org;
     this.servicePlan         = servicePlan;
     this.version             = version;
     this.isUpgrading         = isUpgrading;
     this.isPiloting          = isPiloting;
     this.isUpgradeInProgress = isUpgradeInProgress;
 }
Ejemplo n.º 13
0
 public TenantData(Guid tenantId, string tenantName, string servicePlan, ExchangeObjectVersion version, bool isUpgradingOrganization, bool isPilotingOrganization, string[] constraints)
 {
     this.TenantId                = tenantId;
     this.TenantName              = tenantName;
     this.ServicePlan             = servicePlan;
     this.Constraints             = constraints;
     this.Version                 = version;
     this.IsUpgradingOrganization = isUpgradingOrganization;
     this.IsPilotingOrganization  = isPilotingOrganization;
 }
        private void bindingSource_ListChanged(object sender, ListChangedEventArgs e)
        {
            BindingSource bindingSource = (BindingSource)sender;
            IVersionable  versionable   = bindingSource.DataSource as IVersionable;

            if (versionable != null)
            {
                if (!this.datasourceVersions.ContainsKey(bindingSource))
                {
                    this.datasourceVersions[bindingSource] = versionable.ExchangeVersion;
                    this.DisableControlsByVersion(bindingSource, versionable);
                    return;
                }
                ExchangeObjectVersion exchangeObjectVersion = this.datasourceVersions[bindingSource];
                if (!exchangeObjectVersion.IsSameVersion(versionable.ExchangeVersion))
                {
                    this.datasourceVersions[bindingSource] = versionable.ExchangeVersion;
                    this.EnableControlsByVersion(bindingSource, versionable);
                    return;
                }
            }
            else
            {
                DataTable dataTable = bindingSource.DataSource as DataTable;
                if (dataTable != null)
                {
                    DataObjectStore dataObjectStore = dataTable.ExtendedProperties["DataSourceStore"] as DataObjectStore;
                    if (dataObjectStore != null)
                    {
                        foreach (string text in dataObjectStore.GetKeys())
                        {
                            IVersionable versionable2 = dataObjectStore.GetDataObject(text) as IVersionable;
                            if (versionable2 != null)
                            {
                                if (this.dataSourceInTableVersions.ContainsKey(text))
                                {
                                    ExchangeObjectVersion exchangeObjectVersion2 = this.dataSourceInTableVersions[text];
                                    if (!exchangeObjectVersion2.IsSameVersion(versionable2.ExchangeVersion))
                                    {
                                        this.dataSourceInTableVersions[text] = versionable2.ExchangeVersion;
                                        this.EnableControlsByVersion(bindingSource, versionable2);
                                    }
                                }
                                else
                                {
                                    this.dataSourceInTableVersions[text] = versionable2.ExchangeVersion;
                                    this.DisableControlsByVersion(bindingSource, versionable2);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        // Token: 0x060005CC RID: 1484 RVA: 0x0001614C File Offset: 0x0001434C
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            OrganizationId currentOrganizationId = base.CurrentOrganizationId;
            TDataObject    dataObject            = this.DataObject;

            if (!currentOrganizationId.Equals(dataObject.OrganizationId))
            {
                this.CurrentOrgState = new LazilyInitialized <SharedTenantConfigurationState>(delegate()
                {
                    TDataObject dataObject8 = this.DataObject;
                    return(SharedConfiguration.GetSharedConfigurationState(dataObject8.OrganizationId));
                });
            }
            if (SharedConfigurationTaskHelper.ShouldPrompt(this, this.SharedTenantConfigurationMode, this.CurrentOrgState) && !base.InternalForce)
            {
                TDataObject dataObject2 = this.DataObject;
                if (!base.ShouldContinue(Strings.ConfirmSharedConfiguration(dataObject2.OrganizationId.OrganizationalUnit.Name)))
                {
                    TaskLogger.LogExit();
                    return;
                }
            }
            TDataObject dataObject3 = this.DataObject;

            if (dataObject3.IsChanged(ADObjectSchema.Id))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, base.OrgWideSessionSettings, ConfigScopes.TenantSubTree, 702, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\SetAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                TDataObject dataObject4 = this.DataObject;
                ADObjectId  parent      = dataObject4.Id.Parent;
                ADRawEntry  adrawEntry  = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion,
                    ADObjectSchema.ObjectClass
                });
                ExchangeObjectVersion        exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                MultiValuedProperty <string> multiValuedProperty   = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass];
                TDataObject dataObject5 = this.DataObject;
                if (dataObject5.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass))
                {
                    TDataObject dataObject6 = this.DataObject;
                    string      name        = dataObject6.Name;
                    TDataObject dataObject7 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject7.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
Ejemplo n.º 16
0
        internal static object DiffRetentionPeriodGetter(IPropertyBag propertyBag)
        {
            Unlimited <int> unlimited = (Unlimited <int>)propertyBag[OfflineAddressBookSchema.RawDiffRetentionPeriod];

            if (unlimited.IsUnlimited)
            {
                ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)propertyBag[ADObjectSchema.ExchangeVersion];
                if (exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2007))
                {
                    return(null);
                }
            }
            return(unlimited);
        }
        internal static ExchangeObjectVersion GetPropertyDefinitionVersion(IVersionable versionableObject, string propertyName)
        {
            ExchangeObjectVersion result = ExchangeObjectVersion.Exchange2003;

            if (versionableObject != null && versionableObject.ObjectSchema != null)
            {
                FieldInfo field = versionableObject.ObjectSchema.GetType().GetField(propertyName, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                if (null != field)
                {
                    ProviderPropertyDefinition providerPropertyDefinition = (ProviderPropertyDefinition)field.GetValue(null);
                    result = providerPropertyDefinition.VersionAdded;
                }
            }
            return(result);
        }
Ejemplo n.º 18
0
        public override void BuildFilter(out string parameterList, out string filter, out string preArgs, DataRow row)
        {
            base.BuildFilter(out parameterList, out filter, out preArgs, row);
            ExchangeObjectVersion exchangeObjectVersion = null;

            if (!DBNull.Value.Equals(row["MinVersion"]))
            {
                exchangeObjectVersion = (row["MinVersion"] as ExchangeObjectVersion);
            }
            if (exchangeObjectVersion != null)
            {
                string text = string.Format(" | Filter-Mailbox -Value {0}", exchangeObjectVersion.ToInt64());
                filter = ((filter == null) ? text : (filter + text));
            }
        }
        private static bool TryParseExchangeVersion(string version, out ExchangeObjectVersion exchangeVersion)
        {
            exchangeVersion = null;
            bool result;

            try
            {
                exchangeVersion = ExchangeObjectVersion.Parse(version);
                result          = true;
            }
            catch (ArgumentException)
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 20
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            TDataObject       dataObject        = this.DataObject;
            ADObjectId        parent            = dataObject.Id.Parent;
            ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(parent);

            if (!parent.Equals(ADSession.GetRootDomainNamingContext(adsessionSettings.GetAccountOrResourceForestFqdn())))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 264, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                ADRawEntry adrawEntry = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion,
                    ADObjectSchema.ObjectClass
                });
                if (adrawEntry == null)
                {
                    if (string.IsNullOrEmpty(base.DomainController))
                    {
                        TDataObject dataObject2 = this.DataObject;
                        base.WriteError(new TaskException(Strings.ErrorParentNotFound(dataObject2.Name, parent.ToString())), (ErrorCategory)1003, null);
                    }
                    else
                    {
                        TDataObject dataObject3 = this.DataObject;
                        base.WriteError(new TaskException(Strings.ErrorParentNotFoundOnDomainController(dataObject3.Name, base.DomainController, parent.ToString(), parent.DomainId.ToString())), (ErrorCategory)1003, null);
                    }
                }
                ExchangeObjectVersion        exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                MultiValuedProperty <string> multiValuedProperty   = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass];
                TDataObject dataObject4 = this.DataObject;
                if (dataObject4.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass) && this.EnforceExchangeObjectVersion)
                {
                    TDataObject dataObject5 = this.DataObject;
                    string      name        = dataObject5.Name;
                    TDataObject dataObject6 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject6.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(this.DataObject));
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
Ejemplo n.º 21
0
        private T ObjectFromItem <T>(Item item) where T : IConfigurable, new()
        {
            EwsStoreObject        ewsStoreObject  = (EwsStoreObject)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));
            object                originalValue   = null;
            ExchangeObjectVersion exchangeVersion = (ExchangeObjectVersion)EwsStoreObjectSchema.ExchangeVersion.DefaultValue;

            if (item.TryGetProperty(EwsStoreObjectSchema.ExchangeVersion.StorePropertyDefinition, ref originalValue))
            {
                exchangeVersion = (ExchangeObjectVersion)ValueConvertor.ConvertValue(originalValue, typeof(ExchangeObjectVersion), null);
                ewsStoreObject.SetExchangeVersion(exchangeVersion);
                if (ewsStoreObject.ExchangeVersion.Major > ewsStoreObject.MaximumSupportedExchangeObjectVersion.Major)
                {
                    ExTraceGlobals.StorageTracer.TraceWarning <ItemId, byte, byte>(0L, "{0} has major version {1} which is greater than current one ({2}) and will be ignored", item.Id, ewsStoreObject.ExchangeVersion.Major, ewsStoreObject.MaximumSupportedExchangeObjectVersion.Major);
                    return(default(T));
                }
            }
            if (!string.IsNullOrEmpty(ewsStoreObject.ItemClass) && !ewsStoreObject.ItemClass.Equals(item.ItemClass, StringComparison.OrdinalIgnoreCase))
            {
                return(default(T));
            }
            ewsStoreObject.CopyFromItemObject(item, this.RequestedServerVersion);
            if (ewsStoreObject.MaximumSupportedExchangeObjectVersion.IsOlderThan(ewsStoreObject.ExchangeVersion))
            {
                ExTraceGlobals.StorageTracer.TraceWarning <ItemId, ExchangeObjectVersion, ExchangeObjectVersion>(0L, "{0} has version {1} which is greater than current one ({2}) and will be read-only", item.Id, ewsStoreObject.ExchangeVersion, ewsStoreObject.MaximumSupportedExchangeObjectVersion);
                ewsStoreObject.SetIsReadOnly(true);
            }
            ValidationError[] array = ewsStoreObject.ValidateRead();
            ewsStoreObject.ResetChangeTracking(true);
            if (array.Length > 0)
            {
                foreach (ValidationError validationError in array)
                {
                    PropertyValidationError propertyValidationError = validationError as PropertyValidationError;
                    ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "Object '{0}' read from '{1}' failed validation. Attribute: '{2}'. Invalid data: '{3}'. Error message: '{4}'.", new object[]
                    {
                        ewsStoreObject.Identity,
                        this.Mailbox.ToString() + "\\" + this.DefaultFolder.ToString(),
                        (propertyValidationError != null) ? propertyValidationError.PropertyDefinition.Name : "<null>",
                        (propertyValidationError != null) ? (propertyValidationError.InvalidData ?? "<null>") : "<null>",
                        validationError.Description
                    });
                }
            }
            return((T)((object)this.FilterObject(ewsStoreObject)));
        }
 private void ClearNewAttributesForOldExchange(OfflineAddressBook dataObject, ExchangeObjectVersion version)
 {
     foreach (PropertyDefinition propertyDefinition in dataObject.Schema.AllProperties)
     {
         ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition;
         if (((version.IsOlderThan(adpropertyDefinition.VersionAdded) && !adpropertyDefinition.IsCalculated) || (version == ExchangeObjectVersion.Exchange2007 && adpropertyDefinition == OfflineAddressBookSchema.ANRProperties) || (version == ExchangeObjectVersion.Exchange2007 && adpropertyDefinition == OfflineAddressBookSchema.DetailsProperties) || (version == ExchangeObjectVersion.Exchange2007 && adpropertyDefinition == OfflineAddressBookSchema.TruncatedProperties)) && !dataObject.ExchangeVersion.IsOlderThan(adpropertyDefinition.VersionAdded))
         {
             if (adpropertyDefinition.IsMultivalued)
             {
                 ((MultiValuedPropertyBase)dataObject[adpropertyDefinition]).Clear();
             }
             else
             {
                 dataObject[adpropertyDefinition] = null;
             }
         }
     }
 }
Ejemplo n.º 23
0
 public EwsStoreObjectPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, object initialValue, PropertyDefinitionBase storePropertyDefinition, Action <Item, object> itemPropertySetter) : base(name, versionAdded ?? EwsHelper.EwsVersionToExchangeObjectVersion(storePropertyDefinition.Version), type, flags, defaultValue, initialValue)
 {
     if (storePropertyDefinition == null)
     {
         throw new ArgumentNullException("storePropertyDefinition");
     }
     if (storePropertyDefinition is PropertyDefinition)
     {
         if (itemPropertySetter == null && !this.IsReadOnly && storePropertyDefinition != ItemSchema.Attachments)
         {
             throw new ArgumentException("ItemPropertySetter must be provided for writable first class property.");
         }
     }
     else if (storePropertyDefinition is ExtendedPropertyDefinition && itemPropertySetter != null)
     {
         throw new ArgumentException("ItemPropertySetter shouldn't be provided for extended property.");
     }
     this.storePropertyDefinition = storePropertyDefinition;
     this.ItemPropertySetter      = itemPropertySetter;
 }
Ejemplo n.º 24
0
        // Token: 0x06000C15 RID: 3093 RVA: 0x0004EEF0 File Offset: 0x0004D0F0
        private RoutingAddress[] FilterByServerVersionAndLookupDisplayName(RoutingAddress[] routingAddresses, IRecipientSession recipientSession, string decisionMakerAddress, out string decisionMakerDisplayName)
        {
            List <RoutingAddress> list = new List <RoutingAddress>(routingAddresses.Length);

            ProxyAddress[] array = new ProxyAddress[routingAddresses.Length];
            decisionMakerDisplayName = string.Empty;
            for (int i = 0; i < routingAddresses.Length; i++)
            {
                array[i] = new SmtpProxyAddress(routingAddresses[i].ToString(), true);
            }
            Result <ADRawEntry>[] array2 = recipientSession.FindByProxyAddresses(array, ApprovalAssistant.ExchangeVersionDisplayNameProperties);
            for (int j = 0; j < array2.Length; j++)
            {
                ADRawEntry data = array2[j].Data;
                if (data == null)
                {
                    ApprovalAssistant.GeneralTracer.TraceDebug <RoutingAddress>((long)this.GetHashCode(), "AD entry not found for '{0}', will not send update to this address.", routingAddresses[j]);
                }
                else
                {
                    ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)data[ADObjectSchema.ExchangeVersion];
                    if (exchangeObjectVersion != null && !exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010))
                    {
                        list.Add(routingAddresses[j]);
                        ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)data[ADRecipientSchema.EmailAddresses];
                        foreach (ProxyAddress proxyAddress in proxyAddressCollection)
                        {
                            if (string.Equals(proxyAddress.AddressString, decisionMakerAddress, StringComparison.OrdinalIgnoreCase))
                            {
                                decisionMakerDisplayName = (string)data[ADRecipientSchema.DisplayName];
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Ejemplo n.º 25
0
 internal static ADPropertyDefinition ConfigXmlProperty <T, ValueT>(string propertyName, ExchangeObjectVersion propertyVersion, ADPropertyDefinition configXmlProperty, ValueT defaultValue, Func <T, ValueT> getterDelegate, Action <T, ValueT> setterDelegate, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) where T : XMLSerializableBase, new()
 {
     return(XMLSerializableBase.ConfigXmlProperty <T, ValueT>(propertyName, propertyVersion, configXmlProperty, defaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, getterDelegate, setterDelegate, mservPropertyDefinition, mbxPropertyDefinition));
 }
 // Token: 0x06000ED2 RID: 3794 RVA: 0x00047154 File Offset: 0x00045354
 internal MServPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name, versionAdded, type, flags, defaultValue, readConstraints, writeConstraints, supportingProperties, null, getterDelegate, setterDelegate)
 {
 }
Ejemplo n.º 27
0
 public AdminPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints) : base(name, versionAdded, type, defaultValue, readConstraints, writeConstraints)
 {
 }
Ejemplo n.º 28
0
 public AdminPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, object defaultValue, bool mandatory, bool multiValued, bool readOnly, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints) : base(name, versionAdded, type, defaultValue, readConstraints, writeConstraints)
 {
     this.isMandatory   = mandatory;
     this.isMultivalued = multiValued;
     this.isReadOnly    = readOnly;
 }
Ejemplo n.º 29
0
        internal static ADPropertyDefinition ConfigXmlProperty <T, ValueT>(string propertyName, ExchangeObjectVersion propertyVersion, ADPropertyDefinition configXmlProperty, ValueT defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, Func <T, ValueT> getterDelegate, Action <T, ValueT> setterDelegate, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) where T : XMLSerializableBase, new()
        {
            ADPropertyDefinitionFlags adpropertyDefinitionFlags = ADPropertyDefinitionFlags.Calculated;

            if (setterDelegate == null)
            {
                adpropertyDefinitionFlags |= ADPropertyDefinitionFlags.ReadOnly;
            }
            return(new ADPropertyDefinition(propertyName, propertyVersion, typeof(ValueT), null, adpropertyDefinitionFlags, defaultValue, readConstraints, writeConstraints, configXmlProperty.SupportingProperties.ToArray <ProviderPropertyDefinition>(), null, XMLSerializableBase.XmlElementGetterDelegate <T, ValueT>(getterDelegate, configXmlProperty, defaultValue), (setterDelegate != null) ? XMLSerializableBase.XmlElementSetterDelegate <T, ValueT>(setterDelegate, configXmlProperty) : null, mservPropertyDefinition, mbxPropertyDefinition));
        }
Ejemplo n.º 30
0
        protected static object GetSingleProperty(object prop, Type type)
        {
            if (prop == null)
            {
                return(null);
            }
            object obj = null;

            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]);
            }
            else if (type == typeof(ADObjectId) && prop is PSObject)
            {
                obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString()));
            }
            else if (type == typeof(EnhancedTimeSpan))
            {
                obj = EnhancedTimeSpan.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <EnhancedTimeSpan>))
            {
                obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString());
            }
            else if (type == typeof(ByteQuantifiedSize))
            {
                obj = ByteQuantifiedSize.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <ByteQuantifiedSize>))
            {
                obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <int>))
            {
                obj = Unlimited <int> .Parse(prop.ToString());
            }
            else if (type == typeof(ProxyAddress))
            {
                obj = ProxyAddress.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpAddress))
            {
                obj = new SmtpAddress(prop.ToString());
            }
            else if (type == typeof(SmtpDomain))
            {
                obj = SmtpDomain.Parse(prop.ToString());
            }
            else if (type == typeof(CountryInfo))
            {
                obj = CountryInfo.Parse(prop.ToString());
            }
            else if (type == typeof(SharingPolicyDomain))
            {
                obj = SharingPolicyDomain.Parse(prop.ToString());
            }
            else if (type == typeof(ApprovedApplication))
            {
                obj = ApprovedApplication.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpDomainWithSubdomains))
            {
                obj = SmtpDomainWithSubdomains.Parse(prop.ToString());
            }
            else if (type == typeof(UMLanguage))
            {
                obj = UMLanguage.Parse(prop.ToString());
            }
            else if (type == typeof(UMSmartHost))
            {
                obj = UMSmartHost.Parse(prop.ToString());
            }
            else if (type == typeof(ScheduleInterval))
            {
                obj = ScheduleInterval.Parse(prop.ToString());
            }
            else if (type == typeof(NumberFormat))
            {
                obj = NumberFormat.Parse(prop.ToString());
            }
            else if (type == typeof(DialGroupEntry))
            {
                obj = DialGroupEntry.Parse(prop.ToString());
            }
            else if (type == typeof(CustomMenuKeyMapping))
            {
                obj = CustomMenuKeyMapping.Parse(prop.ToString());
            }
            else if (type == typeof(HolidaySchedule))
            {
                obj = HolidaySchedule.Parse(prop.ToString());
            }
            else if (type == typeof(UMTimeZone))
            {
                obj = UMTimeZone.Parse(prop.ToString());
            }
            else if (type == typeof(ServerVersion))
            {
                obj = ServerVersion.ParseFromSerialNumber(prop.ToString());
            }
            else if (type == typeof(X509Certificate2))
            {
                obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]);
            }
            else if (type == typeof(LocalizedString))
            {
                obj = new LocalizedString(prop.ToString());
            }
            else if (type == typeof(ExchangeObjectVersion))
            {
                obj = ExchangeObjectVersion.Parse(prop.ToString());
            }
            else if (type == typeof(bool))
            {
                obj = bool.Parse(prop.ToString());
            }
            else if (type == typeof(SecurityPrincipalIdParameter))
            {
                obj = new SecurityPrincipalIdParameter(prop.ToString());
            }
            else if (type == typeof(ActiveDirectoryAccessRule))
            {
                obj = (prop as ActiveDirectoryAccessRule);
            }
            else if (type == typeof(ObjectId))
            {
                string text = prop.ToString();
                if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/"))
                {
                    text = MockObjectCreator.ConvertDNFromTreeStructure(text);
                }
                obj = new ADObjectId(text);
            }
            else if (type.IsEnum)
            {
                try
                {
                    obj = Enum.Parse(type, prop.ToString());
                }
                catch (ArgumentException)
                {
                    obj = Enum.GetValues(type).GetValue(0);
                }
            }
            return(obj ?? prop);
        }