Class: Net::LdapPdu
- Inherits:
-
Object
- Object
- Net::LdapPdu
- Defined in:
- lib/net/ldap/pdu.rb
Constant Summary collapse
- BindResult =
1
- SearchReturnedData =
4
- SearchResult =
5
- ModifyResponse =
7
- AddResponse =
9
- DeleteResponse =
11
- ModifyRDNResponse =
13
Instance Attribute Summary collapse
-
#app_tag ⇒ Object
readonly
Returns the value of attribute app_tag.
-
#msg_id ⇒ Object
readonly
Returns the value of attribute msg_id.
-
#search_attributes ⇒ Object
readonly
Returns the value of attribute search_attributes.
-
#search_dn ⇒ Object
readonly
Returns the value of attribute search_dn.
-
#search_entry ⇒ Object
readonly
Returns the value of attribute search_entry.
Instance Method Summary collapse
-
#initialize(ber_object) ⇒ LdapPdu
constructor
initialize An LDAP PDU always looks like a BerSequence with two elements: an integer (message-id number), and an application-specific sequence.
-
#result_code(code = :resultCode) ⇒ Object
result_code This returns an LDAP result code taken from the PDU, but it will be nil if there wasn’t a result code.
Constructor Details
#initialize(ber_object) ⇒ LdapPdu
initialize An LDAP PDU always looks like a BerSequence with two elements: an integer (message-id number), and an application-specific sequence. 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.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/net/ldap/pdu.rb', line 65 def initialize ber_object begin @msg_id = ber_object[0].to_i @app_tag = ber_object[1].ber_identifier - 0x60 rescue # any error becomes a data-format error raise LdapPduError.new( "ldap-pdu format error" ) end case @app_tag when BindResult parse_ldap_result ber_object[1] when SearchReturnedData parse_search_return 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] else raise LdapPduError.new( "unknown pdu-type: #{@app_tag}" ) end end |
Instance Attribute Details
#app_tag ⇒ Object (readonly)
Returns the value of attribute app_tag.
47 48 49 |
# File 'lib/net/ldap/pdu.rb', line 47 def app_tag @app_tag end |
#msg_id ⇒ Object (readonly)
Returns the value of attribute msg_id.
47 48 49 |
# File 'lib/net/ldap/pdu.rb', line 47 def msg_id @msg_id end |
#search_attributes ⇒ Object (readonly)
Returns the value of attribute search_attributes.
48 49 50 |
# File 'lib/net/ldap/pdu.rb', line 48 def search_attributes @search_attributes end |
#search_dn ⇒ Object (readonly)
Returns the value of attribute search_dn.
48 49 50 |
# File 'lib/net/ldap/pdu.rb', line 48 def search_dn @search_dn end |
#search_entry ⇒ Object (readonly)
Returns the value of attribute search_entry.
48 49 50 |
# File 'lib/net/ldap/pdu.rb', line 48 def search_entry @search_entry end |
Instance Method Details
#result_code(code = :resultCode) ⇒ Object
result_code This returns an LDAP result code taken from the PDU, but it will be nil if there wasn’t a result code. That can easily happen depending on the type of packet.
100 101 102 |
# File 'lib/net/ldap/pdu.rb', line 100 def result_code code = :resultCode @ldap_result and @ldap_result[code] end |