Beispiel #1
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));
        }
Beispiel #2
0
        public static ADPropertyDefinition FromProvisionedADProperty(ADPropertyDefinition provisionedProperty, string name, string ldapDisplayName)
        {
            if (provisionedProperty == null)
            {
                throw new ArgumentNullException("provisionedProperty");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (string.IsNullOrEmpty(ldapDisplayName))
            {
                throw new ArgumentNullException("ldapDisplayName");
            }
            if ((provisionedProperty.Flags & ADPropertyDefinitionFlags.ReadOnly) != ADPropertyDefinitionFlags.None)
            {
                throw new ArgumentException(string.Format("It does not make sense to create provisioning template for ReadOnly property: {0}.", provisionedProperty.Name));
            }
            ADPropertyDefinitionFlags flags = provisionedProperty.Flags & ~(ADPropertyDefinitionFlags.Calculated | ADPropertyDefinitionFlags.FilterOnly | ADPropertyDefinitionFlags.Mandatory | ADPropertyDefinitionFlags.PersistDefaultValue | ADPropertyDefinitionFlags.WriteOnce | ADPropertyDefinitionFlags.TaskPopulated);
            Type type = provisionedProperty.Type;

            PropertyDefinitionConstraint[] array = new PropertyDefinitionConstraint[provisionedProperty.AllConstraints.Count];
            provisionedProperty.AllConstraints.CopyTo(array, 0);
            object defaultValue = null;

            if (provisionedProperty.Type.IsValueType)
            {
                if (!provisionedProperty.Type.IsGenericType || (provisionedProperty.Type.GetGenericTypeDefinition() != typeof(Nullable <>) && provisionedProperty.Type.GetGenericTypeDefinition() != typeof(Unlimited <>)))
                {
                    type = typeof(Nullable <>).MakeGenericType(new Type[]
                    {
                        provisionedProperty.Type
                    });
                    defaultValue = null;
                }
                else if (provisionedProperty.Type.IsGenericType && provisionedProperty.Type.GetGenericTypeDefinition() == typeof(Unlimited <>))
                {
                    defaultValue = provisionedProperty.DefaultValue;
                }
            }
            else if (provisionedProperty.Type == typeof(string))
            {
                defaultValue = string.Empty;
            }
            return(new ADPropertyDefinition(name, ExchangeObjectVersion.Exchange2010, type, provisionedProperty.FormatProvider, ldapDisplayName, flags, defaultValue, array, PropertyDefinitionConstraint.None, ProviderPropertyDefinition.None, null, null, null, null, null));
        }
Beispiel #3
0
        internal static ADPropertyDefinition LegacyDnProperty(ADPropertyDefinitionFlags flags)
        {
            string text = "[a-zA-Z0-9 @!%&'),-.:<>}_\"\\|\\(\\*\\+\\?\\[\\]\\{]+";

            return(new ADPropertyDefinition("LegacyExchangeDN", ExchangeObjectVersion.Exchange2003, typeof(string), "legacyExchangeDN", flags, string.Empty, PropertyDefinitionConstraint.None, new PropertyDefinitionConstraint[]
            {
                new NoLeadingOrTrailingWhitespaceConstraint(),
                new RegexConstraint(string.Concat(new string[]
                {
                    "^(/o=",
                    text,
                    "|/o=",
                    text,
                    "/ou=",
                    text,
                    "(/cn=",
                    text,
                    ")*)$"
                }), RegexOptions.Compiled | RegexOptions.Singleline, DataStrings.LegacyDNPatternDescription)
            }, SimpleProviderPropertyDefinition.None, null, null, null, null, null));
        }
Beispiel #4
0
 public NspiPropertyDefinition(PropTag propTag, Type type, string ldapDisplayName, ADPropertyDefinitionFlags flags, object defaultValue, bool memberOfGlobalCatalog) : base(propTag.ToString(), ExchangeObjectVersion.Exchange2003, type, ldapDisplayName, flags, defaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, null, null)
 {
     this.propTag = propTag;
     this.memberOfGlobalCatalog = memberOfGlobalCatalog;
 }
        private static NspiPropertyDefinition CreatePropertyDefinition(ADSchemaAttributeObject mapiAttribute)
        {
            ADPropertyDefinitionFlags adpropertyDefinitionFlags = ADPropertyDefinitionFlags.None;
            Type     typeFromHandle;
            PropType propType;
            object   defaultValue;

            switch (mapiAttribute.DataSyntax)
            {
            case DataSyntax.Boolean:
                typeFromHandle = typeof(bool);
                propType       = PropType.Boolean;
                defaultValue   = false;
                goto IL_13B;

            case DataSyntax.Integer:
            case DataSyntax.Enumeration:
            case DataSyntax.LargeInteger:
                typeFromHandle             = typeof(int);
                propType                   = PropType.Int;
                defaultValue               = 0;
                adpropertyDefinitionFlags |= ADPropertyDefinitionFlags.PersistDefaultValue;
                goto IL_13B;

            case DataSyntax.Sid:
            case DataSyntax.Octet:
                typeFromHandle             = typeof(byte[]);
                propType                   = PropType.Binary;
                defaultValue               = null;
                adpropertyDefinitionFlags |= ADPropertyDefinitionFlags.Binary;
                goto IL_13B;

            case DataSyntax.Numeric:
            case DataSyntax.Printable:
            case DataSyntax.Teletex:
            case DataSyntax.IA5:
            case DataSyntax.CaseSensitive:
            case DataSyntax.Unicode:
                typeFromHandle = typeof(string);
                propType       = PropType.String;
                defaultValue   = string.Empty;
                goto IL_13B;

            case DataSyntax.UTCTime:
            case DataSyntax.GeneralizedTime:
                typeFromHandle = typeof(DateTime?);
                propType       = PropType.SysTime;
                defaultValue   = null;
                goto IL_13B;

            case DataSyntax.DNBinary:
            case DataSyntax.DNString:
            case DataSyntax.DSDN:
            case DataSyntax.ORName:
                typeFromHandle = typeof(ADObjectId);
                defaultValue   = null;
                if (mapiAttribute.LinkID == 0)
                {
                    propType = PropType.String;
                    goto IL_13B;
                }
                propType = PropType.Object;
                if (mapiAttribute.LinkID % 2 == 1)
                {
                    adpropertyDefinitionFlags |= ADPropertyDefinitionFlags.BackLink;
                    goto IL_13B;
                }
                goto IL_13B;
            }
            NspiSchemaProperties.Tracer.TraceDebug <DataSyntax>(0L, "Unsupported DataSyntax {0} -- Skipped", mapiAttribute.DataSyntax);
            return(null);

IL_13B:
            if (!mapiAttribute.IsSingleValued)
            {
                PropType propType2 = propType;
                if (propType2 > PropType.Object)
                {
                    if (propType2 != PropType.String)
                    {
                        if (propType2 == PropType.SysTime)
                        {
                            goto IL_188;
                        }
                        if (propType2 != PropType.Binary)
                        {
                            goto IL_19C;
                        }
                    }
                    propType |= PropType.MultiValueFlag;
                    goto IL_1A7;
                }
                if (propType2 != PropType.Int)
                {
                    switch (propType2)
                    {
                    case PropType.Boolean:
                        break;

                    case (PropType)12:
                        goto IL_19C;

                    case PropType.Object:
                        goto IL_1A7;

                    default:
                        goto IL_19C;
                    }
                }
IL_188:
                NspiSchemaProperties.Tracer.TraceDebug <PropType>(0L, "Unsupported multivalue property type {0} -- Skipped", propType);
                return(null);

IL_19C:
                throw new InvalidOperationException("Invalid PropType");
IL_1A7:
                defaultValue = null;
                adpropertyDefinitionFlags |= ADPropertyDefinitionFlags.MultiValued;
                adpropertyDefinitionFlags &= ~ADPropertyDefinitionFlags.PersistDefaultValue;
            }
            return(new NspiPropertyDefinition(PropTagHelper.PropTagFromIdAndType(mapiAttribute.MapiID, propType), typeFromHandle, mapiAttribute.LdapDisplayName, adpropertyDefinitionFlags, defaultValue, mapiAttribute.IsMemberOfPartialAttributeSet));
        }
 public ADPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, string ldapDisplayName, ADPropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) : this(name, versionAdded, type, null, ldapDisplayName, null, flags, defaultValue, readConstraints, writeConstraints, SimpleProviderPropertyDefinition.None, null, null, null, mservPropertyDefinition, mbxPropertyDefinition)
 {
 }
 internal ADPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, string ldapDisplayName, ADPropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) : this(name, versionAdded, type, null, ldapDisplayName, null, flags, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate, mservPropertyDefinition, mbxPropertyDefinition)
 {
 }
 internal ADPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, IFormatProvider formatProvider, string ldapDisplayName, string shadowLdapDisplayName, string softLinkLdapDisplayName, ADPropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) : base(name, versionAdded, type, (PropertyDefinitionFlags)flags, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate)
 {
     this.formatProvider          = formatProvider;
     this.ldapDisplayName         = ldapDisplayName;
     this.mservPropertyDefinition = mservPropertyDefinition;
     this.mbxPropertyDefinition   = mbxPropertyDefinition;
     if (string.IsNullOrEmpty(this.LdapDisplayName))
     {
         if (!this.IsCalculated && !this.IsTaskPopulated && !this.IsNonADProperty)
         {
             throw new ArgumentException(base.Name + ": Non-calculated properties must have LdapDisplayName", "ldapDisplayName");
         }
     }
     else
     {
         if (this.IsCalculated && base.CustomFilterBuilderDelegate != new CustomFilterBuilderDelegate(ADObject.DummyCustomFilterBuilderDelegate))
         {
             throw new ArgumentException(base.Name + ": Calculated properties should not contain an LdapDisplayName, unless it is the DummyCustomFilterBuilderDelegate.", "ldapDisplayName");
         }
         if (this.IsTaskPopulated)
         {
             throw new ArgumentException(base.Name + ": TaskPopulated properties should not contain an LdapDisplayName.", "ldapDisplayName");
         }
     }
     if (!this.IsMultivalued && !this.IsFilterOnly && !this.IsCalculated && !this.IsMandatory && base.Type == typeof(string) && !string.Empty.Equals(base.DefaultValue))
     {
         throw new ArgumentException(base.Name + ": Non-mandatory string properties must have default value String.Empty. Found " + (base.DefaultValue ?? "<null>"), "defaultValue");
     }
     if (this.IsValidateInFirstOrganization || this.IsDoNotValidate || this.IsBackLink)
     {
         if ((this.IsValidateInFirstOrganization && this.IsDoNotValidate) || (this.IsDoNotValidate && this.IsBackLink) || (this.IsValidateInFirstOrganization && this.IsBackLink))
         {
             throw new ArgumentException(base.Name + ": Only one of the three property definition flags - ValidateInFirstOrganization, DoNotValidate and BackLink can be set in parameter flags");
         }
         if (base.Type != typeof(ADObjectId))
         {
             throw new ArgumentException(base.Name + ": If ValidateInFirstOrganization, DoNotValidate or BackLink is set for parameter flags, the property type MUST be ADObjectId");
         }
     }
     if (this.IsRanged && (!this.IsMultivalued || string.IsNullOrEmpty(this.ldapDisplayName) || !this.IsReadOnly))
     {
         throw new ArgumentException(base.Name + ": Only multivalued non calculated properties can be ranged.");
     }
     if (!string.IsNullOrEmpty(this.ldapDisplayName) && this.IsRanged != this.ldapDisplayName.ToLower().Contains(";range="))
     {
         throw new ArgumentException(base.Name + ": Ranged property needs to define range in ldapName.");
     }
     if (!string.IsNullOrEmpty(shadowLdapDisplayName))
     {
         if (this.IsCalculated || this.IsReadOnly || this.IsFilterOnly || this.IsTaskPopulated || this.IsSoftLinkAttribute)
         {
             throw new ArgumentException(base.Name + ": Calculated, ReadOnly, FilterOnly, SoftLink, or TaskPopulated properties may not have shadows");
         }
         Type type2;
         ADPropertyDefinitionFlags flags2;
         object defaultValue2;
         if (type.GetTypeInfo().IsValueType&& (flags & ADPropertyDefinitionFlags.PersistDefaultValue) == ADPropertyDefinitionFlags.PersistDefaultValue)
         {
             Type typeFromHandle = typeof(Nullable <>);
             type2 = typeFromHandle.MakeGenericType(new Type[]
             {
                 type
             });
             flags2        = (flags & ~ADPropertyDefinitionFlags.PersistDefaultValue);
             defaultValue2 = null;
         }
         else
         {
             type2         = type;
             flags2        = flags;
             defaultValue2 = defaultValue;
         }
         this.shadowProperty = new ADPropertyDefinition(string.Format("Shadow{0}", name), ExchangeObjectVersion.Exchange2003, type2, formatProvider, shadowLdapDisplayName, null, null, flags2, defaultValue2, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, SimpleProviderPropertyDefinition.None, null, null, null, null, null);
     }
     if (!string.IsNullOrEmpty(softLinkLdapDisplayName))
     {
         if (this.IsCalculated || this.IsReadOnly || this.IsFilterOnly || this.IsTaskPopulated)
         {
             throw new ArgumentException(base.Name + ": Calculated, ReadOnly, FilterOnly, or TaskPopulated properties may not have soft links");
         }
         Type typeFromHandle2             = typeof(byte[]);
         ADPropertyDefinitionFlags flags3 = ADPropertyDefinitionFlags.Binary;
         this.softLinkShadowProperty = new ADPropertyDefinition(string.Format("{0}_sl", name), ExchangeObjectVersion.Exchange2003, typeFromHandle2, formatProvider, softLinkLdapDisplayName, null, null, flags3, null, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, SimpleProviderPropertyDefinition.None, null, null, null, null, null);
     }
 }
