grep { /^\s*(\w+)\s+(.*\S)\s*$/ }
split("\n", $self->option('attributes'));
- if ( $self->option('radius') {
+ if ( $self->option('radius') ) {
foreach my $table (qw(reply check)) {
my $method = "radius_$table";
my %radius = $svc_acct->$method();
}
sub ldap_insert { #subroutine, not method
- my $dn = ldap_connect(shift, shift, shift);
+ my $ldap = ldap_connect(shift, (my $dn = shift), shift);
my %attrib = @_;
my $status = $ldap->add( $dn, attrs => [ %attrib ] );
sub ldap_connect {
my( $machine, $dn, $password ) = @_;
+ my %bind_options;
+ $bind_options{password} = $password if length($password);
eval "use Net::LDAP";
die $@ if $@;
- my $ldap = Net::LDAP->net($machine) or die $@;
- my $status = $ldap->bind( $dn, password=>$password );
+ my $ldap = Net::LDAP->new($machine) or die $@;
+ my $status = $ldap->bind( $dn, %bind_options );
die $status->error if $status->is_error;
- $dn;
+ $ldap;
}