Created
March 14, 2013 16:12
-
-
Save AlD/5162690 to your computer and use it in GitHub Desktop.
Add a default search base to Net::LDAP via new(base => $base)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Net::LDAP::Wrapper; | |
use strict; | |
use parent 'Net::LDAP'; | |
my $_base; | |
sub new { | |
my $class = shift; | |
my $host = shift; | |
my %opts = (@_); | |
if (exists($opts{base})) { | |
$_base = $opts{base}; | |
delete $opts{base}; | |
} | |
my $self = $class->SUPER::new($host, %opts); | |
return $self; | |
} | |
sub search { | |
my $self = shift; | |
push(@_, base => $_base) if $_base; | |
return $self->SUPER::search(@_); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment