internal static object QuotaSettingGetter(ADPropertyDefinition adPropertyDefinition, IPropertyBag propertyBag)
        {
            if (adPropertyDefinition == null)
            {
                throw new ArgumentNullException("adPropertyDefinition");
            }
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings];
            string quotaSettingIdentifier = adPropertyDefinition.Name + ':';
            object result = adPropertyDefinition.DefaultValue;

            if (multiValuedProperty != null && multiValuedProperty.Count > 0)
            {
                string text = multiValuedProperty.FirstOrDefault((string item) => item.StartsWith(quotaSettingIdentifier, StringComparison.Ordinal));
                if (!string.IsNullOrEmpty(text))
                {
                    try
                    {
                        result = ValueConvertor.ConvertValueFromString(text.Substring(quotaSettingIdentifier.Length), adPropertyDefinition.Type, null);
                    }
                    catch (FormatException ex)
                    {
                        PropertyValidationError error = new PropertyValidationError(DirectoryStrings.CannotCalculateProperty(adPropertyDefinition.Name, ex.Message), adPropertyDefinition, propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings]);
                        throw new DataValidationException(error, ex);
                    }
                }
            }
            return(result);
        }
        internal static void QuotaSettingSetter(ADPropertyDefinition adPropertyDefinition, object quota, IPropertyBag propertyBag)
        {
            if (adPropertyDefinition == null)
            {
                throw new ArgumentNullException("adPropertyDefinition");
            }
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings];
            string text = adPropertyDefinition.Name + ':';

            if (multiValuedProperty != null && multiValuedProperty.Count != 0)
            {
                for (int i = multiValuedProperty.Count - 1; i >= 0; i--)
                {
                    if (string.IsNullOrEmpty(multiValuedProperty[i]) || multiValuedProperty[i].StartsWith(text, StringComparison.Ordinal))
                    {
                        multiValuedProperty.RemoveAt(i);
                    }
                }
            }
            if (!object.Equals(quota, adPropertyDefinition.DefaultValue))
            {
                string arg  = ValueConvertor.ConvertValueToString(quota, null);
                string item = string.Format("{0}{1}", text, arg);
                multiValuedProperty.Add(item);
            }
            propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings] = multiValuedProperty;
        }
Esempio n. 3
0
        internal static MiniVirtualDirectory CreateFrom(ADObject virtualDirectory, ICollection <PropertyDefinition> propertyDefinitions, object[] propertyValues)
        {
            MiniVirtualDirectory             miniVirtualDirectory = new MiniVirtualDirectory();
            IEnumerable <PropertyDefinition> allProperties        = miniVirtualDirectory.Schema.AllProperties;
            ADPropertyBag adpropertyBag = new ADPropertyBag();

            adpropertyBag.SetIsReadOnly(false);
            foreach (PropertyDefinition propertyDefinition in allProperties)
            {
                ADPropertyDefinition key = (ADPropertyDefinition)propertyDefinition;
                object value             = virtualDirectory.propertyBag.Contains(key) ? virtualDirectory.propertyBag[key] : null;
                adpropertyBag.SetField(key, value);
            }
            MultiValuedProperty <string> multiValuedProperty = adpropertyBag[ADObjectSchema.ObjectClass] as MultiValuedProperty <string>;

            if (multiValuedProperty == null || multiValuedProperty.Count == 0)
            {
                multiValuedProperty = new MultiValuedProperty <string>(virtualDirectory.MostDerivedObjectClass);
                adpropertyBag.SetField(ADObjectSchema.ObjectClass, multiValuedProperty);
            }
            if (adpropertyBag[ADObjectSchema.WhenChangedUTC] == null)
            {
                DateTime utcNow = DateTime.UtcNow;
                adpropertyBag.SetField(ADObjectSchema.WhenChangedUTC, utcNow);
                adpropertyBag.SetField(ADObjectSchema.WhenCreatedUTC, utcNow);
            }
            if (propertyDefinitions != null && propertyValues != null)
            {
                adpropertyBag.SetProperties(propertyDefinitions, propertyValues);
            }
            adpropertyBag.SetIsReadOnly(true);
            miniVirtualDirectory.propertyBag = adpropertyBag;
            return(miniVirtualDirectory);
        }
