// Token: 0x060050CB RID: 20683 RVA: 0x0012BE54 File Offset: 0x0012A054
        internal static PropertyDefinition[] LdapAttributesToPropertyDefinitions(ADObjectSchema schema, string[] attributes)
        {
            PropertyDefinition[] array  = new ADPropertyDefinition[attributes.Length];
            string[]             array2 = new string[attributes.Length];
            int num  = 0;
            int num2 = 0;

            for (int i = 0; i < attributes.Length; i++)
            {
                ADPropertyDefinition adpropDefByLdapDisplayName = schema.GetADPropDefByLdapDisplayName(attributes[i]);
                if (adpropDefByLdapDisplayName != null)
                {
                    array[num] = adpropDefByLdapDisplayName;
                    num++;
                }
                else
                {
                    array2[num2] = attributes[i];
                    num2++;
                }
            }
            PropertyDefinition[] array3 = new ADPropertyDefinition[num];
            Array.Copy(array, array3, num);
            return(array3);
        }
Esempio n. 2
0
        internal static string TrimStringValue(ADObjectSchema schema, ADPropertyDefinition propertyDefinition, string value)
        {
            if (propertyDefinition == null)
            {
                throw new ArgumentNullException("propertyDefinition");
            }
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }
            int stringConstraintLength = MobileDevice.GetStringConstraintLength(schema, propertyDefinition);

            if (value.Length > stringConstraintLength)
            {
                return(value.Remove(stringConstraintLength));
            }
            return(value);
        }
Esempio n. 3
0
        internal static int GetStringConstraintLength(ADObjectSchema schema, ADPropertyDefinition propertyDefinition)
        {
            if (propertyDefinition == null)
            {
                throw new ArgumentNullException("propertyDefinition");
            }
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }
            schema.InitializeAutogeneratedConstraints();
            int num = int.MaxValue;

            foreach (PropertyDefinitionConstraint propertyDefinitionConstraint in propertyDefinition.AllConstraints)
            {
                StringLengthConstraint stringLengthConstraint = propertyDefinitionConstraint as StringLengthConstraint;
                if (stringLengthConstraint != null && stringLengthConstraint.MaxLength < num)
                {
                    num = stringLengthConstraint.MaxLength;
                }
            }
            return(num);
        }
        // Token: 0x060050CD RID: 20685 RVA: 0x0012BED4 File Offset: 0x0012A0D4
        internal static PropertyDefinition[] LdapAttributesToPropertyDefinitions(ADObjectSchema schema, string[] attributes, ADObject recipient, out PropertyDefinition[] nonADRecipientPropDefs)
        {
            PropertyDefinition[] array  = new ADPropertyDefinition[attributes.Length];
            PropertyDefinition[] array2 = new ADPropertyDefinition[attributes.Length];
            int num  = 0;
            int num2 = 0;

            foreach (string text in attributes)
            {
                if (!string.IsNullOrEmpty(text))
                {
                    bool     flag         = false;
                    bool     flag2        = false;
                    object   defaultValue = null;
                    string[] array3       = text.Split(new char[]
                    {
                        ':'
                    }, 2);
                    if (string.IsNullOrEmpty(array3[0]))
                    {
                        throw new ArgumentException(DirectoryStrings.ExArgumentException("attributes", text), "attributes");
                    }
                    if (array3.Length > 1)
                    {
                        if (array3[1].Equals("mv", StringComparison.OrdinalIgnoreCase))
                        {
                            flag2 = true;
                        }
                        else if (array3[1].Equals("binary", StringComparison.OrdinalIgnoreCase))
                        {
                            flag = true;
                        }
                        else
                        {
                            if (!array3[1].Equals("mv-binary", StringComparison.OrdinalIgnoreCase))
                            {
                                throw new ArgumentException(DirectoryStrings.ExArgumentException("attributes", text), "attributes");
                            }
                            flag2 = true;
                            flag  = true;
                        }
                    }
                    else
                    {
                        defaultValue = string.Empty;
                    }
                    ADPropertyDefinition adpropDefByLdapDisplayName = schema.GetADPropDefByLdapDisplayName(array3[0]);
                    if (adpropDefByLdapDisplayName != null)
                    {
                        array[num] = adpropDefByLdapDisplayName;
                        if (((ADPropertyDefinition)array[num]).IsBinary != flag || ((ADPropertyDefinition)array[num]).IsMultivalued != flag2)
                        {
                            throw new RusOperationException(DirectoryStrings.ExceptionSchemaMismatch(array3[0], ((ADPropertyDefinition)array[num]).IsBinary, ((ADPropertyDefinition)array[num]).IsMultivalued, flag, flag2));
                        }
                        num++;
                    }
                    else
                    {
                        Type type;
                        if (!RUSMarshal.TryFindFilterOnlyDefinitionType(recipient, array3[0], out type))
                        {
                            type = (flag ? typeof(byte[]) : typeof(string));
                        }
                        ADPropertyDefinition adpropertyDefinition = new ADPropertyDefinition(array3[0], ExchangeObjectVersion.Exchange2003, type, array3[0], (flag ? ADPropertyDefinitionFlags.Binary : ADPropertyDefinitionFlags.None) | (flag2 ? ADPropertyDefinitionFlags.MultiValued : ADPropertyDefinitionFlags.None), defaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, SimpleProviderPropertyDefinition.None, null, null, null, null, null);
                        array2[num2] = adpropertyDefinition;
                        num2++;
                    }
                }
            }
            PropertyDefinition[] array4 = new ADPropertyDefinition[num];
            Array.Copy(array, array4, num);
            nonADRecipientPropDefs = new ADPropertyDefinition[num2];
            Array.Copy(array2, nonADRecipientPropDefs, num2);
            return(array4);
        }
