Project

General

Profile

Feature #1913 » Redmine-ldap-as-user.diff

patch for Redmine.pm to make use of "bind as user" feature - Adi Kriegisch, 2009-08-21 15:34

View differences:

redmine/extra/svn/Redmine.pm 2009-08-21 15:30:48.000000000 +0200
294 294
          );
295 295
          $sthldap->execute($auth_source_id);
296 296
          while (my @rowldap = $sthldap->fetchrow_array) {
297
            # add ldap authenticate as user
298
            my $bind_as = $rowldap[3];
299
            my $bind_pw = $rowldap[4] ? $rowldap[4] : "";
300
            if ($bind_as =~ m/\$login/) {
301
              # replace $login with $redmine_user and use $redmine_pass
302
              $bind_as =~ s/\$login/$redmine_user/g;
303
              $bind_pw = $redmine_pass
304
            }
297 305
            my $ldap = Authen::Simple::LDAP->new(
298 306
                host    =>      ($rowldap[2] == 1 || $rowldap[2] eq "t") ? "ldaps://$rowldap[0]" : $rowldap[0],
299 307
                port    =>      $rowldap[1],
300 308
                basedn  =>      $rowldap[5],
301
                binddn  =>      $rowldap[3] ? $rowldap[3] : "",
302
                bindpw  =>      $rowldap[4] ? $rowldap[4] : "",
309
                binddn  =>      $bind_as,
310
                bindpw  =>      $bind_pw,
303 311
                filter  =>      "(".$rowldap[6]."=%s)"
304 312
            );
305 313
            $ret = 1 if ($ldap->authenticate($redmine_user, $redmine_pass));
(2-2/6)