/// <summary> Encode an array of LdapModifications to ASN.1. /// /// </summary> /// <param name="mods">an array of LdapModification objects /// /// </param> /// <returns> an Asn1SequenceOf object containing the modifications. /// </returns> static private Asn1SequenceOf encodeModifications(LdapModification[] mods) { // Convert Java-API LdapModification[] to RFC2251 SEQUENCE OF SEQUENCE Asn1SequenceOf rfcMods = new Asn1SequenceOf(mods.Length); for (int i = 0; i < mods.Length; i++) { LdapAttribute attr = mods[i].Attribute; // place modification attribute values in Asn1SetOf Asn1SetOf vals = new Asn1SetOf(attr.size()); if (attr.size() > 0) { System.Collections.IEnumerator attrEnum = attr.ByteValues; while (attrEnum.MoveNext()) { vals.add(new RfcAttributeValue((sbyte[])attrEnum.Current)); } } // create SEQUENCE containing mod operation and attr type and vals Asn1Sequence rfcMod = new Asn1Sequence(2); rfcMod.add(new Asn1Enumerated(mods[i].Op)); rfcMod.add(new RfcAttributeTypeAndValues(new RfcAttributeDescription(attr.Name), vals)); // place SEQUENCE into SEQUENCE OF rfcMods.add(rfcMod); } return(rfcMods); }
/// <summary> Build the attribuite list from an LdapEntry. /// /// </summary> /// <param name="entry">The LdapEntry associated with this add request. /// </param> private static RfcAttributeList makeRfcAttrList(LdapEntry entry) { // convert Java-API LdapEntry to RFC2251 AttributeList LdapAttributeSet attrSet = entry.getAttributeSet(); RfcAttributeList attrList = new RfcAttributeList(attrSet.Count); IEnumerator itr = attrSet.GetEnumerator(); while (itr.MoveNext()) { LdapAttribute attr = (LdapAttribute)itr.Current; Asn1SetOf vals = new Asn1SetOf(attr.size()); IEnumerator attrEnum = attr.ByteValues; while (attrEnum.MoveNext()) { vals.add(new RfcAttributeValue((sbyte[])attrEnum.Current)); } attrList.add(new RfcAttributeTypeAndValues(new RfcAttributeDescription(attr.Name), vals)); } return(attrList); }