##// END OF EJS Templates
Redmine.pm support for LDAP authentication (patch by Liwiusz Ociepa). Closes #879, #918....
Jean-Philippe Lang -
r1320:246e8f67c598
parent child
Show More
@@ -90,6 +90,7 use strict;
90 90
91 91 use DBI;
92 92 use Digest::SHA1;
93 use Authen::Simple::LDAP;
93 94
94 95 use Apache2::Module;
95 96 use Apache2::Access;
@@ -176,17 +177,37 sub is_member {
176 177 my $pass_digest = Digest::SHA1::sha1_hex($redmine_pass);
177 178
178 179 my $sth = $dbh->prepare(
179 "SELECT hashed_password FROM members, projects, users WHERE projects.id=members.project_id AND users.id=members.user_id AND users.status=1 AND login=? AND identifier=?;"
180 "SELECT hashed_password, auth_source_id FROM members, projects, users WHERE projects.id=members.project_id AND users.id=members.user_id AND users.status=1 AND login=? AND identifier=?;"
180 181 );
181 182 $sth->execute($redmine_user, $project_id);
182 183
183 184 my $ret;
184 185 while (my @row = $sth->fetchrow_array) {
186 unless ($row[1]) {
185 187 if ($row[0] eq $pass_digest) {
186 188 $ret = 1;
187 189 last;
188 190 }
191 } else {
192 my $sthldap = $dbh->prepare(
193 "SELECT host,port,account,account_password,base_dn,attr_login from auth_sources WHERE id = ?;"
194 );
195 $sthldap->execute($row[1]);
196 while (my @rowldap = $sthldap->fetchrow_array) {
197 my $ldap = Authen::Simple::LDAP->new(
198 host => $rowldap[0],
199 port => $rowldap[1],
200 basedn => $rowldap[4],
201 binddn => $rowldap[2] ? $rowldap[2] : "",
202 bindpw => $rowldap[3] ? $rowldap[3] : "",
203 filter => "(".$rowldap[5]."=%s)"
204 );
205 $ret = 1 if ($ldap->authenticate($redmine_user, $redmine_pass));
206 }
207 $sthldap->finish();
208 }
189 209 }
210 $sth->finish();
190 211 $dbh->disconnect();
191 212
192 213 $ret;
General Comments 0
You need to be logged in to leave comments. Login now