Author: gd Date: 2006-06-26 16:14:40 +0000 (Mon, 26 Jun 2006) New Revision: 16521
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16521 Log: Fix different extended_dn handling for win2k/2k3 (thanks to Frederic Brin at Novell). Guenther Modified: branches/SAMBA_3_0/examples/misc/adssearch.pl trunk/examples/misc/adssearch.pl Changeset: Modified: branches/SAMBA_3_0/examples/misc/adssearch.pl =================================================================== --- branches/SAMBA_3_0/examples/misc/adssearch.pl 2006-06-26 15:24:10 UTC (rev 16520) +++ branches/SAMBA_3_0/examples/misc/adssearch.pl 2006-06-26 16:14:40 UTC (rev 16521) @@ -87,7 +87,7 @@ 'base|b=s' => \$opt_base, 'D|DN=s' => \$opt_binddn, 'debug=i' => \$opt_debug, - 'extendeddn|e' => \$opt_display_extendeddn, + 'extendeddn|e=i' => \$opt_display_extendeddn, 'help' => \$opt_help, 'host|h=s' => \$opt_host, 'machine|P' => \$opt_machine, @@ -1396,13 +1396,13 @@ > ); - my $ctl_extended_dn_val = $asn_extended_dn->encode( mode => '1'); - my $ctl_extended_dn =Net::LDAP::Control->new( - type => $ads_controls{'LDAP_SERVER_EXTENDED_DN_OID'}, - critical => 'true', - value => $ctl_extended_dn_val); + # only w2k3 accepts '1' and needs the ctl_val, w2k does not accept a ctl_val + my $ctl_extended_dn_val = $asn_extended_dn->encode( mode => $opt_display_extendeddn); + my $ctl_extended_dn = Net::LDAP::Control->new( + type => $ads_controls{'LDAP_SERVER_EXTENDED_DN_OID'}, + critical => 'true', + value => $opt_display_extendeddn ? $ctl_extended_dn_val : ""); - # setup notify control my $ctl_notification = Net::LDAP::Control->new( type => $ads_controls{'LDAP_SERVER_NOTIFICATION_OID'}, @@ -1421,7 +1421,7 @@ push(@ctrls_s, "LDAP_PAGED_RESULT_OID_STRING" ); } - if ($opt_display_extendeddn) { + if (defined($opt_display_extendeddn)) { push(@ctrls, $ctl_extended_dn); push(@ctrls_s, "LDAP_SERVER_EXTENDED_DN_OID"); } Modified: trunk/examples/misc/adssearch.pl =================================================================== --- trunk/examples/misc/adssearch.pl 2006-06-26 15:24:10 UTC (rev 16520) +++ trunk/examples/misc/adssearch.pl 2006-06-26 16:14:40 UTC (rev 16521) @@ -87,7 +87,7 @@ 'base|b=s' => \$opt_base, 'D|DN=s' => \$opt_binddn, 'debug=i' => \$opt_debug, - 'extendeddn|e' => \$opt_display_extendeddn, + 'extendeddn|e=i' => \$opt_display_extendeddn, 'help' => \$opt_help, 'host|h=s' => \$opt_host, 'machine|P' => \$opt_machine, @@ -1396,13 +1396,13 @@ > ); - my $ctl_extended_dn_val = $asn_extended_dn->encode( mode => '1'); - my $ctl_extended_dn =Net::LDAP::Control->new( - type => $ads_controls{'LDAP_SERVER_EXTENDED_DN_OID'}, - critical => 'true', - value => $ctl_extended_dn_val); + # only w2k3 accepts '1' and needs the ctl_val, w2k does not accept a ctl_val + my $ctl_extended_dn_val = $asn_extended_dn->encode( mode => $opt_display_extendeddn); + my $ctl_extended_dn = Net::LDAP::Control->new( + type => $ads_controls{'LDAP_SERVER_EXTENDED_DN_OID'}, + critical => 'true', + value => $opt_display_extendeddn ? $ctl_extended_dn_val : ""); - # setup notify control my $ctl_notification = Net::LDAP::Control->new( type => $ads_controls{'LDAP_SERVER_NOTIFICATION_OID'}, @@ -1421,7 +1421,7 @@ push(@ctrls_s, "LDAP_PAGED_RESULT_OID_STRING" ); } - if ($opt_display_extendeddn) { + if (defined($opt_display_extendeddn)) { push(@ctrls, $ctl_extended_dn); push(@ctrls_s, "LDAP_SERVER_EXTENDED_DN_OID"); }
