Object
Defines the Protocol Data Unit (PDU) for LDAP. An LDAP PDU always looks like a BER SEQUENCE with at least two elements: an INTEGER message ID number and an application-specific SEQUENCE. Some LDAPv3 packets also include an optional third element, a sequence of "controls" (see RFC 2251 section 4.1.12 for more information).
The application-specific tag in the sequence tells us what kind of packet it is, and each kind has its own format, defined in RFC-1777.
Observe that many clients (such as ldapsearch) do not necessarily enforce the expected application tags on received protocol packets. This implementation does interpret the RFC strictly in this regard, and it remains to be seen whether there are servers out there that will not work well with our approach.
Currently, we only support controls on SearchResult.
tools.ietf.org/html/rfc4511#section-4.1.1 tools.ietf.org/html/rfc4511#section-4.1.9
see also SearchResultReferral (19) tools.ietf.org/html/rfc4511#section-4.6
Messy. Does this functionality belong somewhere else?
# File lib/net/ldap/pdu.rb, line 83 def initialize(ber_object) begin @message_id = ber_object[0].to_i # Grab the bottom five bits of the identifier so we know which type of # PDU this is. # # This is safe enough in LDAP-land, but it is recommended that other # approaches be taken for other protocols in the case that there's an # app-specific tag that has both primitive and constructed forms. @app_tag = ber_object[1].ber_identifier & 0x1f @ldap_controls = [] rescue Exception => ex raise Net::LDAP::PDU::Error, "LDAP PDU Format Error: #{ex.message}" end case @app_tag when BindResult parse_bind_response(ber_object[1]) when SearchReturnedData parse_search_return(ber_object[1]) when SearchResultReferral parse_search_referral(ber_object[1]) when SearchResult parse_ldap_result(ber_object[1]) when ModifyResponse parse_ldap_result(ber_object[1]) when AddResponse parse_ldap_result(ber_object[1]) when DeleteResponse parse_ldap_result(ber_object[1]) when ModifyRDNResponse parse_ldap_result(ber_object[1]) when SearchRequest parse_ldap_search_request(ber_object[1]) when BindRequest parse_bind_request(ber_object[1]) when UnbindRequest parse_unbind_request(ber_object[1]) when ExtendedResponse parse_ldap_result(ber_object[1]) else raise LdapPduError.new("unknown pdu-type: #{@app_tag}") end parse_controls(ber_object[2]) if ber_object[2] end
# File lib/net/ldap/pdu.rb, line 138 def error_message result[:errorMessage] || "" end
Returns a hash which (usually) defines the members :resultCode, :errorMessage, and :matchedDN. These values come directly from an LDAP response packet returned by the remote peer. Also see result_code.
# File lib/net/ldap/pdu.rb, line 134 def result @ldap_result || {} end
Return serverSaslCreds, which are only present in BindResponse packets.
# File lib/net/ldap/pdu.rb, line 167 def result_server_sasl_creds @ldap_result && @ldap_result[:serverSaslCreds] end
Generated with the Darkfish Rdoc Generator 2.