- $userldapentry = $search->shift_entry;
- my $cmpmesg = $db->compare( $userldapentry, attr=>'userpassword', value => $password );
- if ($cmpmesg->code != 6) {
- warn "LDAP Auth rejected : invalid password for user '$userid'. " . description($cmpmesg);
- return -1;
- }
- }
+ # Handle multiple branches. Same login exists several times in different branches.
+ my $bind_ok = 0;
+ while (my $entry = $search->shift_entry) {
+ my $user_ldap_bind_ret = $db->bind($entry->dn, password => $password);
+ unless ($user_ldap_bind_ret->code) {
+ $userldapentry = $entry;
+ $bind_ok = 1;
+ last;
+ }
+ }
+
+ unless ($bind_ok) {
+ warn "LDAP Auth rejected : invalid password for user '$userid'.";
+ return -1;
+ }
+
+
+ }