/// <summary> /// The constructure with attribute name and attribute vaule params. /// </summary> /// <param name="attributeName">The attribute name which can be find in Landpy.ActiveDirectory.Entity.Attribute.Name namespace or custom set.</param> /// <param name="attributeValue">The attribute value which can be find in Landpy.ActiveDirectory.Entity.Attribute.Value namespace or custom set.</param> protected AttributeKeyValueFilter(string attributeName, string attributeValue) { this.AttributeName = attributeName; if (attributeName.Equals(AttributeNames.ObjectGuid, StringComparison.CurrentCultureIgnoreCase)) { this.AttributeValue = GuidHexConvertor.Convert(new Guid(attributeValue)); } else { this.AttributeValue = attributeValue.Replace(@"\", @"\5c").Replace(@"*", @"\2a").Replace(@"(", @"\28").Replace(@")", @"\29").Replace(@"/", @"\2f"); } }
/// <summary> /// The constructure with native fitler string param. /// </summary> /// <param name="filterString">The native filter string.</param> public Custom(string filterString) { if (filterString.IndexOf(AttributeNames.ObjectGuid, StringComparison.CurrentCultureIgnoreCase) != -1) { string hexFilterString = filterString; string[] filterSections = filterString.Split(new char[] { '(', ')' }); foreach (var filterSection in filterSections) { if (filterSection.IndexOf(AttributeNames.ObjectGuid, StringComparison.CurrentCultureIgnoreCase) != -1) { string hexFilterSection = String.Format(@"{0}{1}", filterSection.Substring(0, 11), GuidHexConvertor.Convert(new Guid(filterSection.Substring(11)))); hexFilterString = hexFilterString.Replace(filterSection, hexFilterSection); } } this.FilterString = hexFilterString; } else { this.FilterString = filterString; } }