--- /backupalog/redmine/extra/svn/Redmine.pm 2012-09-18 21:46:47.000000000 -0300 +++ /usr/lib/perl5/5.10.0/Apache/Redmine.pm 2013-05-20 19:35:32.556653362 -0300 @@ -446,6 +446,55 @@ my $dbh = connect_database($r); my $project_id = get_project_identifier($r); + # This unless is added to allow SVNListParentPath to work only for LDAP users + # The LDAP authentication code is copied from the code below + unless (defined($project_id)) { + + my $ret_new; + + my $sthuseronly = $dbh->prepare( + "select auth_source_id from users where login = ?;" + ); + $sthuseronly->execute($redmine_user); + my @auth_source_result = $sthuseronly->fetchrow_array; + my $auth_source_id_new = $auth_source_result[0]; + + + 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_new); + 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_new = Authen::Simple::LDAP->new( + host => ($rowldap[2] eq "1" || $rowldap[2] eq "t") ? "ldaps://$rowldap[0]:$rowldap[1]" : $rowldap[0], + port => $rowldap[1], + basedn => $rowldap[5], + binddn => $bind_as, + bindpw => $bind_pw, + filter => "(".$rowldap[6]."=%s)" + ); + if ($ldap_new->authenticate($redmine_user, $redmine_pass)) { + $ret_new = 1; + } else { + $ret_new = 0; + } + + } + $sthldap->finish(); + undef $sthldap; + + $sthuseronly->finish(); + return $ret_new; + } + + my $pass_digest = Digest::SHA::sha1_hex($redmine_pass); my $access_mode = request_is_read_only($r) ? "R" : "W";