svn commit: samba r21105 - in branches: SAMBA_3_0/examples/misc SAMBA_3_0_24/examples/misc

gd at samba.org gd at samba.org
Thu Feb 1 12:20:34 GMT 2007


Author: gd
Date: 2007-02-01 12:20:33 +0000 (Thu, 01 Feb 2007)
New Revision: 21105

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21105

Log:
Quick fix for CLDAP reply without NetLogon attribute.

Guenther

Modified:
   branches/SAMBA_3_0/examples/misc/cldap.pl
   branches/SAMBA_3_0_24/examples/misc/cldap.pl


Changeset:
Modified: branches/SAMBA_3_0/examples/misc/cldap.pl
===================================================================
--- branches/SAMBA_3_0/examples/misc/cldap.pl	2007-02-01 10:59:35 UTC (rev 21104)
+++ branches/SAMBA_3_0/examples/misc/cldap.pl	2007-02-01 12:20:33 UTC (rev 21105)
@@ -136,7 +136,9 @@
 				) || 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 @@
 	#$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,10 +325,25 @@
 		}
 	>);
 
-	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 @@
 	}
 	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");

Modified: branches/SAMBA_3_0_24/examples/misc/cldap.pl
===================================================================
--- branches/SAMBA_3_0_24/examples/misc/cldap.pl	2007-02-01 10:59:35 UTC (rev 21104)
+++ branches/SAMBA_3_0_24/examples/misc/cldap.pl	2007-02-01 12:20:33 UTC (rev 21105)
@@ -136,7 +136,9 @@
 				) || 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 @@
 	#$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,10 +325,25 @@
 		}
 	>);
 
-	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 @@
 	}
 	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");



More information about the samba-cvs mailing list