tinu
tinu

Reputation: 558

Redmine.pm does not work with Authen::Simple::LDAP

I'm using the Bitnami Redmine Stack on a Windows Server. I have configured Redmine to use LDAP authentication and it works. Now I'd like to have SVN authentication via Redmine and LDAP. I can log-in with a Redmine account but not with LDAP. There is an error in the Apache error.log:

[Authen::Simple::LDAP] Failed to bind with dn 'REDMINE'. Reason: 'Bad file descriptor'

'REDMINE' is the user which is used for the LDAP. It seems to be a problem in the Redmine.pm which is written in Perl, but I don't know much about Perl.

I found a part of the Perl-Code which, I think, causes the error:

my $sthldap = $dbh->prepare(
          "SELECT host,port,tls,account,account_password,base_dn,attr_login from auth_sources WHERE id = ?;"
      );
      $sthldap->execute($auth_source_id);
      while (my @rowldap = $sthldap->fetchrow_array) {
        my $bind_as = $rowldap[3] ? $rowldap[3] : "";
        my $bind_pw = $rowldap[4] ? $rowldap[4] : "";
        if ($bind_as =~ m/\$login/) {
          # replace $login with $redmine_user and use $redmine_pass
          $bind_as =~ s/\$login/$redmine_user/g;
          $bind_pw = $redmine_pass
        }
        my $ldap = Authen::Simple::LDAP->new(
            host    =>      ($rowldap[2] eq "1" || $rowldap[2] eq "t") ? "ldaps://$rowldap[0]:$rowldap[1]" : "ldap://$rowldap[0]",
            port    =>      $rowldap[1],
            basedn  =>      $rowldap[5],
            binddn  =>      $bind_as,
            bindpw  =>      $bind_pw,
            filter  =>      "(".$rowldap[6]."=%s)"
        );
        my $method = $r->method;
        $ret = 1 if ($ldap->authenticate($redmine_user, $redmine_pass) && (($access_mode eq "R" && $permissions =~ /:browse_repository/) || $permissions =~ /:commit_access/));

      }
      $sthldap->finish();
      undef $sthldap;

Does anyone know about a solution for this problem? Or maybe a working alternative to the standard Redmine.pm?

Upvotes: 3

Views: 519

Answers (1)

tinu
tinu

Reputation: 558

The problem was that I don't have installed "IO::Socket::IP" and "latest perl-ldap" via the cpan console and strawberry-perl doesn't include it in the install. After I installed these with the following CMD commands it worked fine!

> cpan
cpan> install IO::Socket::IP
cpan> install latest perl-ldap

Upvotes: 2

Related Questions