Beispiel #9
0
 internal static ADPropertyDefinition GetClientAccessRulePropertyDefinition <PropertyType, SingleType>(string name, PropertyType defaultValue, Func <ClientAccessRule, PropertyType> getter, Action <ClientAccessRule, PropertyType, IPropertyBag> setter, ADPropertyDefinitionFlags flags, PropertyDefinitionConstraint[] writeConstraints)
 {
     return(new ADPropertyDefinition(name, ExchangeObjectVersion.Exchange2012, typeof(SingleType), null, flags, defaultValue, PropertyDefinitionConstraint.None, writeConstraints, new ProviderPropertyDefinition[]
     {
         ADClientAccessRuleSchema.InternalPriority,
         ADClientAccessRuleSchema.RuleFlags,
         ADObjectSchema.RawName,
         ADClientAccessRuleSchema.Xml
     }, null, (IPropertyBag propertyBag) => getter(ADClientAccessRuleSchema.GetRuleFromADProperties(propertyBag)), delegate(object value, IPropertyBag propertyBag)
     {
         ClientAccessRule ruleFromADProperties = ADClientAccessRuleSchema.GetRuleFromADProperties(propertyBag);
         setter(ruleFromADProperties, (PropertyType)((object)value), propertyBag);
         propertyBag[ADClientAccessRuleSchema.Xml] = ruleFromADProperties.Xml;
     }, null, null));
 }
 private static ADPropertyDefinitionFlags CalculateFlags(string ldapDisplayName, ADPropertyDefinitionFlags flags)
 {
     if ((flags & ADPropertyDefinitionFlags.Calculated) == ADPropertyDefinitionFlags.None && string.IsNullOrEmpty(ldapDisplayName))
     {
         return(flags | ADPropertyDefinitionFlags.TaskPopulated);
     }
     return(flags);
 }
        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 HygienePropertyDefinition(string name, Type type, object defaultValue, ExchangeObjectVersion version, string displayName, ADPropertyDefinitionFlags flags) : base(name, version, type, displayName, flags, defaultValue, new PropertyDefinitionConstraint[0], new PropertyDefinitionConstraint[0], null, null)
 {
 }
 public HygienePropertyDefinition(string name, Type type, object defaultValue, ADPropertyDefinitionFlags flags = ADPropertyDefinitionFlags.PersistDefaultValue) : this(name, type, defaultValue, ExchangeObjectVersion.Exchange2010, flags)
 {
 }