Esempio n. 4
0
 public PolicyConfigConverter(ADPropertyDefinition policyIdProperty, ConfigurationObjectType configurationObjectType, Action <TPolicyStorage, TPolicyConfig> copyPropertiesToPolicyConfigDelegate, Action <TPolicyConfig, TPolicyStorage> copyPropertiesToStorageDelegate) : base(typeof(TPolicyConfig), configurationObjectType, typeof(TPolicyStorage), policyIdProperty)
 {
     ArgumentValidator.ThrowIfNull("copyPropertiesToPolicyConfigDelegate", copyPropertiesToPolicyConfigDelegate);
     ArgumentValidator.ThrowIfNull("copyPropertiesToStorageDelegate", copyPropertiesToStorageDelegate);
     this.copyPropertiesToPolicyConfigDelegate = copyPropertiesToPolicyConfigDelegate;
     this.copyPropertiesToStorageDelegate      = copyPropertiesToStorageDelegate;
 }
Esempio n. 5
0
 // Token: 0x0600606D RID: 24685 RVA: 0x00147AD5 File Offset: 0x00145CD5
 public ProvisioningPropertyTemplate(ADPropertyDefinition policyProperty, ProviderPropertyDefinition objectProperty, ValueConverterDelegate valueConverter, Type[] targetObjectTypes) : base(policyProperty, objectProperty, valueConverter, targetObjectTypes)
 {
     if (objectProperty.IsReadOnly)
     {
         throw new ArgumentException(string.Format("objectProperty '{0}' is read only.", objectProperty.Name));
     }
 }
Esempio n. 6
0
        internal QueryFilter CreateWildcardFilter(ADPropertyDefinition schemaProperty, string identityString)
        {
            string       text         = identityString;
            MatchOptions matchOptions = MatchOptions.FullString;

            if (text.StartsWith("*") && text.EndsWith("*"))
            {
                if (text.Length <= 2)
                {
                    return(null);
                }
                text         = text.Substring(1, text.Length - 2);
                matchOptions = MatchOptions.SubString;
            }
            else if (text.EndsWith("*"))
            {
                text         = text.Substring(0, text.Length - 1);
                matchOptions = MatchOptions.Prefix;
            }
            else if (text.StartsWith("*"))
            {
                text         = text.Substring(1);
                matchOptions = MatchOptions.Suffix;
            }
            return(new TextFilter(schemaProperty, text, matchOptions, MatchFlags.IgnoreCase));
        }
Esempio n. 7
0
        protected override bool UpdateTargetMissingProperty(string sourceId, ADPropertyDefinition propertyDefinition, SyncLink link, ADRawEntry target)
        {
            string text = (string)target[SyncObjectSchema.ObjectId];
            MultiValuedProperty <string> multiValuedProperty  = (MultiValuedProperty <string>)target[ADObjectSchema.ObjectClass];
            DirectoryObjectClass?        directoryObjectClass = null;

            foreach (string key in multiValuedProperty)
            {
                if (this.directoryClassLookup.ContainsKey(key))
                {
                    directoryObjectClass = new DirectoryObjectClass?(this.directoryClassLookup[key]);
                    break;
                }
            }
            if (directoryObjectClass == null)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string, string, string>((long)SyncConfiguration.TraceId, "LinkTargetMissingPropertyResolver:: - Skipping link {0} -> {1}. Unsupported link target class: {2}", sourceId, text, string.Join(",", multiValuedProperty.ToArray()));
                return(false);
            }
            if (propertyDefinition.LdapDisplayName == SyncGroupSchema.ManagedBy.LdapDisplayName && directoryObjectClass.Value == DirectoryObjectClass.Group)
            {
                ExTraceGlobals.BackSyncTracer.TraceError <string, string>((long)SyncConfiguration.TraceId, "LinkTargetMissingPropertyResolver:: - Skipping link {0} -> {1}. ManagedBy for groups pointing to groups need to be filtered out.", sourceId, text);
                return(false);
            }
            link.UpdateSyncData(text, directoryObjectClass.Value);
            return(true);
        }
        internal static object TlsAuthLevelGetter(IPropertyBag propertyBag, ADPropertyDefinition flagsProperty)
        {
            int          num          = (int)propertyBag[flagsProperty];
            TlsAuthLevel tlsAuthLevel = (TlsAuthLevel)((num & 4080) >> 4);

            return((tlsAuthLevel == (TlsAuthLevel)0) ? null : new TlsAuthLevel?(tlsAuthLevel));
        }
 internal void UpdateDisplay()
 {
     if (!base.TextBoxReadOnly || this.DisplayMember == null || string.Equals(this.ValueMember, this.DisplayMember))
     {
         ValueToDisplayObjectConverter valueToDisplayObjectConverter = (this.ValueMemberConverter != null) ? this.ValueMemberConverter : new ToStringValueToDisplayObjectConverter();
         this.Text = ((this.SelectedValue == null || DBNull.Value == this.SelectedValue) ? string.Empty : valueToDisplayObjectConverter.Convert(this.SelectedValue).ToString());
         return;
     }
     if (this.SelectedValue != null && this.Picker != null)
     {
         object obj = null;
         ValueToDisplayObjectConverter valueToDisplayObjectConverter2 = (this.DisplayMemberConverter != null) ? this.DisplayMemberConverter : new ToStringValueToDisplayObjectConverter();
         if (this.Picker.SelectedObjects != null && this.Picker.SelectedObjects.Rows.Count > 0)
         {
             obj = this.Picker.SelectedObjects.Rows[0][this.DisplayMember];
         }
         else if (this.resolver != null && (this.SelectedValue is ADObjectId || this.ValueMemberPropertyDefinition != null) && !string.IsNullOrEmpty(this.SelectedValue.ToString()))
         {
             ADPropertyDefinition property = this.ValueMemberPropertyDefinition ?? ADObjectSchema.Id;
             this.resolver.ResolveObjectIds(property, new List <object>(new object[]
             {
                 this.SelectedValue
             }));
             base.UpdateBrowseButtonState();
         }
         else
         {
             obj = this.SelectedValue;
         }
         this.Text = ((obj == null) ? string.Empty : valueToDisplayObjectConverter2.Convert(obj).ToString());
         return;
     }
     this.Text = string.Empty;
 }
