public MonitorEventResponse(RfcLdapMessage message) : base(message) { sbyte[] returnedValue = Value; if (null == returnedValue) { throw new LdapException(LdapException.resultCodeToString(ResultCode), ResultCode, null); } LBERDecoder decoder = new LBERDecoder(); Asn1Sequence sequence = (Asn1Sequence)decoder.decode(returnedValue); int length = ((Asn1Integer)sequence.get_Renamed(0)).intValue(); Asn1Set sequenceSet = (Asn1Set)sequence.get_Renamed(1); specifier_list = new EdirEventSpecifier[length]; for (int i = 0; i < length; i++) { Asn1Sequence eventspecifiersequence = (Asn1Sequence)sequenceSet.get_Renamed(i); int classfication = ((Asn1Integer)eventspecifiersequence.get_Renamed(0)).intValue(); int enumtype = ((Asn1Enumerated)eventspecifiersequence.get_Renamed(1)).intValue(); specifier_list[i] = new EdirEventSpecifier((EdirEventType)classfication, (EdirEventResultType)enumtype); } }
/// <summary> Constructs an object from the responseValue which contains the /// entry count. /// /// The constructor parses the responseValue which has the following /// format: /// responseValue ::= /// count INTEGER /// /// </summary> /// <exception> IOException The response value could not be decoded. /// </exception> public PartitionEntryCountResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { if (ResultCode == LdapException.SUCCESS) { // parse the contents of the reply sbyte[] returnedValue = 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"); } Asn1Integer asn1_count = (Asn1Integer)decoder.decode(returnedValue); if (asn1_count == null) { throw new System.IO.IOException("Decoding error"); } count = asn1_count.intValue(); } else { count = -1; } }
/// <summary> /// Constructs an object from the responseValue which contains the effective /// privileges. /// The constructor parses the responseValue which has the following /// format: /// responseValue ::= /// privileges INTEGER /// </summary> /// <exception> /// IOException The responseValue could not be decoded. /// </exception> public GetEffectivePrivilegesResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { if (ResultCode == LdapException.SUCCESS) { // parse the contents of the reply var returnedValue = Value; if (returnedValue == null) { throw new IOException("No returned value"); } // Create a decoder object var decoder = new LBERDecoder(); if (decoder == null) { throw new IOException("Decoding error"); } var asn1_privileges = (Asn1Integer)decoder.decode(returnedValue); if (asn1_privileges == null) { throw new IOException("Decoding error"); } privileges = asn1_privileges.intValue(); } else { privileges = 0; } }
/** * Used to Convert an RfcLDAPMessage object to the appropriate * LDAPIntermediateResponse object depending on the operation being performed. * * @param inResponse The LDAPIntermediateResponse object as returned by the * extendedOperation method in the LDAPConnection object. * <br><br> * @return An object of base class LDAPIntermediateResponse. The actual child * class of this returned object depends on the operation being * performed. * * @exception LDAPException A general exception which includes an error message * and an LDAP error code. */ public static LdapIntermediateResponse ConvertToIntermediateResponse(RfcLdapMessage inResponse) // throws LDAPException { var tempResponse = new LdapIntermediateResponse(inResponse); // Get the oid stored in the Extended response var inOid = tempResponse.GetId(); var regExtResponses = LdapIntermediateResponse.GetRegisteredResponses(); try { var extRespClass = regExtResponses.FindResponseExtension(inOid); if (extRespClass == null) { return(tempResponse); } Type[] argsClass = { typeof(RfcLdapMessage) }; object[] args = { inResponse }; Exception ex; try { var extConstructor = extRespClass.GetConstructor(argsClass); try { object resp = null; resp = extConstructor.Invoke(args); return((LdapIntermediateResponse)resp); } catch (UnauthorizedAccessException e) { ex = e; } catch (TargetInvocationException e) { ex = e; } } catch (MissingMethodException e) { // bad class was specified, fall through and return a // default LDAPIntermediateResponse object ex = e; } } catch (MissingFieldException ex) { // No match with the OID // Do nothing. Fall through and construct a default LDAPControl object. Logger.Log.LogWarning("Exception swallowed", ex); } // If we get here we did not have a registered extendedresponse // for this oid. Return a default LDAPIntermediateResponse object. return(tempResponse); }
/// <summary> Used to Convert an RfcLdapMessage object to the appropriate /// LdapExtendedResponse object depending on the operation being performed. /// /// </summary> /// <param name="inResponse"> The LdapExtendedReponse object as returned by the /// extendedOperation method in the LdapConnection object. /// </param> /// <returns> An object of base class LdapExtendedResponse. The actual child /// class of this returned object depends on the operation being /// performed. /// </returns> static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse) { LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse); // Get the oid stored in the Extended response System.String inOID = tempResponse.ID; RespExtensionSet regExtResponses = LdapExtendedResponse.RegisteredResponses; try { System.Type extRespClass = regExtResponses.findResponseExtension(inOID); if (extRespClass == null) { return(tempResponse); } System.Type[] argsClass = new System.Type[] { typeof(RfcLdapMessage) }; System.Object[] args = new System.Object[] { inResponse }; System.Exception ex; try { System.Reflection.ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass); try { System.Object resp = null; resp = extConstructor.Invoke(args); return((LdapExtendedResponse)resp); } catch (System.UnauthorizedAccessException e) { ex = e; } catch (System.Reflection.TargetInvocationException e) { ex = e; } catch (System.Exception e) { // Could not create the ResponseControl object // All possible exceptions are ignored. We fall through // and create a default LdapControl object ex = e; } } catch (System.MethodAccessException e) { // bad class was specified, fall through and return a // default LdapExtendedResponse object ex = e; } } catch (System.FieldAccessException e) { } // If we get here we did not have a registered extendedresponse // for this oid. Return a default LdapExtendedResponse object. return(tempResponse); }
/// <summary> /// Used to Convert an RfcLdapMessage object to the appropriate /// LdapExtendedResponse object depending on the operation being performed. /// </summary> /// <param name="inResponse"> /// The LdapExtendedReponse object as returned by the /// extendedOperation method in the LdapConnection object. /// </param> /// <returns> /// An object of base class LdapExtendedResponse. The actual child /// class of this returned object depends on the operation being /// performed. /// </returns> public static LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse) { var tempResponse = new LdapExtendedResponse(inResponse); // Get the oid stored in the Extended response var inOID = tempResponse.ID; var regExtResponses = LdapExtendedResponse.RegisteredResponses; try { var extRespClass = regExtResponses.findResponseExtension(inOID); if (extRespClass == null) { return(tempResponse); } Type[] argsClass = { typeof(RfcLdapMessage) }; object[] args = { inResponse }; Exception ex; try { var extConstructor = extRespClass.GetConstructor(argsClass); try { object resp = null; resp = extConstructor.Invoke(args); return((LdapExtendedResponse)resp); } catch (UnauthorizedAccessException e) { ex = e; } catch (TargetInvocationException e) { ex = e; } catch (Exception e) { // Could not create the ResponseControl object // All possible exceptions are ignored. We fall through // and create a default LdapControl object ex = e; } } catch (MethodAccessException e) { // bad class was specified, fall through and return a // default LdapExtendedResponse object ex = e; } } catch (FieldAccessException ex) { Logger.Log.LogWarning("Exception swallowed", ex); } // If we get here we did not have a registered extendedresponse // for this oid. Return a default LdapExtendedResponse object. return(tempResponse); }
/** * Used to Convert an RfcLDAPMessage object to the appropriate * LDAPIntermediateResponse object depending on the operation being performed. * * @param inResponse The LDAPIntermediateResponse object as returned by the * extendedOperation method in the LDAPConnection object. * <br><br> * @return An object of base class LDAPIntermediateResponse. The actual child * class of this returned object depends on the operation being * performed. * * @exception LDAPException A general exception which includes an error message * and an LDAP error code. */ static public LdapIntermediateResponse convertToIntermediateResponse(RfcLdapMessage inResponse) // throws LDAPException { LdapIntermediateResponse tempResponse = new LdapIntermediateResponse(inResponse); // Get the oid stored in the Extended response String inOID = tempResponse.getID(); RespExtensionSet regExtResponses = LdapIntermediateResponse.getRegisteredResponses(); try { Type extRespClass = regExtResponses.findResponseExtension(inOID); if (extRespClass == null) { return(tempResponse); } Type[] argsClass = new Type[] { typeof(RfcLdapMessage) }; Object[] args = { inResponse }; Exception ex; try { ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass); try { Object resp = null; resp = extConstructor.Invoke(args); return((LdapIntermediateResponse)resp); } catch (UnauthorizedAccessException e) { ex = e; } catch (TargetInvocationException e) { ex = e; } } catch (MissingMethodException e) { // bad class was specified, fall through and return a // default LDAPIntermediateResponse object ex = e; } } catch (MissingFieldException) { // No match with the OID // Do nothing. Fall through and construct a default LDAPControl object. } // If we get here we did not have a registered extendedresponse // for this oid. Return a default LDAPIntermediateResponse object. return(tempResponse); }
/// <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 GetEffectivePrivilegesListResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { /// <summary> Constructs an object from the responseValue which contains the effective /// privileges. /// /// The constructor parses the responseValue which has the following /// format: /// responseValue ::=<br> /// <p>SEQUENCE numberofresponses ::= INTEGER <br> /// SET of [<br> /// SEQUENCES of {privileges INTEGER}]<br> /// /// </summary> /// <exception> IOException The responseValue could not be decoded. /// </exception> if (ResultCode == LdapException.SUCCESS) { // 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"); } Asn1Sequence asn1_seq1 = (Asn1Sequence)decoder.decode(returnedValue); if (asn1_seq1 == null) { throw new IOException("Decoding error"); } Asn1Sequence asn1_seq2 = (Asn1Sequence)asn1_seq1.get_Renamed(0); no_privileges = ((Asn1Integer)asn1_seq2.get_Renamed(0)).intValue(); Asn1Set set_privileg_response = null; set_privileg_response = (Asn1Set)asn1_seq1.get_Renamed(1); Asn1Sequence seq2 = null; privileges = new int[no_privileges]; for (int index = 0; index < no_privileges; index++) { seq2 = (Asn1Sequence)set_privileg_response.get_Renamed(index); privileges[index] = ((Asn1Integer)seq2.get_Renamed(0)).intValue(); } } }
public LdapWhoAmIResponse(RfcLdapMessage message) : base(message) { AuthzId = ((RfcExtendedResponse)message.Response)?.Response?.StringValue(); AuthzIdWithoutType = AuthzId; AuthzIdType = AuthzType.None; if (!string.IsNullOrEmpty(AuthzId)) { // Seems like sometimes, control characters are prepended to the actual value var cutIndex = 0; foreach (var c in AuthzId) { if (char.IsControl(c) || c == '"') { cutIndex++; } else { break; } } if (cutIndex > 0) { AuthzId = AuthzId.Substring(cutIndex); } if (AuthzId.StartsWith("u:")) { AuthzIdType = AuthzType.User; AuthzIdWithoutType = AuthzId.Substring(2); } else if (AuthzId.StartsWith("dn:")) { AuthzIdType = AuthzType.DistinguishedName; AuthzIdWithoutType = AuthzId.Substring(3); } else { AuthzIdType = AuthzType.Unknown; } } }
/// <summary> /// Creates an LdapMessage when sending a protocol operation and sends /// some optional controls with the message. /// </summary> /// <param name="op"> /// The operation type of message. /// </param> /// <param name="controls"> /// The controls to use with the operation. /// </param> /// <seealso cref="Type"> /// </seealso> /*package*/ internal LdapMessage(int type, IRfcRequest op, LdapControl[] controls) { // Get a unique number for this request message _messageType = type; RfcControls asn1Ctrls = null; if (controls != null) { // Move LdapControls into an RFC 2251 Controls object. asn1Ctrls = new RfcControls(); for (var i = 0; i < controls.Length; i++) { // asn1Ctrls.add(null); asn1Ctrls.Add(controls[i].Asn1Object); } } // create RFC 2251 LdapMessage Message = new RfcLdapMessage(op, asn1Ctrls); }
/// <summary> /// Initializes a new instance of the <see cref="LdapMessage"/> class. /// Creates an LdapMessage when sending a protocol operation and sends /// some optional controls with the message. /// </summary> /// <param name="type">The type.</param> /// <param name="op">The operation type of message.</param> /// <param name="controls">The controls to use with the operation.</param> /// <seealso cref="Type"></seealso> internal LdapMessage(LdapOperation type, IRfcRequest op, LdapControl[] controls = null) { // Get a unique number for this request message _messageType = type; RfcControls asn1Ctrls = null; if (controls != null) { // Move LdapControls into an RFC 2251 Controls object. asn1Ctrls = new RfcControls(); foreach (var t in controls) { asn1Ctrls.Add(t.Asn1Object); } } // create RFC 2251 LdapMessage Message = new RfcLdapMessage(op, asn1Ctrls); }
/// <summary> Constructs an object from the responseValue which contains the bind dn. /// /// The constructor parses the responseValue which has the following /// format: /// responseValue ::= /// identity OCTET STRING /// /// </summary> /// <exception> IOException The return value could not be decoded. /// </exception> public GetBindDNResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { if (ResultCode == LdapException.SUCCESS) { // 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"); } // The only parameter returned should be an octet string Asn1OctetString asn1_identity = (Asn1OctetString)decoder.decode(returnedValue); if (asn1_identity == null) { throw new IOException("Decoding error"); } // Convert to normal string object identity = asn1_identity.stringValue(); if (identity == null) { throw new IOException("Decoding error"); } } else { identity = ""; } }
/// <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"); } } } } }
/** * Constructs an object from the responseValue which contains the backup data. * <p>The constructor parses the responseValue which has the following * format:<br> * responseValue ::=<br> * <p>databufferLength ::= INTEGER <br> * mts(modification time stamp) ::= INTEGER<br> * revision ::= INTEGER<br> * returnedBuffer ::= OCTET STRING<br> * dataChunkSizes ::= <br> * SEQUENCE{<br> * noOfChunks INTEGER<br> * SET of [<br> * SEQUENCE of {eachChunksize INTEGER}]<br> * }</p> * * @exception IOException The responseValue could not be decoded. */ public LdapBackupResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { int modificationTime = 0; // Modifaction timestamp of the Object int revision = 0; // Revision number of the Object int chunksSize = 0; int[] chunks = null; //Holds size of each chunks returned from server //Verify if returned ID is not proper if (ID == null || !(ID.Equals(BackupRestoreConstants.NLDAP_LDAP_BACKUP_RESPONSE))) { throw new IOException("LDAP Extended Operation not supported"); } if (ResultCode == LdapException.SUCCESS) { // Get the contents of the reply byte[] returnedValue = SupportClass.ToByteArray(Value); if (returnedValue == null) { throw new Exception("LDAP Operations error. No returned value."); } // Create a decoder object LBERDecoder decoder = new LBERDecoder(); if (decoder == null) { throw new Exception("Decoding error"); } // Parse the parameters in the order MemoryStream currentPtr = new MemoryStream(returnedValue); // Parse bufferLength Asn1Integer asn1_bufferLength = (Asn1Integer)decoder .decode(currentPtr); if (asn1_bufferLength == null) { throw new IOException("Decoding error"); } bufferLength = asn1_bufferLength.intValue(); // Parse modificationTime Asn1Integer asn1_modificationTime = (Asn1Integer)decoder .decode(currentPtr); if (asn1_modificationTime == null) { throw new IOException("Decoding error"); } modificationTime = asn1_modificationTime.intValue(); // Parse revision Asn1Integer asn1_revision = (Asn1Integer)decoder .decode(currentPtr); if (asn1_revision == null) { throw new IOException("Decoding error"); } revision = asn1_revision.intValue(); //Format stateInfo to contain both modificationTime and revision stateInfo = modificationTime + "+" + revision; // Parse returnedBuffer Asn1OctetString asn1_returnedBuffer = (Asn1OctetString)decoder.decode(currentPtr); if (asn1_returnedBuffer == null) { throw new IOException("Decoding error"); } returnedBuffer = SupportClass.ToByteArray(asn1_returnedBuffer.byteValue()); /* * Parse chunks array * Chunks returned from server is encoded as shown below:: * SEQUENCE{ * chunksSize INTEGER * SET of [ * SEQUENCE of {eacChunksize INTEGER}] * } */ Asn1Sequence asn1_chunksSeq = (Asn1Sequence)decoder .decode(currentPtr); if (asn1_chunksSeq == null) { throw new IOException("Decoding error"); } //Get number of chunks returned from server chunksSize = ((Asn1Integer)asn1_chunksSeq.get_Renamed(0)).intValue(); //Construct chunks array chunks = new int[chunksSize]; Asn1Set asn1_chunksSet = (Asn1Set)asn1_chunksSeq.get_Renamed(1); //Iterate through asn1_chunksSet and put each size into chunks array for (int index = 0; index < chunksSize; index++) { Asn1Sequence asn1_eachSeq = (Asn1Sequence)asn1_chunksSet.get_Renamed(index); chunks[index] = ((Asn1Integer)asn1_eachSeq.get_Renamed(0)).intValue(); } //Construct a temporary StringBuffer and append chunksSize, each size //element in chunks array and actual data of eDirectoty Object System.Text.StringBuilder tempBuffer = new System.Text.StringBuilder(); tempBuffer.Append(chunksSize); tempBuffer.Append(";"); int i = 0; for (; i < (chunksSize - 1); i++) { tempBuffer.Append(chunks[i]); tempBuffer.Append(";"); } tempBuffer.Append(chunks[i]); //Assign tempBuffer to parsedString to be returned to Application chunkSizesString = tempBuffer.ToString(); } else { //Intialize all these if getResultCode() != LdapException.SUCCESS bufferLength = 0; stateInfo = null; chunkSizesString = null; returnedBuffer = null; } }
/// <summary> Creates an LdapExtendedResponse object which encapsulates /// a server response to an asynchronous extended operation request. /// /// </summary> /// <param name="message"> The RfcLdapMessage to convert to an /// LdapExtendedResponse object. /// </param> public LdapExtendedResponse(RfcLdapMessage message) : base(message) { }
public EdirEventIntermediateResponse(RfcLdapMessage message) : base(message) { ProcessMessage(getValue()); }
/// <summary> /// Constructs an LdapSearchResult object. /// </summary> /// <param name="message"> /// The RfcLdapMessage with a search result. /// </param> /*package*/ internal LdapSearchResult(RfcLdapMessage message) : base(message) { }
/// <summary> /// Creates an Rfc 2251 LdapMessage when the libraries receive a response /// from a command. /// </summary> /// <param name="message"> /// A response message. /// </param> protected internal LdapMessage(RfcLdapMessage message) { Message = message; }
internal virtual void putReply(RfcLdapMessage message) { if (!acceptReplies) { return; } lock (replies) { replies.Add(message); } message.RequestingMessage = msg; // Save request message info switch (message.Type) { case LdapMessage.SEARCH_RESPONSE: case LdapMessage.SEARCH_RESULT_REFERENCE: case LdapMessage.INTERMEDIATE_RESPONSE: break; default: int res; stopTimer(); // Accept no more results for this message // Leave on connection queue so we can abandon if necessary acceptReplies = false; complete = true; if (bindprops != null) { res = ((RfcResponse)message.Response).getResultCode().intValue(); if (res != LdapException.SASL_BIND_IN_PROGRESS) { if (conn == null) { LogManager.GetCurrentClassLogger().Error("Null connection; creation stack {0}, cleanup stack {1}", _stackTraceCreation, _stackTraceCleanup); } int id; // We either have success or failure on the bind if (res == LdapException.SUCCESS) { // Set bind properties into connection object conn.BindProperties = bindprops; } // If not a sasl bind in-progress, release the bind // semaphore and wake up all waiting threads if (conn.BindSemIdClear) { // Semaphore id for normal operations id = msgId; } else { // Semaphore id for sasl bind id = conn.BindSemId; conn.clearBindSemId(); } conn.freeWriteSemaphore(id); } } break; } // wake up waiting threads sleepersAwake(); }
/** * Creates an LdapIntermediateResponse object which encapsulates * a server response to an asynchronous extended operation request. * * @param message The RfcLdapMessage to convert to an * LdapIntermediateResponse object. */ public LdapIntermediateResponse(RfcLdapMessage message) : base(message) { }
/// <summary> Creates an Rfc 2251 LdapMessage when the libraries receive a response /// from a command. /// /// </summary> /// <param name="message">A response message. /// </param> protected internal LdapMessage(RfcLdapMessage message) { this.message = message; return; }
/// <summary> Constructs an object from the responseValue which contains the /// replica information. /// /// The constructor parses the responseValue which has the following /// format: /// responseValue ::= /// partitionID INTEGER /// replicaState INTEGER /// modificationTime INTEGER /// purgeTime INTEGER /// localPartitionID INTEGER /// partitionDN OCTET STRING /// replicaType INTEGER /// flags INTEGER /// /// </summary> /// <exception> IOException The response value could not be decoded. /// </exception> public GetReplicaInfoResponse(RfcLdapMessage rfcMessage) : base(rfcMessage) { if (ResultCode == LdapException.SUCCESS) { // parse the contents of the reply sbyte[] returnedValue = 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"); } // Parse the parameters in the order System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue)); // Parse partitionID Asn1Integer asn1_partitionID = (Asn1Integer)decoder.decode(currentPtr); if (asn1_partitionID == null) { throw new System.IO.IOException("Decoding error"); } partitionID = asn1_partitionID.intValue(); // Parse replicaState Asn1Integer asn1_replicaState = (Asn1Integer)decoder.decode(currentPtr); if (asn1_replicaState == null) { throw new System.IO.IOException("Decoding error"); } replicaState = asn1_replicaState.intValue(); // Parse modificationTime Asn1Integer asn1_modificationTime = (Asn1Integer)decoder.decode(currentPtr); if (asn1_modificationTime == null) { throw new System.IO.IOException("Decoding error"); } modificationTime = asn1_modificationTime.intValue(); // Parse purgeTime Asn1Integer asn1_purgeTime = (Asn1Integer)decoder.decode(currentPtr); if (asn1_purgeTime == null) { throw new System.IO.IOException("Decoding error"); } purgeTime = asn1_purgeTime.intValue(); // Parse localPartitionID Asn1Integer asn1_localPartitionID = (Asn1Integer)decoder.decode(currentPtr); if (asn1_localPartitionID == null) { throw new System.IO.IOException("Decoding error"); } localPartitionID = asn1_localPartitionID.intValue(); // Parse partitionDN Asn1OctetString asn1_partitionDN = (Asn1OctetString)decoder.decode(currentPtr); if (asn1_partitionDN == null) { throw new System.IO.IOException("Decoding error"); } partitionDN = asn1_partitionDN.stringValue(); if ((object)partitionDN == null) { throw new System.IO.IOException("Decoding error"); } // Parse replicaType Asn1Integer asn1_replicaType = (Asn1Integer)decoder.decode(currentPtr); if (asn1_replicaType == null) { throw new System.IO.IOException("Decoding error"); } replicaType = asn1_replicaType.intValue(); // Parse flags Asn1Integer asn1_flags = (Asn1Integer)decoder.decode(currentPtr); if (asn1_flags == null) { throw new System.IO.IOException("Decoding error"); } flags = asn1_flags.intValue(); } else { partitionID = 0; replicaState = 0; modificationTime = 0; purgeTime = 0; localPartitionID = 0; partitionDN = ""; replicaType = 0; flags = 0; } }
/// <summary> /// Initializes a new instance of the <see cref="LdapMessage"/> class. /// Creates an Rfc 2251 LdapMessage when the libraries receive a response /// from a command. /// </summary> /// <param name="message">A response message.</param> internal LdapMessage(RfcLdapMessage message) => Message = message;
/// <summary> Creates a response LdapMessage when receiving an asynchronous /// response from a server. /// /// </summary> /// <param name="message"> The RfcLdapMessage from a server. /// </param> /*package*/ internal LdapResponse(RfcLdapMessage message) : base(message) { }
private System.String name; // String name for debug /*package*/ /// <summary> Constructs an LdapSearchResultReference object. /// /// </summary> /// <param name="message">The LdapMessage with a search reference. /// </param> internal LdapSearchResultReference(RfcLdapMessage message) : base(message) { return; }