/// <summary>
        /// Try parsing an ldap packet from a stream
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="packet"></param>
        /// <returns>True if succesful. False if parsing fails or stream is empty</returns>
        public static Boolean TryParsePacket(Stream stream, out LdapPacket packet)
        {
            try
            {
                var tagByte = new Byte[1];
                var i       = stream.Read(tagByte, 0, 1);
                if (i != 0)
                {
                    var contentLength = Utils.BerLengthToInt(stream, out int n);
                    var contentBytes  = new Byte[contentLength];
                    stream.Read(contentBytes, 0, contentLength);

                    packet = new LdapPacket(Tag.Parse(tagByte[0]));
                    packet.ChildAttributes.AddRange(ParseAttributes(contentBytes, 0, contentLength));
                    return(true);
                }
            }
            catch (Exception ex)
            {
                _log.Error("Could not parse packet from stream", ex);
            }

            packet = null;
            return(false);
        }
        /// <summary>
        /// Parse an ldap packet from a byte array.
        /// Must be the complete packet
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static LdapPacket ParsePacket(Byte[] bytes)
        {
            var packet        = new LdapPacket(Tag.Parse(bytes[0]));
            var contentLength = Utils.BerLengthToInt(bytes, 1, out var lengthBytesCount);

            packet.ChildAttributes.AddRange(ParseAttributes(bytes, 1 + lengthBytesCount, contentLength));
            return(packet);
        }