Esempio n. 10
0
 public TenantRelocationSyncUnionSchema()
 {
     this.ldapDisplayNameToPropertyDefinitinoMappings = new Dictionary <string, ADPropertyDefinition>(StringComparer.InvariantCultureIgnoreCase);
     foreach (PropertyDefinition propertyDefinition in base.AllProperties)
     {
         ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition;
         if (!string.IsNullOrEmpty(adpropertyDefinition.LdapDisplayName))
         {
             string ldapDisplayName = adpropertyDefinition.LdapDisplayName;
             if (!this.ldapDisplayNameToPropertyDefinitinoMappings.ContainsKey(ldapDisplayName))
             {
                 this.ldapDisplayNameToPropertyDefinitinoMappings[ldapDisplayName] = adpropertyDefinition;
                 ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)this.GetHashCode(), "TenantRelocationSyncUnionSchema constructor: added LdapDisplayName {0} to dictionary", adpropertyDefinition.LdapDisplayName);
             }
             else
             {
                 ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)this.GetHashCode(), "TenantRelocationSyncUnionSchema constructor: skip adding {0} to dictionary, because the key exists", adpropertyDefinition.LdapDisplayName);
             }
         }
         if (adpropertyDefinition.SoftLinkShadowProperty != null && !string.IsNullOrEmpty(adpropertyDefinition.SoftLinkShadowProperty.LdapDisplayName))
         {
             this.ldapDisplayNameToPropertyDefinitinoMappings[adpropertyDefinition.SoftLinkShadowProperty.LdapDisplayName] = adpropertyDefinition;
             ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)this.GetHashCode(), "TenantRelocationSyncUnionSchema constructor: added LdapDisplayName {0} to dictionary, soft link", adpropertyDefinition.LdapDisplayName);
         }
         if (adpropertyDefinition.ShadowProperty != null && !string.IsNullOrEmpty(adpropertyDefinition.ShadowProperty.LdapDisplayName))
         {
             this.ldapDisplayNameToPropertyDefinitinoMappings[adpropertyDefinition.ShadowProperty.LdapDisplayName] = adpropertyDefinition;
             ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>((long)this.GetHashCode(), "TenantRelocationSyncUnionSchema constructor: added LdapDisplayName {0} to dictionary, shadow attribute", adpropertyDefinition.LdapDisplayName);
         }
     }
 }
        internal static object ShowHiddenFoldersEnabledGetter(IPropertyBag propertyBag)
        {
            int num = 1;
            ADPropertyDefinition popImapFlags = PopImapAdConfigurationSchema.PopImapFlags;

            return((num & (int)propertyBag[popImapFlags]) != 0);
        }
