dsv-su / play

Dev repository for Play
0 stars 1 forks source link

Improving suggestions when searching for users #113

Closed booski closed 2 years ago

booski commented 2 years ago

The current user suggestion function takes the entire string entered and runs an ldap query matching on the cn (common name, first + last name). This has a few undesirable side effects, for example a user with a middle name in SUKAT will not be found when searching for them by first + last name:

Name in sukat: Anders Bengt Carlsson

A solution to this would be to do individual searches per entered word, and looking at more than just the cn attribute:

Search string: "ande ca"

Pseudo-code:

$searchterms = preg_split('/\s+/', $inputstring);
$search = '(&';
foreach($searchterms as $term) {
  $search .= "(|(givenName=$term*)(sn=$term*)(uid=$term*))";
}
$search .= ')';
//apply the search to some ldap connection... 

Doing this would make the search for "ande ca" return all users matching both words in either their first, last or usernames.

booski commented 2 years ago

Closely related to #98

pavelsokolov commented 2 years ago

I'm not sure why, but searching through uids is veeery slow. Right now the search is done through sn/givenName: Screenshot 2022-05-03 at 15 59 53

pavelsokolov commented 2 years ago

There's a problem with people with multiple first/last names.

Example: Ann Maria Dorotea Bergholtz Sukat firstname: Ann Maria Dorotea Sukat lastname: Bergholtz

Right now a search for Ma Berg doesn't find her because the sukat first name starts with 'Ann' and not 'Maria'. To be able to find her, we would need to perform a full substring search (sn=*$term) instead of (sn=$term). But this search is quite expensive.

Also it's not possible to find her via 'Ann Maria' because then the search expects both keywords to be present in either of the names.

I tend to think that this could be an exception that we can live with, since 99% of users should have 'valid' names.