Esempio n. 5
0
 // Token: 0x06003A05 RID: 14853 RVA: 0x000E02EF File Offset: 0x000DE4EF
 public ADPresentationSchema()
 {
     this.ParentSchema = this.GetParentSchema();
 }
Esempio n. 6
0
        public static TObject CreateFrom <TObject>(SimpleADObject simpleADObject, ADObjectSchema schema, IEnumerable <PropertyDefinition> additionalProperties) where TObject : ADRawEntry, new()
        {
            ArgumentValidator.ThrowIfNull("simpleADObject", simpleADObject);
            if (typeof(TObject).Equals(typeof(ADRawEntry)))
            {
                throw new ArgumentException("TObject cannot be ADRawEntry");
            }
            ADPropertyBag adpropertyBag = new ADPropertyBag();

            SimpleADObject.SimpleList <SimpleADObject.SimpleADProperty> properties = simpleADObject.Properties;
            SimpleADObject.SimpleADProperty simpleADProperty;
            if (!properties.TryGetValue(ADObjectSchema.Id.LdapDisplayName, out simpleADProperty))
            {
                throw new InvalidOperationException("dn is missing");
            }
            ValidationError validationError;
            ADObjectId      value = (ADObjectId)ADValueConvertor.ConvertFromADAndValidateSingleValue(simpleADProperty.Value as string, ADObjectSchema.Id, false, out validationError);

            adpropertyBag.SetField(ADObjectSchema.Id, value);
            adpropertyBag.SetField(ADObjectSchema.ObjectState, simpleADObject.ObjectState);
            adpropertyBag.SetObjectVersion(simpleADObject.ExchangeVersion);
            TObject tobject = Activator.CreateInstance <TObject>();
            IEnumerable <PropertyDefinition> enumerable;

            if (schema != null)
            {
                enumerable = schema.AllProperties;
            }
            else
            {
                enumerable = ((ADObject)((object)tobject)).Schema.AllProperties;
            }
            if (additionalProperties != null)
            {
                enumerable = enumerable.Concat(additionalProperties);
            }
            foreach (PropertyDefinition propertyDefinition in enumerable)
            {
                ADPropertyDefinition propertyDefinition2 = (ADPropertyDefinition)propertyDefinition;
                SimpleADObject.AddPropertyToPropertyBag(propertyDefinition2, adpropertyBag, properties);
            }
            if (tobject is MiniObject)
            {
                adpropertyBag.SetIsReadOnly(true);
            }
            if (schema != null || (!(tobject is ADRecipient) && !(tobject is MiniRecipient)))
            {
                tobject = (TObject)((object)ADObjectFactory.CreateAndInitializeConfigObject <TObject>(adpropertyBag, tobject, null));
            }
            else
            {
                tobject = (TObject)((object)ADObjectFactory.CreateAndInitializeRecipientObject <TObject>(adpropertyBag, tobject, null));
            }
            tobject.OriginatingServer    = simpleADObject.OriginatingServer;
            tobject.WhenReadUTC          = new DateTime?(simpleADObject.WhenReadUTC);
            tobject.DirectoryBackendType = simpleADObject.DirectoryBackendType;
            tobject.IsCached             = true;
            tobject.ValidateRead();
            tobject.ResetChangeTracking();
            return(tobject);
        }
Esempio n. 7
0
        public static List <T> CreateList <T>(SimpleADObject.SimpleList <SimpleADObject> list, ADObjectSchema schema, IEnumerable <PropertyDefinition> additionalProperties = null) where T : ADObject, new()
        {
            ArgumentValidator.ThrowIfNull("list", list);
            ArgumentValidator.ThrowIfNull("schema", schema);
            List <T> list2 = new List <T>(list.Count);

            foreach (SimpleADObject simpleADObject in list.Values)
            {
                T item = SimpleADObject.CreateFrom <T>(simpleADObject, schema, additionalProperties);
                list2.Add(item);
            }
            return(list2);
        }