Created attachment 25527 [details] [review] Add the SearchCardnumberWithLDAP system preference. This patch adds the "SearchCardnumberWithLDAP" system preference which will let you search for cardnumbers on a LDAP server. This feature only works in the Circulation section's "Check out" search bar. This feature is useful if you want to be able to checkout items for new users who were added on an LDAP server, but never connected on the OPAC. Here is how this feature works: * The librarian searches for a cardnumber in the intranet to do a checkout. * Search for the cardnumber in the local database. * If no borrower was found, SearchCardnumberWithLDAP is activated and an LDAP server is configured, search for the borrower on the LDAP server. * If a borrower was found on the LDAP server, add it to the local database. Also: * If the borrower was found in the local database, SearchCardnumberWithLDAP is activated and an LDAP server is configured, the borrower is updated using the informations on the LDAP server. Sponsored-by: CCSR ( http://www.ccsr.qc.ca )
To test this feature, you must have a LDAP server and configure it in your "koha-conf.xml" with at least mappings for the cardnumber and firstname fields. Make sure all required fields are mapped. Test case 1 : * Add a borrower with the cardnumber "12345" and the name "Test user" on your LDAP server. Make sure this cardnumber doesn't exist in your Koha database. * Activate the "SearchCardnumberWithLDAP" system preference. * Go to the "Circulation" section and search for the "12345" cardnumber to do a checkout. * You should be redirected to the circulation page for the "Test user" borrower, which means the LDAP user was successfully added to the local database. * Modify the "12345" user on your LDAP server. For example, change its name to "Bob". * Go to the "Circulation" section and search for the "12345" cardnumber again. * The user's name should now be "Bob" on the circulation page. Test case 2 : * Disable the "SearchCardnumberWithLDAP" system preference. * Modify the "12345" user on your LDAP server. For example, change its name to "Lisa". * Go to the "Circulation" section and search for the "12345" cardnumber again. * The user's name should still be "Bob" because the account was not updated this time. * Add a borrower with the cardnumber "123456" and the name "Test user 2" on your LDAP server. Make sure this cardnumber doesn't exist in your Koha database. * Go to the "Circulation" section and search for the "123456" cardnumber to do a checkout. * "No patron matched '123456'" should be shown.
Proposed solution in this patch is not compatible with auth_by_bind LDAP option. I don't have a real solution here since auth_by_bind requires patron's password to bind to LDAP server which is not available if patron is not logging in. This should not be total show-stopper since this option is a syspref, but it would be nice if users knew somehow that even if they turn on this option, but use auth_by_bind that it will not work.
Created attachment 26374 [details] [review] Fix system preference and add a note to the preference description. Here is a new version of the patch which adds a note on the fact that it won't work with auth_by_bind. I also added the SQL updates I forgot in my first version of this patch.
Interesting patch... could we have this re-based so I may test it?
Created attachment 60562 [details] [review] Bug 11808 - Add the SearchCardnumberWithLDAP system preference. When activated, cardnumber searches in the intranet will also do a search on the LDAP server if a user was not found in the local database. If the cardnumber is found on the LDAP server, the user account is imported in the local database.
I think we need a second syspref added here as it sneaks in an additional LDAP lookup per local search result to allow for a Sync operation. This could add a not insignificant additional load to the remote LDAP server which some users may wish to avoid.
+('SearchCardnumberWithLDAP','','Search for a cardnumber with LDAP when trying to do a checkout with a cardnumber that does not exist locally. If the cardnumber is found via LDAP, the user is added locally.','','YesNo') Could we maybe wrap it into 3 options for the one suggested? add, add and update, don't do anything (not sure how to phrase that to make it work)
Hmm.. I would love to see this in.. but I don't think it's really ready as it stands.. it's not comprehensive (only works in circulation, not patron searching in general and even within circulation it's not updating in the case where a borrower is found by their cardnumber rather than any other search fields). The routines are also not especially generalised, expecting the return of a datatables centric method call rather than a Koha::Patron (or even borrower row) structure. I'm afraid I'd have to Fail QA on it for those reasons. Not sure I'm going to get around to proposing an alternate solution any time soon though :(
Created attachment 93767 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference. When activated, cardnumber searches in the intranet will also do a search on the LDAP server if a user was not found in the local database. If the cardnumber is found on the LDAP server, the user account is imported in the local database.
Created attachment 93768 [details] [review] Bug 11808: (QA follow-up) Adds a third option to SearchCardnumberWithLDAP and other fixes This patch does a few things: - Adds a third option to the new system preference to choose between: never use ldap, make a request (and add) only when no patron is found, and always make a request (add/update). - Adds search and update with ldap in the case the patron is found by it's cardnumber in circulation. - Use Patron object in the new subs in C4/Auth_with_ldap.pm. To test: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by both it's cardnumber and any other attributes (results should be the same in both case) in the search bar in circ/circulation.pl.Do not choose from the dropdown list, use the submit button. => Should return cardnumber not found 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6.
For now, I've rebased the patch on current master and started to fix the problems reported. Among those fixes, I've added a third option, as Katrin suggested, for the system preference.
(In reply to Maryse Simard from comment #11) > For now, I've rebased the patch on current master and started to fix the > problems reported. Among those fixes, I've added a third option, as Katrin > suggested, for the system preference. Hi Maryse, is this ready for testing again yet? If so, please remember to switch the status!
This functionality is absolutely essential in some institutional/corporate environments, and is a much better idea than using scripts to synchronize all users. We've just tested the patches and all is working as expected from a user perspective. However, there is room for improvement: a) when the user doesn't exist locally, if you checkout using circulation introducing cardnumber, the user is added as expected. However, in my opinion, it should be added as well if "Search patrons" is used and cardnumber is introduced in that form, which doesn't happen at the moment. b) if the user doesn't have branch code defined in the AD an error regarding FK constraints is produced. Koha should deal with that gracefully. Thanks a lot for your work.
Created attachment 95573 [details] [review] Bug 11808: (QA follow-up) Adds support for other patron searches This patch add supports to other pages where patron search is possible: patron search, hold and article requests. Removes the code that tried to support searching for search fields other than cardnumber in circulation.pl Catch exception on broken FK contraint if information on the LDAP server can't be added to the database as to not interrupt execution. The error message is shown on the UI. Revised test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Thank you very much for testing and for your feedback! I added support for the functionality to other pages where patron search is possible, the list is in the patch description. I also added error handling, showing the error in the user interface if there is a problem when creating the new borrower in Koha.
Any love?
Created attachment 144823 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference Add option to search patrons on ldap server when not found in local database and import it Test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Old patches didn't apply anymore so I made a new one with hopefully the same changes
Created attachment 144826 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference Add option to search patrons on ldap server when not found in local database and import it Test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Created attachment 162857 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference Add option to search patrons on ldap server when not found in local database and import it Test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Created attachment 166773 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference Add option to search patrons on ldap server when not found in local database and import it Test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Created attachment 173237 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference Add option to search patrons on ldap server when not found in local database and import it Test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Merge conflict was fix
Created attachment 174288 [details] [review] Bug 11808: Add the SearchCardnumberWithLDAP system preference Add option to search patrons on ldap server when not found in local database and import it Test plan: 0. You need to have an ldap server containing patron informations configured in Koha. 1. Apply patch and update database. 2. Check that the new system preference SearchCardnumberWithLDAP has been added and set as 'never'. 3. Choose a patron who exists in your ldap server but not in Koha. (you can delete an existing patron from Koha if needed) 4. Search for the patron by it's cardnumber in the following locations. Do not choose from the dropdown list, use the submit button. - circ/circulation.pl - circ/article-request.pl - reserve/request.pl - members/member.pl both at the top and in the filter box - any page using common/patron_search.tt, for example adding a guarantor with the members/guarantor_search.pl popup => Should return cardnumber/patron not found or no results 5. Change SearchCardnumberWithLDAP to 'if not found locally'. 6. Repeat step 4. => The patron should be added to Koha. 7. Edit the patron and change any of the existing information. 8. Repeat step 4. => The patron has not been updated (the change made in step 7 is still there) 9. Change SearchCardnumberWithLDAP to 'always'. 10. Repeat step 4. => The patron has been updated. Change made in step 7 has been rewritten and patron informations is the same as in step 6. 11. Try searching for a patron who doesn't exist in Koha and has a nonexistant branch on the LDAP server. An error message should appear accompanying the absence of results.
Fixed conflict