RedmineAdvanced-ldap-as-user.diff

bind to LDAP server as user (see #1913) - Adi Kriegisch, 2009-08-21 15:42

Download (1.17 KB)

View differences:

RedmineAdvanced.pm 2009-08-21 15:16:51.000000000 +0200
461 461
         );
462 462
         $sthldap->execute($auth_source_id);
463 463
         while ( my @rowldap = $sthldap->fetchrow_array ) {
464
            # add ldap authenticate as user (see Feature #1939)
465
            my $bind_as = $rowldap[3];
466
            my $bind_pw = $rowldap[4] ? $rowldap[4] : "";
467
            if ($bind_as =~ m/\$login/) {
468
              # replace $login with $redmine_user and use $redmine_pass
469
              $bind_as =~ s/\$login/$redmine_user/g;
470
              $bind_pw = $redmine_pass
471
            }
464 472
            my $ldap = Authen::Simple::LDAP->new(
465 473
               host => ( $rowldap[2] == 1 || $rowldap[2] eq "t" )
466 474
               ? "ldaps://$rowldap[0]"
467 475
               : $rowldap[0],
468 476
               port   => $rowldap[1],
469 477
               basedn => $rowldap[5],
470
               binddn => $rowldap[3] ? $rowldap[3] : "",
471
               bindpw => $rowldap[4] ? $rowldap[4] : "",
478
               binddn => $bind_as,
479
               bindpw => $bind_pw,
472 480
               filter => "(" . $rowldap[6] . "=%s)"
473 481
            );
474 482
            $ret = 1