Skip to content

Commit

Permalink
Return the extended response data
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Apr 5, 2024
1 parent 0e38c4a commit 1d38606
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class Net::LDAP

universal = {
constructed: {
107 => :array, #ExtendedResponse (PasswdModifyResponseValue)
107 => :string, # ExtendedResponse
},
}

Expand Down Expand Up @@ -1213,7 +1213,7 @@ def delete_tree(args)
def ldapwhoami(args = {})
instrument "ldapwhoami.net_ldap", args do |payload|
@result = use_connection(args, &:ldapwhoami)
@result.success?
@result.success? ? @result.extended_response : nil
end
end
alias_method :whoami, :ldapwhoami
Expand Down
2 changes: 0 additions & 2 deletions lib/net/ldap/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ def delete(args)
end

def ldapwhoami
Net::LDAP::AsnSyntax[139] = :string
ext_seq = [Net::LDAP::WhoamiOid.to_ber_contextspecific(0)]
request = ext_seq.to_ber_appsequence(Net::LDAP::PDU::ExtendedRequest)

Expand All @@ -707,7 +706,6 @@ def ldapwhoami
raise Net::LDAP::ResponseMissingOrInvalidError, "response missing or invalid"
end

Net::LDAP::AsnSyntax[139] = nil
pdu
end

Expand Down
4 changes: 2 additions & 2 deletions lib/net/ldap/pdu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ def parse_ldap_result(sequence)
# requestValue [1] OCTET STRING OPTIONAL }

def parse_extended_response(sequence)
sequence.length >= 3 or raise Net::LDAP::PDU::Error, "Invalid LDAP result length."
sequence.length.between?(3, 5) or raise Net::LDAP::PDU::Error, "Invalid LDAP result length."
@ldap_result = {
:resultCode => sequence[0],
:matchedDN => sequence[1],
:errorMessage => sequence[2],
}
@extended_response = sequence[3]
@extended_response = sequence.last
end
private :parse_extended_response

Expand Down

0 comments on commit 1d38606

Please sign in to comment.