Esempio n. 12
0
 private void SetIfModified <T>(ADPropertyDefinition property, Action <T> setValue)
 {
     if (base.Fields.IsModified(property))
     {
         setValue((T)((object)base.Fields[property]));
     }
 }
Esempio n. 13
0
        private static void TracePropertyValue(string hint, ADPropertyDefinition property, object value)
        {
            string arg = string.Empty;

            if (property.IsMultivalued)
            {
                if (value != null)
                {
                    IList         list          = (IList)value;
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (object obj in list)
                    {
                        if (stringBuilder.Length > 0)
                        {
                            stringBuilder.Append(";");
                        }
                        stringBuilder.AppendFormat("{0}", obj.ToString());
                    }
                    arg = stringBuilder.ToString();
                }
                else
                {
                    arg = "NULL";
                }
            }
            else
            {
                arg = ((value != null) ? value.ToString() : "NULL");
            }
            ExTraceGlobals.BackSyncTracer.TraceDebug <string, string, string>((long)SyncConfiguration.TraceId, "<{0}> PropertyValue - {1}: {2}", hint, property.ToString(), arg);
        }
        // Token: 0x06001D45 RID: 7493 RVA: 0x00079D44 File Offset: 0x00077F44
        internal static object IncludeRecipientGetter(IPropertyBag propertyBag, ADPropertyDefinition filterMeatadata, ADPropertyDefinition filter)
        {
            WellKnownRecipientType?wellKnownRecipientType = null;

            if (WellKnownRecipientFilterType.Precanned == (WellKnownRecipientFilterType)RecipientFilterHelper.RecipientFilterTypeGetter(propertyBag, filterMeatadata, filter))
            {
                MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[filterMeatadata];
                wellKnownRecipientType = new WellKnownRecipientType?(WellKnownRecipientType.None);
                foreach (string text in multiValuedProperty)
                {
                    if (text.StartsWith("Microsoft.Exchange12.8f91d340bc0c47e4b4058a479602f94c:IncludedRecipients=", StringComparison.OrdinalIgnoreCase))
                    {
                        int value;
                        if (int.TryParse(text.Substring("Microsoft.Exchange12.8f91d340bc0c47e4b4058a479602f94c:IncludedRecipients=".Length), out value))
                        {
                            wellKnownRecipientType = new WellKnownRecipientType?((WellKnownRecipientType)value);
                            break;
                        }
                        wellKnownRecipientType = null;
                        break;
                    }
                }
            }
            return(wellKnownRecipientType);
        }
        internal override bool TryGetValue(ProviderPropertyDefinition pdef, out object result)
        {
            if (this.StrValue == null)
            {
                result = null;
                return(true);
            }
            ADPropertyDefinition adpropertyDefinition = pdef as ADPropertyDefinition;
            IFormatProvider      formatProvider       = (adpropertyDefinition != null) ? adpropertyDefinition.FormatProvider : null;

            result = null;
            Exception ex = null;

            if (!ADValueConvertor.TryConvertValueFromString(this.StrValue, pdef.Type, formatProvider, out result, out ex))
            {
                MrsTracer.Common.Warning("Failed to convert {0} from string '{1}': {2}", new object[]
                {
                    pdef.Name,
                    this.StrValue,
                    CommonUtils.FullExceptionMessage(ex)
                });
                return(false);
            }
            return(true);
        }
 public Result <ADRawEntry>[] ReadMultipleOrganizationProperties(ADObjectId[] organizationOUIds, PropertyDefinition[] properties)
 {
     if (organizationOUIds == null)
     {
         throw new ArgumentNullException("organizationOUIds");
     }
     if (organizationOUIds.Length == 0)
     {
         return(new Result <ADRawEntry> [0]);
     }
     PropertyDefinition[] array;
     if (properties == null)
     {
         array = new ADPropertyDefinition[]
         {
             ADObjectSchema.OrganizationalUnitRoot
         };
     }
     else
     {
         array = new PropertyDefinition[properties.Length + 1];
         properties.CopyTo(array, 0);
         array[array.Length - 1] = ADObjectSchema.OrganizationalUnitRoot;
     }
     return(base.ReadMultiple <ADObjectId, ADRawEntry>(organizationOUIds, (ADObjectId ouId) => new AndFilter(new QueryFilter[]
     {
         new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, ouId),
         new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectClass, ExchangeConfigurationUnit.MostDerivedClass)
     }), delegate(Hashtable hash, ADRawEntry entry)
     {
         ADObjectId adobjectId = (ADObjectId)entry[ADObjectSchema.OrganizationalUnitRoot];
         hash.Add(adobjectId.DistinguishedName, new Result <ADRawEntry>(entry, null));
         hash.Add(adobjectId.ObjectGuid.ToString(), new Result <ADRawEntry>(entry, null));
     }, new ADDataSession.HashLookup <ADObjectId, ADRawEntry>(ADRecipientObjectSession.ADObjectIdHashLookup <ADRawEntry>), array, true));
 }
