Exemplo n.º 1
0
        /// <summary>
        ///     Private implementation of getResponse.
        ///     Has an Integer object as a parameter so we can distinguish
        ///     the null and the message number case.
        /// </summary>
        private LdapMessage GetResponse(int?msgid)
        {
            object      resp;
            LdapMessage response;

            if ((resp = Agent.GetLdapMessage(msgid)) == null)
            {
                // blocks
                return(null); // no messages from this agent
            }

            // Local error occurred, contains a LocalException
            if (resp is LdapResponse ldapResponse)
            {
                return(ldapResponse);
            }

            // Normal message handling
            var message = (RfcLdapMessage)resp;

            switch (message.Type)
            {
            case LdapMessage.SearchResponse:
                response = new LdapSearchResult(message);
                break;

            case LdapMessage.SearchResultReference:
                response = new LdapSearchResultReference(message);
                break;

            case LdapMessage.ExtendedResponse:
                response = ExtResponseFactory.ConvertToExtendedResponse(message);
                break;

            case LdapMessage.IntermediateResponse:
                response = IntermediateResponseFactory.ConvertToIntermediateResponse(message);
                break;

            default:
                response = new LdapResponse(message);
                break;
            }

            return(response);
        }
        /// <summary>
        ///     Private implementation of getResponse.
        ///     Has an Integer object as a parameter so we can distinguish
        ///     the null and the message number case
        /// </summary>
//		private LdapMessage getResponse(System.Int32 msgid)
        private LdapMessage getResponse(Integer32 msgid)
        {
            object         resp;
            RfcLdapMessage message;
            LdapMessage    response;

            if ((resp = agent.getLdapMessage(msgid)) == null)
            {
                // blocks
                return(null); // no messages from this agent
            }
            // Local error occurred, contains a LocalException
            if (resp is LdapResponse)
            {
                return((LdapMessage)resp);
            }
            // Normal message handling
            message = (RfcLdapMessage)resp;
            switch (message.Type)
            {
            case LdapMessage.SEARCH_RESPONSE:
                response = new LdapSearchResult(message);
                break;

            case LdapMessage.SEARCH_RESULT_REFERENCE:
                response = new LdapSearchResultReference(message);
                break;

            case LdapMessage.EXTENDED_RESPONSE:
                var fac = new ExtResponseFactory();
                response = ExtResponseFactory.convertToExtendedResponse(message);
                break;

            case LdapMessage.INTERMEDIATE_RESPONSE:
                response = IntermediateResponseFactory.convertToIntermediateResponse(message);
                break;

            default:
                response = new LdapResponse(message);
                break;
            }
            return(response);
        }