From dbf7a692edba88e0d609142f1ed11445bc7e841a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 1 Feb 2007 12:20:33 +0000 Subject: r21105: Quick fix for CLDAP reply without NetLogon attribute. Guenther (This used to be commit aa135c960e5d713daa4ee13a955dc502d12f4f87) --- examples/misc/cldap.pl | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/misc/cldap.pl b/examples/misc/cldap.pl index 2218537f08..c33fdedfbf 100755 --- a/examples/misc/cldap.pl +++ b/examples/misc/cldap.pl @@ -136,7 +136,9 @@ sub send_cldap_netlogon ($$$$) { ) || die "failed to encode pdu: $@"; if ($opt_debug) { + print"------------\n"; asn_dump($pdu_req); + print"------------\n"; } return $sock->send($pdu_req) || die "no send: $@"; @@ -290,10 +292,13 @@ sub recv_cldap_netlogon ($\$) { #$ret = sysread($sock, $pdu_out, 8192); if ($opt_debug) { + print"------------\n"; asn_dump($pdu_out); + print"------------\n"; } my $asn_cldap_rep = Convert::ASN1->new; + my $asn_cldap_rep_fail = Convert::ASN1->new; $asn_cldap_rep->prepare(q< SEQUENCE { @@ -320,9 +325,24 @@ sub recv_cldap_netlogon ($\$) { } >); - my $asn1_rep = $asn_cldap_rep->decode($pdu_out) || die "failed to decode pdu: $@"; + $asn_cldap_rep_fail->prepare(q< + SEQUENCE { + msgid2 INTEGER, + [APPLICATION 5] SEQUENCE { + error_code ENUMERATED, + matched_dn OCTET STRING, + error_message OCTET STRING + } + } + >); - $$return_string = $asn1_rep->{'val'}; + my $asn1_rep = $asn_cldap_rep->decode($pdu_out) || + $asn_cldap_rep_fail->decode($pdu_out) || + die "failed to decode pdu: $@"; + + if ($asn1_rep->{'error_code'} == 0) { + $$return_string = $asn1_rep->{'val'}; + } return $ret; } @@ -453,6 +473,11 @@ sub main() { } close($sock); + if (!$reply) { + printf("no 'NetLogon' attribute received\n"); + exit 0; + } + %cldap_netlogon_reply = parse_cldap_reply($reply); if (!%cldap_netlogon_reply) { die("failed to parse CLDAP reply from $server"); -- cgit