Esempio n. 17
0
        private static object GetAccessScope(IPropertyBag properties, string prefix, ADPropertyDefinition cacheDefinition)
        {
            MultiValuedProperty <string> actions = (MultiValuedProperty <string>)properties[OrganizationRelationshipSchema.FederationEnabledActions];
            string action        = OrganizationRelationshipHelper.GetAction(actions, prefix);
            string targetElement = OrganizationRelationshipHelper.GetTargetElement(action);

            if (targetElement == null)
            {
                return(null);
            }
            Guid guid;

            try
            {
                guid = new Guid(targetElement);
            }
            catch (FormatException)
            {
                return(null);
            }
            catch (OverflowException)
            {
                return(null);
            }
            ADObjectId adobjectId = (ADObjectId)properties[cacheDefinition];

            if (adobjectId != null && adobjectId.ObjectGuid == guid)
            {
                return(adobjectId);
            }
            return(new ADObjectId(guid));
        }
Esempio n. 18
0
 private static void CheckPropertyDefinitionsForConsistency(ADPropertyDefinition adProp, SimpleProviderPropertyDefinition propertyDefinition, bool checkReadonly = false)
 {
     if (adProp == null)
     {
         throw new ArgumentNullException("adProp");
     }
     if (propertyDefinition == null)
     {
         throw new ArgumentNullException("propertyDefinition");
     }
     if (adProp.Name != propertyDefinition.Name)
     {
         throw new ArgumentException(string.Format("Underlying property definition for ADPropertyDefinition {0} has non-matching name: {1}", adProp.Name, propertyDefinition.Name));
     }
     if (adProp.IsMultivalued != propertyDefinition.IsMultivalued)
     {
         throw new ArgumentException(string.Format("ADPropertyDefinition {0} and underlying property definition must have the same IsMultivalued value", adProp.Name));
     }
     if (adProp.Type != propertyDefinition.Type && adProp.Type != Nullable.GetUnderlyingType(propertyDefinition.Type))
     {
         throw new ArgumentException(string.Format("ADPropertyDefinition {0}: underlying property definition must have either the same Type, or Nullable version of it", adProp.Name));
     }
     if (checkReadonly && adProp.IsReadOnly)
     {
         throw new ArgumentException(string.Format("ADPropertyDefinition {0} has underlying property definition but is read-only", adProp.Name));
     }
 }
Esempio n. 19
0
        internal static object MultiValuedStringKeyGetter(IPropertyBag propertyBag, ADPropertyDefinition rawProperty, int offset)
        {
            if (offset < 0 || offset > 2)
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            MultiValuedProperty <string> multiValuedProperty = propertyBag[rawProperty] as MultiValuedProperty <string>;

            if (multiValuedProperty == null || multiValuedProperty.Count == 0)
            {
                return(string.Empty);
            }
            string tag   = offset.ToString("d1") + AuthConfigSchema.NameValueSeparator;
            string text  = string.Empty;
            string text2 = multiValuedProperty.SingleOrDefault((string s) => s.StartsWith(tag));

            if (text2 != null && text2.Length > tag.Length)
            {
                text = text2.Substring(tag.Length);
            }
            if (!string.IsNullOrEmpty(text))
            {
                return(text);
            }
            if (multiValuedProperty.Count == 1 && offset == 0)
            {
                text = multiValuedProperty[0];
            }
            return(text);
        }
Esempio n. 20
0
        // 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. 21
