ldap export: don't use password if not given
[freeside.git] / FS / FS / part_export / ldap.pm
index 40f27d6..776814c 100644 (file)
@@ -31,7 +31,7 @@ sub _export_insert {
                  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();
@@ -225,12 +225,14 @@ sub ldap_insert { #subroutine, not method
 
 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;