Esempio n. 1
0
        public static LdapPacket Extract(ICollection <byte> buffer)
        {
            var ldapPacket = new LdapPacket();

            ldapPacket.ExtractTagAndLength(buffer);
            ldapPacket.MessageId         = DERInteger.Extract(buffer);
            ldapPacket.ProtocolOperation = DERProtocolOperation.Extract(buffer);
            if (buffer.Count > 0)
            {
                ldapPacket.Controls = DERSequence <DERControl> .Extract(buffer);
            }

            return(ldapPacket);
        }
        public static DERProtocolOperation Extract(ICollection <byte> buffer)
        {
            var result = new DERProtocolOperation();

            result.ExtractTagAndLength(buffer);
            switch (result.Tag.LdapCommand)
            {
            case LdapCommands.SearchRequest:
                result.Operation = SearchRequest.Extract(buffer);
                break;

            case LdapCommands.BindRequest:
                result.Operation = BindRequest.Extract(buffer);
                break;

            case LdapCommands.UnbindRequest:
                result.Operation = UnbindRequest.Extract(buffer);
                break;

            case LdapCommands.AddRequest:
                result.Operation = AddRequest.Extract(buffer);
                break;

            case LdapCommands.DelRequest:
                result.Operation = DelRequest.Extract(buffer, result.Length);
                break;

            case LdapCommands.ModifyDNRequest:
                result.Operation = ModifyDNRequest.Extract(buffer);
                break;

            case LdapCommands.CompareRequest:
                result.Operation = CompareRequest.Extract(buffer);
                break;

            case LdapCommands.AbandonRequest:
                result.Operation = AbandonRequest.Extract(buffer);
                break;

            case LdapCommands.ModifyRequest:
                result.Operation = ModifyRequest.Extract(buffer);
                break;

            case LdapCommands.SearchResultDone:
                result.Operation = SearchResultDone.Extract(buffer);
                break;

            case LdapCommands.BindResponse:
                result.Operation = BindResponse.Extract(buffer);
                break;

            case LdapCommands.AddResponse:
                result.Operation = AddResponse.Extract(buffer);
                break;

            case LdapCommands.SearchResultEntry:
                result.Operation = SearchResultEntry.Extract(buffer);
                break;
            }

            return(result);
        }