0
        internal void SetProperties(ADObject server)
        {
            ADPropertyBag adpropertyBag = new ADPropertyBag();

            adpropertyBag.SetIsReadOnly(false);
            foreach (PropertyDefinition propertyDefinition in this.Schema.AllProperties)
            {
                ADPropertyDefinition key = (ADPropertyDefinition)propertyDefinition;
                object value             = server.propertyBag.Contains(key) ? server.propertyBag[key] : null;
                adpropertyBag.SetField(key, value);
            }
            MultiValuedProperty <string> multiValuedProperty = adpropertyBag[ADObjectSchema.ObjectClass] as MultiValuedProperty <string>;

            if (multiValuedProperty == null || multiValuedProperty.Count == 0)
            {
                multiValuedProperty = new MultiValuedProperty <string>(this.MostDerivedObjectClass);
                adpropertyBag.SetField(ADObjectSchema.ObjectClass, multiValuedProperty);
            }
            if (adpropertyBag[ADObjectSchema.WhenChangedUTC] == null)
            {
                DateTime utcNow = DateTime.UtcNow;
                adpropertyBag.SetField(ADObjectSchema.WhenChangedUTC, utcNow);
                adpropertyBag.SetField(ADObjectSchema.WhenCreatedUTC, utcNow);
            }
            adpropertyBag.SetIsReadOnly(true);
            this.propertyBag = adpropertyBag;
        }
Esempio n. 22
0
 private static void SetADProperty(ADUser user, ADPropertyDefinition property, object value)
 {
     if (!user.ExchangeVersion.IsOlderThan(property.VersionAdded))
     {
         user[property] = value;
     }
 }
Esempio n. 23
0
 // Token: 0x060050C7 RID: 20679 RVA: 0x0012BAA4 File Offset: 0x00129CA4
 internal static object UnMarshalAttribute(ADPropertyDefinition property, object[] values)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     if (values == null)
     {
         throw new ArgumentNullException("values");
     }
     if (values.Length < 1)
     {
         return(null);
     }
     if (property.IsBinary)
     {
         byte[][] array = new byte[values.Length][];
         for (int i = 0; i < values.Length; i++)
         {
             array[i] = HexConverter.HexStringToByteArray((string)values[i]);
         }
         values = array;
     }
     return(ADValueConvertor.GetValueFromDirectoryAttributeValues(property, values));
 }
Esempio n. 24
0
        public static ADRawEntry CreateFrom(SimpleADObject simpleADObject, IEnumerable <PropertyDefinition> properties)
        {
            ArgumentValidator.ThrowIfNull("simpleADObject", simpleADObject);
            ArgumentValidator.ThrowIfNull("properties", properties);
            ADPropertyBag adpropertyBag = new ADPropertyBag();

            SimpleADObject.SimpleList <SimpleADObject.SimpleADProperty> properties2 = simpleADObject.Properties;
            SimpleADObject.SimpleADProperty simpleADProperty;
            if (!properties2.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);
            foreach (PropertyDefinition propertyDefinition in properties)
            {
                ADPropertyDefinition propertyDefinition2 = (ADPropertyDefinition)propertyDefinition;
                SimpleADObject.AddPropertyToPropertyBag(propertyDefinition2, adpropertyBag, properties2);
            }
            adpropertyBag.SetField(ADObjectSchema.ObjectState, simpleADObject.ObjectState);
            adpropertyBag.SetObjectVersion(simpleADObject.ExchangeVersion);
            return(new ADRawEntry(adpropertyBag)
            {
                OriginatingServer = simpleADObject.OriginatingServer,
                WhenReadUTC = new DateTime?(simpleADObject.WhenReadUTC),
                DirectoryBackendType = simpleADObject.DirectoryBackendType,
                IsCached = true
            });
        }
 private void StampServiceAccountValue(ThrottlingPolicy dataObject, ADPropertyDefinition key, Unlimited <uint> serviceAccountDefaultValue)
 {
     if (!base.Fields.Contains(key))
     {
         dataObject[key] = serviceAccountDefaultValue;
     }
 }
