summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-12-15 00:40:57 +0100
committermkanat%bugzilla.org <>2007-12-15 00:40:57 +0100
commit7cf695517efa17b200f31ed4c934af8839153e44 (patch)
tree20884c11575b18d95ea5bd092d004d25936b1860 /Bugzilla
parent4734e25879a9b98ff0c28f8430ce9b3fb536df90 (diff)
downloadbugzilla-7cf695517efa17b200f31ed4c934af8839153e44.tar.gz
bugzilla-7cf695517efa17b200f31ed4c934af8839153e44.tar.xz
Bug 229049: Make LDAP authentication work when there are multiple mail= attributes for an account.
Patch By Emmanuel Seyman <eseyman@linagora.com> r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Auth/Verify/LDAP.pm18
1 files changed, 17 insertions, 1 deletions
diff --git a/Bugzilla/Auth/Verify/LDAP.pm b/Bugzilla/Auth/Verify/LDAP.pm
index 0176abdcb..b8dff397f 100644
--- a/Bugzilla/Auth/Verify/LDAP.pm
+++ b/Bugzilla/Auth/Verify/LDAP.pm
@@ -37,6 +37,7 @@ use fields qw(
use Bugzilla::Constants;
use Bugzilla::Error;
+use Bugzilla::User;
use Bugzilla::Util;
use Net::LDAP;
@@ -90,7 +91,22 @@ sub check_credentials {
details => {attr => $mail_attr} };
}
- $params->{bz_username} = $user_entry->get_value($mail_attr);
+ my @emails = $user_entry->get_value($mail_attr);
+
+ # Default to the first email address returned.
+ $params->{bz_username} = $emails[0];
+
+ if (@emails > 1) {
+ # Cycle through the adresses and check if they're Bugzilla logins.
+ # Use the first one that returns a valid id.
+ foreach my $email (@emails) {
+ if ( login_to_id($email) ) {
+ $params->{bz_username} = $email;
+ last;
+ }
+ }
+ }
+
} else {
$params->{bz_username} = $username;
}