/// <summary> Constructs a Control object by decoding from an Asn1Sequence</summary> public RfcControl(Asn1Sequence seqObj) : base(3) { int len = seqObj.size(); for (int i = 0; i < len; i++) { add(seqObj.get_Renamed(i)); } }
/// <summary> Constructs an object from the responseValue which contains the list /// of replicas. /// /// The constructor parses the responseValue which has the following /// format: /// responseValue ::= /// replicaList /// SEQUENCE OF OCTET STRINGS /// /// </summary> /// <exception> IOException The responseValue could not be decoded. /// </exception> public ListReplicasResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { if (ResultCode != LdapException.SUCCESS) { replicaList = new string[0]; } else { // parse the contents of the reply sbyte[] returnedValue = this.Value; if (returnedValue == null) { throw new IOException("No returned value"); } // Create a decoder object LBERDecoder decoder = new LBERDecoder(); if (decoder == null) { throw new IOException("Decoding error"); } // We should get back a sequence Asn1Sequence returnedSequence = (Asn1Sequence)decoder.decode(returnedValue); if (returnedSequence == null) { throw new IOException("Decoding error"); } // How many replicas were returned int len = returnedSequence.size(); replicaList = new string[len]; // Copy each one into our String array for (int i = 0; i < len; i++) { // Get the next Asn1Octet String in the sequence Asn1OctetString asn1_nextReplica = (Asn1OctetString)returnedSequence.get_Renamed(i); if (asn1_nextReplica == null) { throw new IOException("Decoding error"); } // Convert to a string replicaList[i] = asn1_nextReplica.stringValue(); if (replicaList[i] == null) { throw new IOException("Decoding error"); } } } }
public LdapEntryChangeControl(String oid, bool critical, sbyte[] value_Renamed) : base(oid, critical, value_Renamed) { // Create a decoder objet LBERDecoder decoder = new LBERDecoder(); if (decoder == null) { throw new System.IO.IOException("Decoding error."); } // We should get a sequence initially Asn1Object asnObj = decoder.decode(value_Renamed); if ((asnObj == null) || (!(asnObj is Asn1Sequence))) { throw new System.IO.IOException("Decoding error."); } Asn1Sequence sequence = (Asn1Sequence)asnObj; // The first element in the sequence should be an enumerated type Asn1Object asn1Obj = sequence.get_Renamed(0); if ((asn1Obj == null) || (!(asn1Obj is Asn1Enumerated))) { throw new System.IO.IOException("Decoding error."); } m_changeType = ((Asn1Enumerated)asn1Obj).intValue(); //check for optional elements if ((sequence.size() > 1) && (m_changeType == 8)) //8 means modifyDN { // get the previous DN - it is encoded as an octet string asn1Obj = sequence.get_Renamed(1); if ((asn1Obj == null) || (!(asn1Obj is Asn1OctetString))) { throw new System.IO.IOException("Decoding error get previous DN"); } m_previousDN = ((Asn1OctetString)asn1Obj).stringValue(); } else { m_previousDN = ""; } //check for change number if (sequence.size() == 3) { asn1Obj = sequence.get_Renamed(2); if ((asn1Obj == null) || (!(asn1Obj is Asn1Integer))) { throw new System.IO.IOException("Decoding error getting change number"); } m_changeNumber = ((Asn1Integer)asn1Obj).intValue(); m_hasChangeNumber = true; } else { m_hasChangeNumber = false; } return; }
protected void ProcessMessage(sbyte[] returnedValue) { LBERDecoder decoder = new LBERDecoder(); Asn1Sequence sequence = (Asn1Sequence)decoder.decode(returnedValue); event_type = (EdirEventType)(((Asn1Integer)sequence.get_Renamed(0)).intValue()); event_result_type = (EdirEventResultType)(((Asn1Integer)sequence.get_Renamed(1)).intValue()); if (sequence.size() > 2) { Asn1Tagged objTagged = (Asn1Tagged)sequence.get_Renamed(2); switch ((EdirEventDataType)(objTagged.getIdentifier().Tag)) { case EdirEventDataType.EDIR_TAG_ENTRY_EVENT_DATA: event_response_data = new EntryEventData(EdirEventDataType.EDIR_TAG_ENTRY_EVENT_DATA, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_VALUE_EVENT_DATA: event_response_data = new ValueEventData(EdirEventDataType.EDIR_TAG_VALUE_EVENT_DATA, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_DEBUG_EVENT_DATA: event_response_data = new DebugEventData(EdirEventDataType.EDIR_TAG_DEBUG_EVENT_DATA, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_GENERAL_EVENT_DATA: event_response_data = new GeneralDSEventData(EdirEventDataType.EDIR_TAG_GENERAL_EVENT_DATA, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_SKULK_DATA: event_response_data = null; break; case EdirEventDataType.EDIR_TAG_BINDERY_EVENT_DATA: event_response_data = new BinderyObjectEventData(EdirEventDataType.EDIR_TAG_BINDERY_EVENT_DATA, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_DSESEV_INFO: event_response_data = new SecurityEquivalenceEventData(EdirEventDataType.EDIR_TAG_DSESEV_INFO, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_MODULE_STATE_DATA: event_response_data = new ModuleStateEventData(EdirEventDataType.EDIR_TAG_MODULE_STATE_DATA, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_NETWORK_ADDRESS: event_response_data = new NetworkAddressEventData(EdirEventDataType.EDIR_TAG_NETWORK_ADDRESS, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_CONNECTION_STATE: event_response_data = new ConnectionStateEventData(EdirEventDataType.EDIR_TAG_CONNECTION_STATE, objTagged.taggedValue()); break; case EdirEventDataType.EDIR_TAG_CHANGE_SERVER_ADDRESS: event_response_data = new ChangeAddressEventData(EdirEventDataType.EDIR_TAG_CHANGE_SERVER_ADDRESS, objTagged.taggedValue()); break; /* * case EdirEventDataType.EDIR_TAG_CHANGE_CONFIG_PARAM : * responsedata = * new ChangeConfigEventData( * taggedobject.taggedValue()); * * break; * * case EdirEventDataType.EDIR_TAG_STATUS_LOG : * responsedata = * new StatusLogEventData(taggedobject.taggedValue()); * * break; */ case EdirEventDataType.EDIR_TAG_NO_DATA: event_response_data = null; break; default: //unhandled data. throw new IOException(); } } else { //NO DATA event_response_data = null; } }
/// <summary> Constructs an object from the responseValue which contains the replication /// filter. /// /// The constructor parses the responseValue which has the following /// format: /// responseValue ::= /// SEQUENCE of SEQUENCE { /// classname OCTET STRING /// SEQUENCE of ATTRIBUTES /// } /// where /// ATTRIBUTES:: OCTET STRING /// /// </summary> /// <exception> IOException The responseValue could not be decoded. /// </exception> public GetReplicationFilterResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { if (ResultCode != LdapException.SUCCESS) { returnedFilter = new System.String[0][]; for (int i = 0; i < 0; i++) { returnedFilter[i] = new System.String[0]; } } else { // parse the contents of the reply sbyte[] returnedValue = this.Value; if (returnedValue == null) { throw new System.IO.IOException("No returned value"); } // Create a decoder object LBERDecoder decoder = new LBERDecoder(); if (decoder == null) { throw new System.IO.IOException("Decoding error"); } // We should get back a sequence Asn1Sequence returnedSequence = (Asn1Sequence)decoder.decode(returnedValue); if (returnedSequence == null) { throw new System.IO.IOException("Decoding error"); } // How many sequences in this list int numberOfSequences = returnedSequence.size(); returnedFilter = new System.String[numberOfSequences][]; // Parse each returned sequence object for (int classNumber = 0; classNumber < numberOfSequences; classNumber++) { // Get the next Asn1Sequence Asn1Sequence asn1_innerSequence = (Asn1Sequence)returnedSequence.get_Renamed(classNumber); if (asn1_innerSequence == null) { throw new System.IO.IOException("Decoding error"); } // Get the asn1 encoded classname Asn1OctetString asn1_className = (Asn1OctetString)asn1_innerSequence.get_Renamed(0); if (asn1_className == null) { return; } // Get the attribute List Asn1Sequence asn1_attributeList = (Asn1Sequence)asn1_innerSequence.get_Renamed(1); if (asn1_attributeList == null) { throw new System.IO.IOException("Decoding error"); } int numberOfAttributes = asn1_attributeList.size(); returnedFilter[classNumber] = new System.String[numberOfAttributes + 1]; // Get the classname returnedFilter[classNumber][0] = asn1_className.stringValue(); if ((System.Object)returnedFilter[classNumber][0] == null) { throw new System.IO.IOException("Decoding error"); } for (int attributeNumber = 0; attributeNumber < numberOfAttributes; attributeNumber++) { // Get the asn1 encoded attribute name Asn1OctetString asn1_attributeName = (Asn1OctetString)asn1_attributeList.get_Renamed(attributeNumber); if (asn1_attributeName == null) { throw new System.IO.IOException("Decoding error"); } // Get attributename string returnedFilter[classNumber][attributeNumber + 1] = asn1_attributeName.stringValue(); if ((System.Object)returnedFilter[classNumber][attributeNumber + 1] == null) { throw new System.IO.IOException("Decoding error"); } } } } }