Esempio n. 26
0
        private static void FilterProperty(PropertyBag propertyBag, HashSet <string> attributesEverSet, SyncPropertyDefinition property)
        {
            bool flag = false;

            if (property.IsCalculated || !string.IsNullOrEmpty(property.LdapDisplayName))
            {
                if (property.IsCalculated)
                {
                    using (IEnumerator <ADPropertyDefinition> enumerator = property.DependentProperties.Cast <ADPropertyDefinition>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ADPropertyDefinition adpropertyDefinition = enumerator.Current;
                            if (!string.IsNullOrEmpty(property.LdapDisplayName) && attributesEverSet.Contains(adpropertyDefinition.LdapDisplayName))
                            {
                                flag = true;
                                break;
                            }
                        }
                        goto IL_79;
                    }
                }
                flag = attributesEverSet.Contains(property.LdapDisplayName);
IL_79:
                if (!flag)
                {
                    propertyBag.Remove(property);
                }
            }
        }
 private void InternalWriteResult(Collection <PSObject> psObjects, ADPropertyDefinition propertyDef)
 {
     if (psObjects == null)
     {
         throw new ArgumentNullException(Strings.ErrorNullParameter("psObjects"));
     }
     if (propertyDef == null)
     {
         throw new ArgumentNullException(Strings.ErrorNullParameter("propertyDef"));
     }
     foreach (PSObject psobject in psObjects)
     {
         foreach (PSPropertyInfo pspropertyInfo in psobject.Properties)
         {
             if (pspropertyInfo == null)
             {
                 throw new ArgumentNullException(Strings.ErrorNullParameter("property"));
             }
             if (pspropertyInfo.Value == null)
             {
                 throw new ArgumentNullException(Strings.ErrorNullParameter("property value"));
             }
             base.WriteObject(new ExchangeServerAccessLicenseUser(this.license.LicenseName, pspropertyInfo.Value.ToString()));
         }
     }
 }
 // Token: 0x06006078 RID: 24696 RVA: 0x00147D43 File Offset: 0x00145F43
 public RecipientResourceCountQuota(ADPropertyDefinition countQuotaProperty, string systemAddressListName, Type[] targetObjectTypes, RecipientTypeDetails[] targetObjectRecipientTypeDetails) : this(countQuotaProperty, systemAddressListName, targetObjectTypes)
 {
     if (targetObjectRecipientTypeDetails != null)
     {
         this.targetRecipientTypeDetails = new ReadOnlyCollection <RecipientTypeDetails>(targetObjectRecipientTypeDetails);
     }
 }
Esempio n. 29
0
        internal static PropertyValueBaseXML Create(ProviderPropertyDefinition pdef, object value)
        {
            ADPropertyDefinition adpropertyDefinition = pdef as ADPropertyDefinition;
            IFormatProvider      formatProvider       = (adpropertyDefinition != null) ? adpropertyDefinition.FormatProvider : null;
            ADObjectId           adobjectId           = value as ADObjectId;

            if (adobjectId != null)
            {
                return(ADObjectIdXML.Serialize(adobjectId));
            }
            OrganizationId organizationId = value as OrganizationId;

            if (organizationId != null)
            {
                return(OrganizationIdXML.Serialize(organizationId));
            }
            RawSecurityDescriptor rawSecurityDescriptor = value as RawSecurityDescriptor;

            if (rawSecurityDescriptor != null)
            {
                return(new PropertyStringValueXML
                {
                    StrValue = CommonUtils.GetSDDLString(rawSecurityDescriptor)
                });
            }
            Exception ex;

            if (pdef.IsBinary)
            {
                byte[] binValue;
                if (ADValueConvertor.TryConvertValueToBinary(value, formatProvider, out binValue, out ex))
                {
                    return(new PropertyBinaryValueXML
                    {
                        BinValue = binValue
                    });
                }
                MrsTracer.Common.Warning("Failed to convert {0} to binary, will try string: {1}", new object[]
                {
                    pdef.Name,
                    CommonUtils.FullExceptionMessage(ex)
                });
            }
            PropertyStringValueXML propertyStringValueXML = new PropertyStringValueXML();
            string text;

            if (!ADValueConvertor.TryConvertValueToString(value, formatProvider, out text, out ex))
            {
                text = value.ToString();
                MrsTracer.Common.Warning("Failed to convert {0} to string, defaulting to '{1}': {2}", new object[]
                {
                    pdef.Name,
                    text,
                    CommonUtils.FullExceptionMessage(ex)
                });
            }
            propertyStringValueXML.StrValue = text;
            return(propertyStringValueXML);
        }
Esempio n. 30
0
 // Note: this type is marked as 'beforefieldinit'.
 static SetOfflineAddressBookInternal()
 {
     ADPropertyDefinition[,] array = new ADPropertyDefinition[3, 2];
     array[0, 0] = ADConfigurationObjectSchema.AdminDisplayName;
     array[1, 0] = OfflineAddressBookSchema.Server;
     array[2, 0] = OfflineAddressBookSchema.PublicFolderDatabase;
     SetOfflineAddressBookInternal.propertiesCannotBeSet = array;
 }