Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change root_dse to return a RootDSE object instead of an Entry

Remove supported_* methods from Net::LDAP as they are now
methods in the RootDSE class
  • Loading branch information...
commit 036c1880b5a1844f8844300b5bdb3306e40e6478 1 parent 12db9ee
@gbarr gbarr authored
Showing with 23 additions and 33 deletions.
  1. +1 −0  MANIFEST
  2. +12 −28 lib/Net/LDAP.pm
  3. +2 −2 lib/Net/LDAP.pod
  4. +8 −3 t/54dse.t
View
1  MANIFEST
@@ -75,6 +75,7 @@ lib/Net/LDAP/Message.pm
lib/Net/LDAP/Message.pod
lib/Net/LDAP/RFC.pod
lib/Net/LDAP/Reference.pod
+lib/Net/LDAP/RootDSE.pm
lib/Net/LDAP/Schema.pm
lib/Net/LDAP/Schema.pod
lib/Net/LDAP/Search.pm
View
40 lib/Net/LDAP.pm
@@ -874,33 +874,6 @@ sub schema {
: Net::LDAP::Schema->new($mesg->entry);
}
-sub supported_extension {
- return _supported_feature( 'supportedExtension', @_ );
-}
-
-sub supported_version {
- return _supported_feature( 'supportedLDAPVersion', @_ );
-}
-
-sub supported_control {
- return _supported_feature( 'supportedControl', @_ );
-}
-
-sub supported_sasl_mechanism {
- return _supported_feature( 'supportedSASLMechanisms', @_ );
-}
-
-sub _supported_feature {
- my $attr = shift;
- my $root = shift->root_dse( attrs => [$attr] )
- or return undef;
- my %ext;
- map { $ext{$_} = 1 } $root->get_value( $attr );
- foreach (@_) {
- return 0 unless exists $ext{$_};
- }
- return 1;
-}
sub root_dse {
my $ldap = shift;
@@ -914,6 +887,9 @@ sub root_dse {
supportedSASLMechanisms
supportedLDAPVersion
)];
+ my $root = $arg{attrs} && $ldap->{net_ldap_root_dse};
+
+ return $root if $root;
my $mesg = $ldap->search(
base => '',
@@ -922,7 +898,13 @@ sub root_dse {
attrs => $attrs,
);
- $mesg->entry;
+ require Net::LDAP::RootDSE;
+ $root = $mesg->entry;
+ bless $root, 'Net::LDAP::RootDSE' if $root; # Naughty, but there you go :-)
+
+ $ldap->{net_ldap_root_dse} = $root unless $arg{attrs};
+
+ return $root;
}
sub start_tls {
@@ -952,6 +934,8 @@ sub start_tls {
return $mesg
if $mesg->code;
+ delete $ldap->{net_ldap_root_dse};
+
$arg->{sslversion} = 'tlsv1' unless defined $arg->{sslversion};
IO::Socket::SSL::context_init( { _SSL_context_init_args($arg) } );
IO::Socket::SSL::socketToSSL($sock, {_SSL_context_init_args($arg)})
View
4 lib/Net/LDAP.pod
@@ -492,7 +492,7 @@ If not specified, then the following attributes will be requested
=back
-The result is an object of class L<Net::LDAP::Search>.
+The result is an object of class L<Net::LDAP::RootDSE>.
B<Example>
@@ -912,6 +912,6 @@ terms as Perl itself.
=for html <hr>
-I<$Id: LDAP.pod,v 1.25 2003/05/07 10:54:57 gbarr Exp $>
+I<$Id: LDAP.pod,v 1.26 2003/05/09 12:05:10 gbarr Exp $>
=cut
View
11 t/54dse.t
@@ -5,7 +5,7 @@ BEGIN {
start_server(version => 3);
}
-print "1..2\n";
+print "1..4\n";
$ldap = client();
ok($ldap, "client");
@@ -13,7 +13,12 @@ ok($ldap, "client");
$dse = $ldap->root_dse;
ok($dse, "dse");
-use Net::LDAP::LDIF;
-Net::LDAP::LDIF->new(qw(- w))->write_entry($dse) if $dse;
+$dse->dump if $dse and $ENV{TEST_VERBOSE};
+
+my @extn = $dse->get_value('supportedExtension');
+
+ok($dse->supported_extension(@extn), 'supported_extension');
+
+ok(!$dse->supported_extension('foobar'), 'extension foobar');
Please sign in to comment.
Something went wrong with that request. Please try again.