public BindingStorage ToBindingStorage(ExPolicyConfigProvider policyConfigProvider) { ArgumentValidator.ThrowIfNull("policyConfigProvider", policyConfigProvider); BindingStorage bindingStorage = new BindingStorage(); bindingStorage.SetId(PolicyStorage.PoliciesContainer.GetChildId(this.Name)); bindingStorage.Name = this.Name; bindingStorage.MasterIdentity = this.MasterIdentity; bindingStorage.PolicyId = this.PolicyId; bindingStorage.Workload = this.Workload; bindingStorage.PolicyVersion = this.PolicyVersion; foreach (string scopeStorageString in this.RawAppliedScopes) { ScopeStorage scopeStorage = ExBindingStoreObject.ScopeStorageFromString(scopeStorageString, policyConfigProvider); if (scopeStorage != null) { bindingStorage.AppliedScopes.Add(scopeStorage); } } if (this.WhenChanged != null) { bindingStorage.propertyBag.SetField(ADObjectSchema.WhenChangedRaw, ADValueConvertor.ConvertValueToString(this.WhenChanged.Value, null)); } if (this.WhenCreated != null) { bindingStorage.propertyBag.SetField(ADObjectSchema.WhenCreatedRaw, ADValueConvertor.ConvertValueToString(this.WhenCreated.Value, null)); } bindingStorage.ResetChangeTracking(true); bindingStorage.RawObject = this; return(bindingStorage); }
public static GetterDelegate RawStringGetterIgnoringInvalid <TConverted>(ADPropertyDefinition rawPropertyDefinition, ADPropertyDefinition convertedPropertyDefinition) { if (!rawPropertyDefinition.IsMultivalued) { throw new NotImplementedException("RawStringGetterIgnoringInvalid is only currently implemented for multi-valued properties."); } return(delegate(IPropertyBag bag) { MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)bag[rawPropertyDefinition]; MultiValuedProperty <TConverted> result = null; List <TConverted> list = new List <TConverted>(); bool flag = false; foreach (string originalValue in multiValuedProperty) { object obj; Exception ex; if (ADValueConvertor.TryConvertValueFromString(originalValue, typeof(TConverted), rawPropertyDefinition.FormatProvider, out obj, out ex)) { list.Add((TConverted)((object)obj)); } else { flag = true; } } if (!flag && list.Count != 0) { result = new MultiValuedProperty <TConverted>(rawPropertyDefinition.IsReadOnly, convertedPropertyDefinition, list); } return result; }); }
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); }
// 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)); }
// Token: 0x06000DDF RID: 3551 RVA: 0x00040AB3 File Offset: 0x0003ECB3 private void ConvertAnrFilter(AmbiguousNameResolutionFilter anrFilter) { this.IncrementFilterSize(); this.ldapFilter.Append("(anr="); ADValueConvertor.EscapeAndAppendString(anrFilter.ValueToMatch, this.ldapFilter); this.ldapFilter.Append(")"); }
public static object GetValuesFromDirectoryProperty(SyncPropertyDefinition property, DirectoryProperty originalValues, List <ValidationError> errors) { if (originalValues == null) { return(null); } IList values = originalValues.GetValues(); if (values == null || values.Count == 0 || values == DirectoryProperty.EmptyValues) { return(null); } if (property.IsMultivalued) { IList values2 = new ArrayList(values.Count); SyncValueConvertor.ConvertMultipleValues(property, values, ref values2, errors); MultiValuedPropertyBase multiValuedPropertyBase = ADValueConvertor.CreateGenericMultiValuedProperty(property, property.IsReadOnly, values2, null, null); multiValuedPropertyBase.IsCompletelyRead = true; return(multiValuedPropertyBase); } ValidationError validationError = null; object result = SyncValueConvertor.ConvertSingleValue(property, values[0], out validationError); if (validationError != null) { errors.Add(validationError); } return(result); }
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 }); }
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); }
internal override MultiValuedPropertyBase CreateMultiValuedProperty(ProviderPropertyDefinition propertyDefinition, bool createAsReadOnly, ICollection values, ICollection invalidValues, LocalizedString?readOnlyErrorMessage) { if (propertyDefinition.Type == typeof(KindKeyword)) { return(new MultiValuedProperty <KindKeyword>(createAsReadOnly, propertyDefinition, values, invalidValues, readOnlyErrorMessage)); } return(ADValueConvertor.CreateGenericMultiValuedProperty(propertyDefinition, createAsReadOnly, values, invalidValues, readOnlyErrorMessage)); }
// Token: 0x06000B48 RID: 2888 RVA: 0x00033CCC File Offset: 0x00031ECC private bool AreMultivaluedPropertiesEqual(object leftValue, object rightValue, ADPropertyDefinition adProperty) { MultiValuedPropertyBase multiValuedPropertyBase = leftValue as MultiValuedPropertyBase; MultiValuedPropertyBase multiValuedPropertyBase2 = rightValue as MultiValuedPropertyBase; if (multiValuedPropertyBase != null && multiValuedPropertyBase.Count > 0 && rightValue == null) { return(false); } if (multiValuedPropertyBase == null && multiValuedPropertyBase2 != null && multiValuedPropertyBase2.Count > 0) { return(false); } if (multiValuedPropertyBase == null && multiValuedPropertyBase2 != null && multiValuedPropertyBase2.Count == 0) { return(true); } if (multiValuedPropertyBase != null && multiValuedPropertyBase.Count == 0 && multiValuedPropertyBase2 == null) { return(true); } if (multiValuedPropertyBase.Count == 0 && multiValuedPropertyBase2.Count == 0) { return(true); } IEnumerable enumerable = (IEnumerable)leftValue; List <byte[]> list = new List <byte[]>(); List <string> list2 = new List <string>(); foreach (object originalValue in enumerable) { if (adProperty.IsBinary) { list.Add(ADValueConvertor.ConvertValueToBinary(originalValue, adProperty.FormatProvider)); } else { list2.Add(ADValueConvertor.ConvertValueToString(originalValue, adProperty.FormatProvider)); } } IEnumerable enumerable2 = (IEnumerable)rightValue; List <byte[]> list3 = new List <byte[]>(); List <string> list4 = new List <string>(); foreach (object originalValue2 in enumerable2) { if (adProperty.IsBinary) { list3.Add(ADValueConvertor.ConvertValueToBinary(originalValue2, adProperty.FormatProvider)); } else { list4.Add(ADValueConvertor.ConvertValueToString(originalValue2, adProperty.FormatProvider)); } } return(list.Equals(list3, ByteArrayComparer.Instance) && list2.Equals(list4, StringComparer.Ordinal)); }
// Token: 0x06000DDC RID: 3548 RVA: 0x00040938 File Offset: 0x0003EB38 private void ConvertInChainFilter(InChainFilter inChainFilter) { ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)inChainFilter.Property; string ldapDisplayName = adpropertyDefinition.LdapDisplayName; this.IncrementFilterSize(); this.ldapFilter.Append("("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append(":1.2.840.113556.1.4.1941:="); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, inChainFilter.Value, this.ldapFilter, false, 0); this.ldapFilter.Append(")"); }
internal static MultiValuedPropertyBase GetAddedRemovedLinks(ADPropertyDefinition propertyDefinition, SearchResultAttributeCollection attributeCollection, List <ADPropertyDefinition> rangedProperties, List <ValidationError> errors) { MultiValuedProperty <ADObjectId> links = ADDirSyncHelper.GetLinks(propertyDefinition, false, attributeCollection, rangedProperties, errors); MultiValuedProperty <ADObjectId> links2 = ADDirSyncHelper.GetLinks(propertyDefinition, true, attributeCollection, rangedProperties, errors); if (links != null || links2 != null) { List <ADDirSyncLink> list = new List <ADDirSyncLink>(); ADDirSyncHelper.AddLinks(list, links, LinkState.Added, propertyDefinition); ADDirSyncHelper.AddLinks(list, links2, LinkState.Removed, propertyDefinition); return(ADValueConvertor.CreateGenericMultiValuedProperty(propertyDefinition, true, list, ADDirSyncHelper.EmptyList, null)); } return(null); }
protected virtual ExSearchResultEntry GetTargetEntry(ExSearchResultEntry entry) { DirectoryAttribute directoryAttribute = entry.Attributes["objectGUID"]; byte[] value = (byte[])directoryAttribute.GetValues(typeof(byte[]))[0]; string str = ADValueConvertor.EscapeBinaryValue(value); SearchRequest request = new SearchRequest(this.GetTargetBaseSearchPath(), "(msExchEdgeSyncSourceGuid=" + str + ")", System.DirectoryServices.Protocols.SearchScope.Subtree, new string[0]); SearchResponse searchResponse = (SearchResponse)this.SendRequest(request); if (searchResponse.Entries.Count > 0) { return(new ExSearchResultEntry(searchResponse.Entries[0])); } return(null); }
internal static MultiValuedProperty <ADObjectId> GetLinks(ADPropertyDefinition propertyDefinition, bool deleted, SearchResultAttributeCollection attributeCollection, List <ADPropertyDefinition> rangedProperties, List <ValidationError> errors) { int num = deleted ? 0 : 1; IntRange range = new IntRange(num, num); ADPropertyDefinition adpropertyDefinition = new ADPropertyDefinition(propertyDefinition.Name, propertyDefinition.VersionAdded, typeof(ADObjectId), propertyDefinition.LdapDisplayName, propertyDefinition.Flags | ADPropertyDefinitionFlags.MultiValued, propertyDefinition.DefaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, null, null); adpropertyDefinition = RangedPropertyHelper.CreateRangedProperty(adpropertyDefinition, range); DirectoryAttribute directoryAttribute = attributeCollection[adpropertyDefinition.LdapDisplayName]; if (directoryAttribute != null) { return(ADValueConvertor.GetValueFromDirectoryAttribute(null, directoryAttribute, adpropertyDefinition, true, rangedProperties, null, errors, null, false) as MultiValuedProperty <ADObjectId>); } return(null); }
public SyncResult OnDeleteEntry(byte[] guid) { string str = ADValueConvertor.EscapeBinaryValue(guid); SearchRequest request = new SearchRequest(this.GetTargetBaseSearchPath(), "(msExchEdgeSyncSourceGuid=" + str + ")", System.DirectoryServices.Protocols.SearchScope.Subtree, new string[0]); SearchResultEntry searchResultEntry = null; SearchResponse searchResponse = (SearchResponse)this.SendRequest(request); if (searchResponse.Entries.Count > 0) { searchResultEntry = searchResponse.Entries[0]; try { DeleteRequest request2 = new DeleteRequest(searchResultEntry.DistinguishedName); this.SendRequest(request2); } catch (ExDirectoryException ex) { if (ex.ResultCode != ResultCode.NoSuchObject) { if (ExTraceGlobals.SynchronizationJobTracer.IsTraceEnabled(TraceType.ErrorTrace)) { ExTraceGlobals.SynchronizationJobTracer.TraceError <string, Guid>((long)this.GetHashCode(), "Failed to delete entry {0} with sourceGuid {1}", searchResultEntry.DistinguishedName, new Guid(guid)); } throw; } this.logSession.LogEvent(EdgeSyncLoggingLevel.Medium, EdgeSyncEvent.TargetConnection, string.Format(CultureInfo.InvariantCulture, "DN:{0}, Guid:{1}", new object[] { searchResultEntry.DistinguishedName, new Guid(guid).ToString() }), "Skip deleting non-existing entry after sourceGuid has been confirmed. It must have been deleted in between."); return(SyncResult.None); } if (ExTraceGlobals.SynchronizationJobTracer.IsTraceEnabled(TraceType.DebugTrace)) { ExTraceGlobals.SynchronizationJobTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Deleted object {0} with sourceGuid {1}", searchResultEntry.DistinguishedName, new Guid(guid)); } return(SyncResult.Deleted); } if (ExTraceGlobals.SynchronizationJobTracer.IsTraceEnabled(TraceType.DebugTrace)) { ExTraceGlobals.SynchronizationJobTracer.TraceDebug <Guid>((long)this.GetHashCode(), "Delete non-existing entry with sourceGUID {0}", new Guid(guid)); } this.logSession.LogEvent(EdgeSyncLoggingLevel.Medium, EdgeSyncEvent.TargetConnection, new Guid(guid).ToString(), "Skip deleting non-existing entry"); return(SyncResult.None); }
// Token: 0x06000DDB RID: 3547 RVA: 0x00040790 File Offset: 0x0003E990 private void ConvertTextFilter(TextFilter textFilter) { if (textFilter.Property.Type.IsEnum) { throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedOperatorForProperty(textFilter.Property.Name, "LIKE")); } ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)textFilter.Property; string ldapDisplayName = adpropertyDefinition.LdapDisplayName; this.IncrementFilterSize(); this.ldapFilter.Append("("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("="); switch (textFilter.MatchOptions) { case MatchOptions.FullString: ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0); this.ldapFilter.Append(")"); return; case MatchOptions.SubString: this.ldapFilter.Append("*"); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0); this.ldapFilter.Append("*)"); return; case MatchOptions.Prefix: ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0); this.ldapFilter.Append("*)"); return; case MatchOptions.Suffix: this.ldapFilter.Append("*"); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0); this.ldapFilter.Append(")"); return; case MatchOptions.WildcardString: ADValueConvertor.EscapeAndAppendString(textFilter.Text, this.ldapFilter, true); this.ldapFilter.Append(")"); return; } throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedTextFilterOption(textFilter.MatchOptions.ToString())); }
public static int ParseTransportFlagsFromDirectoryAttribute(DirectoryAttribute attribute) { int result; try { object[] values = attribute.GetValues(typeof(string)); if (values == null || values.Length == 0) { throw new ExDirectoryException(new ArgumentNullException("TransportConfigContainerSchema.Flags attribute is null")); } result = (int)ADValueConvertor.GetValueFromDirectoryAttributeValues(ADAMTransportConfigContainerSchema.Flags, values); } catch (DataValidationException e) { throw new ExDirectoryException(e); } return(result); }
internal bool TryGetValue(ProviderPropertyDefinition pdef, out object result) { if (this.values.Count == 0) { result = null; return(true); } if (pdef.IsMultivalued) { List <object> list = new List <object>(this.values.Count); foreach (PropertyValueBaseXML propertyValueBaseXML in this.values) { object item; if (propertyValueBaseXML.TryGetValue(pdef, out item)) { list.Add(item); } } MultiValuedPropertyBase multiValuedPropertyBase = null; List <object> invalidValues = new List <object>(); if (!ADValueConvertor.TryCreateGenericMultiValuedProperty(pdef, false, list, invalidValues, null, out multiValuedPropertyBase)) { MrsTracer.Common.Warning("Failed to convert array to MultiValued property {0}", new object[] { pdef.Name }); result = null; return(false); } result = multiValuedPropertyBase; return(true); } else { if (this.values.Count != 1) { result = null; return(false); } return(this.values[0].TryGetValue(pdef, out result)); } }
public static SetterDelegate RawStringSetter <TConverted>(ADPropertyDefinition rawPropertyDefinition) { if (!rawPropertyDefinition.IsMultivalued) { throw new NotImplementedException("RawStringSetter is only currently implemented for multi-valued properties."); } return(delegate(object value, IPropertyBag bag) { MultiValuedProperty <TConverted> multiValuedProperty = (MultiValuedProperty <TConverted>)value; MultiValuedProperty <string> multiValuedProperty2 = null; if (multiValuedProperty != null && multiValuedProperty.Count != 0) { multiValuedProperty2 = new MultiValuedProperty <string>(); foreach (TConverted tconverted in multiValuedProperty) { multiValuedProperty2.Add(ADValueConvertor.ConvertValueToString(tconverted, rawPropertyDefinition.FormatProvider)); } } bag[rawPropertyDefinition] = multiValuedProperty2; }); }
public string ToFullString() { StringBuilder stringBuilder = new StringBuilder(); foreach (ADPropertyDefinition adpropertyDefinition in PushNotificationApp.ComparableProperties.Value) { object obj = null; this.propertyBag.TryGetField(adpropertyDefinition, ref obj); string text = null; if (obj != null) { if (!adpropertyDefinition.IsMultivalued) { text = ADValueConvertor.ConvertValueToString(obj, adpropertyDefinition.FormatProvider); } else { MultiValuedPropertyBase multiValuedPropertyBase = obj as MultiValuedPropertyBase; StringBuilder stringBuilder2 = new StringBuilder(); foreach (object originalValue in ((IEnumerable)multiValuedPropertyBase)) { if (stringBuilder2.Length > 0) { stringBuilder2.Append(", "); } stringBuilder2.AppendFormat("{0}", ADValueConvertor.ConvertValueToString(originalValue, adpropertyDefinition.FormatProvider)); } text = string.Format("@({0})", stringBuilder2.ToString()); } } if (stringBuilder.Length > 0) { stringBuilder.Append("; "); } stringBuilder.AppendFormat("{0}:{1}", adpropertyDefinition.Name, (text != null) ? text : "<null>"); } return(stringBuilder.ToString()); }
public static string BuildHostedRecipientAddressQuery(string attributeName, List <string> addressList) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("(&"); stringBuilder.Append("(msExchCU=*)(msExchOURoot=*)"); stringBuilder.Append("(|"); StringBuilder stringBuilder2 = new StringBuilder(); string value; if (string.Equals(attributeName, "msExchUMAddresses", StringComparison.OrdinalIgnoreCase)) { value = "=meum:"; } else { value = "=smtp:"; } foreach (string originalValue in addressList) { stringBuilder2.Append("("); stringBuilder2.Append(attributeName); stringBuilder2.Append(value); ADValueConvertor.EscapeAndAppendString(originalValue, stringBuilder2); stringBuilder2.Append(")"); } stringBuilder.Append(stringBuilder2.ToString()); stringBuilder.Append(")"); stringBuilder.Append("(|"); foreach (string value2 in Schema.Query.supportedHostedRecipientClasses) { stringBuilder.Append("(objectClass="); stringBuilder.Append(value2); stringBuilder.Append(")"); } stringBuilder.Append("))"); return(stringBuilder.ToString()); }
internal override MultiValuedPropertyBase CreateMultiValuedProperty(ProviderPropertyDefinition propertyDefinition, bool createAsReadOnly, ICollection values, ICollection invalidValues, LocalizedString?readOnlyErrorMessage) { return(ADValueConvertor.CreateGenericMultiValuedProperty(propertyDefinition, createAsReadOnly, values, invalidValues, readOnlyErrorMessage)); }
internal override object DeserializeData(ProviderPropertyDefinition propertyDefinition, object input) { return(ADValueConvertor.DeserializeData(propertyDefinition, input)); }
// Token: 0x060002E3 RID: 739 RVA: 0x0000FCDB File Offset: 0x0000DEDB protected override object DeserializeValue(object value) { return(ADValueConvertor.DeserializeData((ADPropertyDefinition)this.PropertyDefinition, value)); }
// Token: 0x060050C6 RID: 20678 RVA: 0x0012B948 File Offset: 0x00129B48 internal static object MarshalAttribute(ADPropertyDefinition property, object value) { if (property == null) { throw new ArgumentNullException("property"); } if (value == null) { return(null); } object[] array; if (!property.IsMultivalued) { array = new object[2]; array[0] = property.LdapDisplayName; if (property.IsBinary) { byte[] array2 = ADValueConvertor.ConvertValueToBinary(value, property.FormatProvider); array[1] = HexConverter.ByteArrayToHexString(array2); } else { ADObjectId adobjectId = value as ADObjectId; if (adobjectId != null) { array[1] = adobjectId.ToDNString(); } else { array[1] = ADValueConvertor.ConvertValueToString(value, property.FormatProvider); } } } else { int num = 0; ArrayList arrayList = new ArrayList(); IEnumerable enumerable = (IEnumerable)value; foreach (object obj in enumerable) { if (property.IsBinary) { byte[] array3 = ADValueConvertor.ConvertValueToBinary(obj, property.FormatProvider); arrayList.Add(HexConverter.ByteArrayToHexString(array3)); } else { ADObjectId adobjectId2 = obj as ADObjectId; string value2; if (adobjectId2 != null) { value2 = adobjectId2.ToDNString(); } else { value2 = ADValueConvertor.ConvertValueToString(obj, property.FormatProvider); } arrayList.Add(value2); } num++; } if (num == 0) { return(null); } array = new object[num + 1]; array[0] = property.LdapDisplayName; arrayList.CopyTo(array, 1); } return(array); }
// Token: 0x06000B4A RID: 2890 RVA: 0x00033E84 File Offset: 0x00032084 internal bool Equals(ADRawEntry left, ADRawEntry right, IEnumerable <PropertyDefinition> properties) { if (left == null) { return(null == right); } if (right == null) { return(null == left); } foreach (PropertyDefinition propertyDefinition in properties) { ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition; if (adpropertyDefinition.LdapDisplayName != null && !adpropertyDefinition.IsCalculated && !adpropertyDefinition.LdapDisplayName.Equals(ADObjectSchema.Id.LdapDisplayName, StringComparison.Ordinal)) { object obj = null; left.propertyBag.TryGetField(adpropertyDefinition, ref obj); object obj2 = null; right.propertyBag.TryGetField(adpropertyDefinition, ref obj2); if (obj != null || obj2 != null) { if (adpropertyDefinition.IsMultivalued) { if (!this.AreMultivaluedPropertiesEqual(obj, obj2, adpropertyDefinition)) { return(false); } } else { if (obj != null && obj2 == null) { return(false); } if (obj == null && obj2 != null) { return(false); } if (adpropertyDefinition.IsBinary) { byte[] left2 = ADValueConvertor.ConvertValueToBinary(obj, adpropertyDefinition.FormatProvider); byte[] right2 = ADValueConvertor.ConvertValueToBinary(obj2, adpropertyDefinition.FormatProvider); if (!ByteArrayComparer.Instance.Equals(left2, right2)) { return(false); } } else { string a = ADValueConvertor.ConvertValueToString(obj, adpropertyDefinition.FormatProvider); string b = ADValueConvertor.ConvertValueToString(obj2, adpropertyDefinition.FormatProvider); if (!string.Equals(a, b, StringComparison.Ordinal)) { return(false); } } } } } } return(true); }
private static object ConvertSingleValueForDirectoryProperty(SyncPropertyDefinition property, object value) { if (object.Equals(property.DefaultValue, value) && !property.PersistDefaultValue) { return(SyncValueConvertor.IgnoreValue); } if (value == null) { return(null); } if (typeof(DirectoryPropertyString).IsAssignableFrom(property.ExternalType) || property.ExternalType == typeof(string)) { return(ADValueConvertor.ConvertValueToString(value, property.FormatProvider)); } if (typeof(DirectoryPropertyGuid).IsAssignableFrom(property.ExternalType)) { return(ADValueConvertor.ConvertValueToString(value, property.FormatProvider)); } if (typeof(DirectoryPropertyBinary).IsAssignableFrom(property.ExternalType)) { return(ADValueConvertor.ConvertValueToBinary(value, property.FormatProvider)); } if (typeof(DirectoryPropertyBoolean).IsAssignableFrom(property.ExternalType)) { return(bool.Parse(ADValueConvertor.ConvertValueToString(value, property.FormatProvider))); } if (typeof(DirectoryPropertyInt32).IsAssignableFrom(property.ExternalType)) { return(int.Parse(ADValueConvertor.ConvertValueToString(value, property.FormatProvider))); } if (typeof(DirectoryPropertyDateTime).IsAssignableFrom(property.ExternalType)) { Type type = value.GetType(); if (type.Equals(typeof(DateTime))) { return(((DateTime)value).ToUniversalTime()); } return(DateTime.Parse(ADValueConvertor.ConvertValueToString(value, property.FormatProvider), property.FormatProvider)); } else { if (typeof(DirectoryPropertyXmlServiceOriginatedResource) == property.ExternalType && value is Capability) { Capability capability = (Capability)value; if (CapabilityHelper.IsAllowedSKUCapability(capability)) { Guid skucapabilityGuid = CapabilityHelper.GetSKUCapabilityGuid(capability); if (skucapabilityGuid != Guid.Empty) { return(new XmlValueServiceOriginatedResource { Resource = new ServiceOriginatedResourceValue { ServicePlanId = skucapabilityGuid.ToString("D"), Capability = capability.ToString() } }); } } return(SyncValueConvertor.IgnoreValue); } if (typeof(DirectoryPropertyXmlDirSyncStatus).IsAssignableFrom(property.ExternalType)) { string stringValue = (string)value; return(new XmlValueDirSyncStatus { DirSyncStatus = SyncValueConvertor.ConvertStringToDirSyncStatus(stringValue) }); } if (typeof(DirectoryPropertyReferenceAddressList).IsAssignableFrom(property.ExternalType) && value is PropertyReference) { PropertyReference propertyReference = (PropertyReference)value; return(new DirectoryReferenceAddressList { TargetClass = propertyReference.TargetObjectClass, Value = propertyReference.TargetId, TargetDeleted = propertyReference.TargetDeleted }); } throw new NotSupportedException("Conversion for external type " + property.ExternalType.Name); } }
private static object ConvertSingleValue(SyncPropertyDefinition property, object value, out ValidationError error) { error = null; if (value is XmlValueAssignedPlan) { return(((XmlValueAssignedPlan)value).Plan); } if (value is XmlValueCompanyVerifiedDomain) { return(((XmlValueCompanyVerifiedDomain)value).Domain); } if (value is XmlValueDirSyncStatus) { return(SyncValueConvertor.ConvertDirSyncStatusToString(((XmlValueDirSyncStatus)value).DirSyncStatus)); } if (value is AttributeSet) { return(SyncValueConvertor.ConvertAttributeSetToString((AttributeSet)value)); } if (value is XmlValueValidationError) { return(((XmlValueValidationError)value).ErrorInfo); } if (value is XmlValueLicenseUnitsDetail) { return(SyncValueConvertor.ConvertXmlValueLicenseUnitsDetailToString((XmlValueLicenseUnitsDetail)value)); } if (property == SyncSubscribedPlanSchema.Capability) { return(((XmlElement)value).OuterXml); } if (property == SyncCompanySchema.CompanyPartnership) { return(SyncValueConvertor.ConvertCompanyPartnershipToString((XmlValueCompanyPartnership)value)); } if (property == SyncRecipientSchema.SipAddresses) { string text = (string)value; if (!string.IsNullOrEmpty(text) && !text.StartsWith(ProxyAddressPrefix.SIP.ToString() + ':', StringComparison.OrdinalIgnoreCase)) { value = ProxyAddressPrefix.SIP.ToString() + ':' + text; } } else { if (property.Type == typeof(RemoteRecipientType)) { return((RemoteRecipientType)value); } if (property.Type == typeof(RecipientTypeDetails)) { return((RecipientTypeDetails)value); } if (property.Type == typeof(MailboxAuditOperations)) { return((MailboxAuditOperations)value); } if (property.Type == typeof(ElcMailboxFlags)) { return((ElcMailboxFlags)value); } if (property.Type == typeof(DateTime?)) { return((DateTime?)value); } if (property.Type == typeof(DateTime)) { return((DateTime)value); } if (property.Type == typeof(EnhancedTimeSpan)) { return(TimeSpan.FromSeconds((double)((int)value))); } if (value is XmlValueRightsManagementTenantConfiguration) { return(((XmlValueRightsManagementTenantConfiguration)value).RightsManagementTenantConfiguration); } if (value is XmlValueRightsManagementTenantKey) { return(((XmlValueRightsManagementTenantKey)value).RightsManagementTenantKey); } if (value is XmlValueServiceInfo) { return(((XmlValueServiceInfo)value).Info); } if (value is int || value is bool) { return(value); } if (value is DirectoryReferenceAddressList) { DirectoryReferenceAddressList directoryReferenceAddressList = (DirectoryReferenceAddressList)value; if (!directoryReferenceAddressList.TargetDeleted) { return(new PropertyReference(directoryReferenceAddressList.Value, directoryReferenceAddressList.TargetClass, directoryReferenceAddressList.TargetDeleted)); } return(null); } else if (value is DirectoryReferenceUserAndServicePrincipal) { DirectoryReferenceUserAndServicePrincipal directoryReferenceUserAndServicePrincipal = (DirectoryReferenceUserAndServicePrincipal)value; return(directoryReferenceUserAndServicePrincipal.Value); } } bool noConversionRequired = property.Type == typeof(byte[]) || property.Type == typeof(string); return(ADValueConvertor.ConvertFromADAndValidateSingleValue(value, property, noConversionRequired, out error)); }
private object ConvertValue(ADPropertyDefinition propertyDefinition, PropValue propValue) { if (propValue.IsError() || propValue.IsNull()) { return(null); } PropType propType = propValue.PropType; object[] values; if (propType <= PropType.SysTime) { if (propType <= PropType.Boolean) { if (propType != PropType.Int && propType != PropType.Boolean) { goto IL_174; } } else { switch (propType) { case PropType.AnsiString: values = new object[] { this.encoding.GetString(propValue.GetBytes()) }; goto IL_18F; case PropType.String: break; default: if (propType != PropType.SysTime) { goto IL_174; } break; } } } else if (propType <= PropType.Binary) { if (propType != PropType.Guid) { if (propType != PropType.Binary) { goto IL_174; } values = new object[] { propValue.RawValue }; goto IL_18F; } } else { switch (propType) { case PropType.AnsiStringArray: values = Array.ConvertAll <byte[], object>(propValue.GetBytesArray(), (byte[] bytesValue) => this.encoding.GetString(bytesValue)); goto IL_18F; case PropType.StringArray: values = Array.ConvertAll <string, object>(propValue.GetStringArray(), (string stringValue) => stringValue); goto IL_18F; default: if (propType != PropType.BinaryArray) { goto IL_174; } values = Array.ConvertAll <byte[], object>(propValue.GetBytesArray(), (byte[] bytesValue) => bytesValue); goto IL_18F; } } values = new object[] { propValue.RawValue.ToString() }; goto IL_18F; IL_174: throw new InvalidOperationException(string.Format("Property type {0} is not supported", propValue.GetType())); object result; try { IL_18F: result = ADValueConvertor.GetValueFromDirectoryAttributeValues(propertyDefinition, values); } catch (DataValidationException arg) { NspiPropertyMap.Tracer.TraceWarning <string, DataValidationException>((long)this.GetHashCode(), "Unable to handle property {0} because it has invalid value, exception: {1}", propertyDefinition.Name, arg); result = null; } return(result); }
// Token: 0x06000DD8 RID: 3544 RVA: 0x0003FF84 File Offset: 0x0003E184 private void ConvertComparisonFilterInternal(ComparisonFilter comparisonFilter, QueryFilter parentFilter, bool isSoftLink, byte softLinkPrefix = 0) { ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)comparisonFilter.Property; object obj = comparisonFilter.PropertyValue; string ldapDisplayName = adpropertyDefinition.LdapDisplayName; if (isSoftLink && adpropertyDefinition.IsSoftLinkAttribute) { ldapDisplayName = adpropertyDefinition.SoftLinkShadowProperty.LdapDisplayName; if (obj != null) { obj = ADObjectIdResolutionHelper.ResolveSoftLink((ADObjectId)obj); } } bool flag = adpropertyDefinition.Type.IsGenericType && adpropertyDefinition.Type.GetGenericTypeDefinition() == typeof(Unlimited <>); if (flag) { bool flag2 = adpropertyDefinition.DefaultValue.Equals(obj); switch (comparisonFilter.ComparisonOperator) { case ComparisonOperator.Equal: if (flag2) { this.IncrementFilterSize(2); this.ldapFilter.Append("(!("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*))"); return; } break; case ComparisonOperator.NotEqual: case ComparisonOperator.LessThan: if (flag2) { this.IncrementFilterSize(); this.ldapFilter.Append('('); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*)"); return; } break; case ComparisonOperator.LessThanOrEqual: if (flag2) { this.IncrementFilterSize(); this.ldapFilter.Append("(objectclass=*)"); return; } break; case ComparisonOperator.GreaterThan: if (flag2) { this.IncrementFilterSize(); this.ldapFilter.Append("(!(objectclass=*))"); return; } break; case ComparisonOperator.GreaterThanOrEqual: if (flag2) { this.IncrementFilterSize(2); this.ldapFilter.Append("(!("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*))"); return; } this.IncrementFilterSize(4); this.ldapFilter.Append("(|("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append(">="); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, isSoftLink, softLinkPrefix); this.ldapFilter.Append(")(!("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*)))"); return; } } switch (comparisonFilter.ComparisonOperator) { case ComparisonOperator.LessThan: this.ConvertCompositeFilter(new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.LessThanOrEqual, comparisonFilter.Property, obj), new ComparisonFilter(ComparisonOperator.NotEqual, comparisonFilter.Property, obj) }), parentFilter); return; case ComparisonOperator.GreaterThan: this.ConvertCompositeFilter(new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, comparisonFilter.Property, obj), new ComparisonFilter(ComparisonOperator.NotEqual, comparisonFilter.Property, obj) }), parentFilter); return; } if (!adpropertyDefinition.PersistDefaultValue && !flag && adpropertyDefinition.DefaultValue != null && adpropertyDefinition.DefaultValue.Equals(comparisonFilter.PropertyValue)) { switch (comparisonFilter.ComparisonOperator) { case ComparisonOperator.Equal: this.IncrementFilterSize(4); this.ldapFilter.Append("(|("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("="); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, adpropertyDefinition.DefaultValue, this.ldapFilter, isSoftLink, softLinkPrefix); this.ldapFilter.Append(")(!("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*)))"); return; case ComparisonOperator.NotEqual: this.IncrementFilterSize(4); this.ldapFilter.Append("(&(!("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("="); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, adpropertyDefinition.DefaultValue, this.ldapFilter, isSoftLink, softLinkPrefix); this.ldapFilter.Append("))("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*))"); return; default: throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedDefaultValueFilter(adpropertyDefinition.Name, comparisonFilter.ComparisonOperator.ToString(), (comparisonFilter.PropertyValue == null) ? string.Empty : obj.ToString())); } } else { string value = string.Empty; switch (comparisonFilter.ComparisonOperator) { case ComparisonOperator.Equal: value = "="; goto IL_49B; case ComparisonOperator.NotEqual: value = "="; goto IL_49B; case ComparisonOperator.LessThanOrEqual: value = "<="; goto IL_49B; case ComparisonOperator.GreaterThanOrEqual: value = ">="; goto IL_49B; } throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedOperator(comparisonFilter.ComparisonOperator.ToString(), typeof(ComparisonFilter).ToString())); IL_49B: if (comparisonFilter.ComparisonOperator == ComparisonOperator.NotEqual) { this.IncrementFilterSize(2); this.ldapFilter.Append("(!("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append(value); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, isSoftLink, softLinkPrefix); this.ldapFilter.Append("))"); return; } if (adpropertyDefinition == ADObjectSchema.Id && Guid.Empty != ((ADObjectId)obj).ObjectGuid && this.tenantScoped && comparisonFilter.ComparisonOperator == ComparisonOperator.Equal) { this.IncrementFilterSize(3); this.ldapFilter.Append("(|("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append(value); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, false, softLinkPrefix); this.ldapFilter.Append(")("); this.ldapFilter.Append(ADObjectSchema.CorrelationIdRaw.LdapDisplayName); this.ldapFilter.Append(value); this.ldapFilter.Append(ADValueConvertor.EscapeBinaryValue(((ADObjectId)obj).ObjectGuid.ToByteArray())); this.ldapFilter.Append("))"); return; } if (adpropertyDefinition == ADObjectSchema.Guid && this.tenantScoped && comparisonFilter.ComparisonOperator == ComparisonOperator.Equal) { string value2 = ADValueConvertor.EscapeBinaryValue(((Guid)obj).ToByteArray()); this.IncrementFilterSize(3); this.ldapFilter.Append("(|("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append(value); this.ldapFilter.Append(value2); this.ldapFilter.Append(")("); this.ldapFilter.Append(ADObjectSchema.CorrelationIdRaw.LdapDisplayName); this.ldapFilter.Append(value); this.ldapFilter.Append(value2); this.ldapFilter.Append("))"); return; } this.IncrementFilterSize(); this.ldapFilter.Append("("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append(value); ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, isSoftLink, softLinkPrefix); this.ldapFilter.Append(")"); return; } }