示例#1
0
def update_user_info_from_ldap(user_id):

    from invenio.legacy.bibcirculation.cern_ldap import get_user_info_from_ldap

    ccid = db.get_borrower_ccid(user_id)
    ldap_info = get_user_info_from_ldap(ccid=ccid)

    if not ldap_info:
        result = ()
    else:
        try:
            name    = ldap_info['displayName'][0]
        except KeyError:
            name    = ""
        try:
            email   = ldap_info['mail'][0]
        except KeyError:
            email   = ""
        try:
            phone   = ldap_info['telephoneNumber'][0]
        except KeyError:
            phone   = ""
        try:
            address = ldap_info['physicalDeliveryOfficeName'][0]
        except KeyError:
            address = ""
        try:
            mailbox = ldap_info['postOfficeBox'][0]
        except KeyError:
            mailbox = ""
        db.update_borrower(user_id, name, email, phone, address, mailbox)
        result = db.search_borrower_by_ccid(int(ccid))
    return result
示例#2
0
文件: utils.py 项目: mhellmic/b2share
def update_user_info_from_ldap(user_id):

    from invenio.legacy.bibcirculation.cern_ldap import get_user_info_from_ldap

    ccid = db.get_borrower_ccid(user_id)
    ldap_info = get_user_info_from_ldap(ccid=ccid)

    if not ldap_info:
        result = ()
    else:
        try:
            name    = ldap_info['displayName'][0]
        except KeyError:
            name    = ""
        try:
            email   = ldap_info['mail'][0]
        except KeyError:
            email   = ""
        try:
            phone   = ldap_info['telephoneNumber'][0]
        except KeyError:
            phone   = ""
        try:
            address = ldap_info['physicalDeliveryOfficeName'][0]
        except KeyError:
            address = ""
        try:
            mailbox = ldap_info['postOfficeBox'][0]
        except KeyError:
            mailbox = ""
        db.update_borrower(user_id, name, email, phone, address, mailbox)
        result = db.search_borrower_by_ccid(int(ccid))
    return result
示例#3
0
文件: utils.py 项目: mhellmic/b2share
def search_user(column, string):
    if string is not None:
        string = string.strip()

    if CFG_CERN_SITE == 1:
        if column == 'name':
            result = db.search_borrower_by_name(string)
        else:
            if column == 'email':
                try:
                    result = db.search_borrower_by_email(string)
                except:
                    result = ()
            else:
                try:
                    result = db.search_borrower_by_ccid(string)
                except:
                    result = ()

            if result == ():
                from invenio.legacy.bibcirculation.cern_ldap \
                     import get_user_info_from_ldap

                ldap_info = 'busy'
                while ldap_info == 'busy':
                    time.sleep(1)
                    if column == 'id' or column == 'ccid':
                        ldap_info = get_user_info_from_ldap(ccid=string)
                    elif column == 'email':
                        ldap_info = get_user_info_from_ldap(email=string)
                    else:
                        ldap_info = get_user_info_from_ldap(nickname=string)

                if len(ldap_info) == 0:
                    result = ()
                else:
                    try:
                        name = ldap_info['displayName'][0]
                    except KeyError:
                        name = ""
                    try:
                        email = ldap_info['mail'][0]
                    except KeyError:
                        email = ""
                    try:
                        phone = ldap_info['telephoneNumber'][0]
                    except KeyError:
                        phone = ""
                    try:
                        address = ldap_info['physicalDeliveryOfficeName'][0]
                    except KeyError:
                        address = ""
                    try:
                        mailbox = ldap_info['postOfficeBox'][0]
                    except KeyError:
                        mailbox = ""
                    try:
                        ccid = ldap_info['employeeID'][0]
                    except KeyError:
                        ccid = ""

                    try:
                        db.new_borrower(ccid, name, email, phone,
                                    address, mailbox, '')
                    except:
                        pass
                    result = db.search_borrower_by_ccid(int(ccid))

    else:
        if column == 'name':
            result = db.search_borrower_by_name(string)
        elif column == 'email':
            result = db.search_borrower_by_email(string)
        else:
            result = db.search_borrower_by_id(string)

    return result
示例#4
0
文件: api.py 项目: SCOAP3/invenio
def ill_register_request(uid, title, authors, place, publisher, year, edition,
                isbn, period_of_interest_from, period_of_interest_to,
                additional_comments, conditions, only_edition, request_type,
                barcode='', ln=CFG_SITE_LANG):
    """
    Register new ILL request. Create new record (collection: ILL Books)

    @param uid: user id
    @type: int

    @param authors: book's authors
    @type authors: string

    @param place: place of publication
    @type place: string

    @param publisher: book's publisher
    @type publisher: string

    @param year: year of publication
    @type year: string

    @param edition: book's edition
    @type edition: string

    @param isbn: book's isbn
    @type isbn: string

    @param period_of_interest_from: period of interest - from(date)
    @type period_of_interest_from: string

    @param period_of_interest_to: period of interest - to(date)
    @type period_of_interest_to: string

    @param additional_comments: comments given by the user
    @type additional_comments: string

    @param conditions: ILL conditions
    @type conditions: boolean

    @param only_edition: borrower wants only the given edition
    @type only_edition: boolean
    """

    _ = gettext_set_language(ln)

    item_info = (title, authors, place, publisher, year, edition, isbn)
    create_ill_record(item_info)

    book_info = {'title': title, 'authors': authors, 'place': place,
                 'publisher': publisher, 'year': year, 'edition': edition,
                 'isbn': isbn}

    user = collect_user_info(uid)
    borrower_id = db.get_borrower_id_by_email(user['email'])

    #Check if borrower is on DB.
    if borrower_id != 0:
        address = db.get_borrower_address(user['email'])

        #Check if borrower has an address.
        if address != 0:

            #Check if borrower has accepted ILL conditions.
            if conditions:

                #Register ILL request on crcILLREQUEST.
                db.ill_register_request(book_info, borrower_id,
                                        period_of_interest_from,
                                        period_of_interest_to,
                                        CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                        additional_comments,
                                        only_edition or 'False', request_type,
                                        budget_code='', barcode=barcode)

                #Display confirmation message.
                message = _("Your ILL request has been registered and the " \
                          "document will be sent to you via internal mail.")

                #Notify librarian about new ILL request.
                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                               toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                               subject=_('ILL request for books confirmation'),
                               content="",
                               attempt_times=1,
                               attempt_sleeptime=10
                               )

            #Borrower did not accept ILL conditions.
            else:
                infos = []
                infos.append(_("You didn't accept the ILL conditions."))
                body = bc_templates.tmpl_display_ill_form(infos=infos, ln=ln)

        #Borrower doesn't have an address.
        else:

            #If BibCirculation at CERN, use LDAP.
            if CFG_CERN_SITE == 1:

                email = user['email']
                result = get_user_info_from_ldap(email)

                try:
                    ldap_address = result['physicalDeliveryOfficeName'][0]
                except KeyError:
                    ldap_address = None

                # verify address
                if ldap_address is not None:
                    db.add_borrower_address(ldap_address, email)

                    db.ill_register_request(book_info, borrower_id,
                                        period_of_interest_from,
                                        period_of_interest_to,
                                        CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                        additional_comments,
                                        only_edition or 'False',
                                        request_type, budget_code='', barcode=barcode)

                    message = _("Your ILL request has been registered and" \
                              " the document will be sent to you via" \
                              " internal mail.")


                    send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                               toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                               subject=_('ILL request for books confirmation'),
                               content="",
                               attempt_times=1,
                               attempt_sleeptime=10
                               )
                else:
                    message = _("It is not possible to validate your request.")
                    message += ' ' + _("Your office address is not available.")
                    message += ' ' + _("Please contact %(contact_email)s") % \
                           {'contact_email': CFG_BIBCIRCULATION_LIBRARIAN_EMAIL}

    else:

        # Get information from CERN LDAP
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user['email'])

            try:
                name = result['cn'][0]
            except KeyError:
                name = None

            try:
                email = result['mail'][0]
            except KeyError:
                email = None

            try:
                phone = result['telephoneNumber'][0]
            except KeyError:
                phone = None

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            try:
                mailbox = result['postOfficeBox'][0]
            except KeyError:
                mailbox = None

            try:
                ccid = result['employeeID'][0]
            except KeyError:
                ccid = ''

            # verify address
            if address is not None:
                db.new_borrower(ccid, name, email, phone, address, mailbox, '')

                borrower_id = db.get_borrower_id_by_email(email)

                db.ill_register_request(book_info, borrower_id,
                                        period_of_interest_from,
                                        period_of_interest_to,
                                        CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                        additional_comments,
                                        only_edition or 'False',
                                        request_type, budget_code='', barcode=barcode)

                message = _("Your ILL request has been registered and" \
                          " the document will be sent to you via" \
                          " internal mail.")

                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                           subject='ILL request for books confirmation',
                           content="",
                           attempt_times=1,
                           attempt_sleeptime=10
                           )

            else:
                message = _("It is not possible to validate your request.")
                message += ' ' + _("Your office address is not available.")
                message += ' ' + _("Please contact %(contact_email)s") % \
                           {'contact_email': CFG_BIBCIRCULATION_LIBRARIAN_EMAIL}

    body = bc_templates.tmpl__with_recid(message=message,
                                                             ln=ln)

    return body
示例#5
0
文件: api.py 项目: SCOAP3/invenio
def ill_register_request_with_recid(recid, uid, period_of_interest_from,
                                    period_of_interest_to, additional_comments,
                                    conditions, only_edition, barcode='',
                                    ln=CFG_SITE_LANG):
    """
    Register a new ILL request.

    @param recid: identify the record. Primary key of bibrec.
    @type recid: int

    @param uid: user id
    @type: int

    @param period_of_interest_from: period of interest - from(date)
    @type period_of_interest_from: string

    @param period_of_interest_to: period of interest - to(date)
    @type period_of_interest_to: string
    """

    _ = gettext_set_language(ln)

    # Create a dictionary.
    book_info = "{'recid': " + str(recid) + "}"

    user = collect_user_info(uid)
    borrower_id = db.get_borrower_id_by_email(user['email'])

    if borrower_id is None:
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user['email'])

            try:
                name = result['cn'][0]
            except KeyError:
                name = None

            try:
                email = result['mail'][0]
            except KeyError:
                email = None

            try:
                phone = result['telephoneNumber'][0]
            except KeyError:
                phone = None

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            try:
                mailbox = result['postOfficeBox'][0]
            except KeyError:
                mailbox = None

            try:
                ccid = result['employeeID'][0]
            except KeyError:
                ccid = ''

            if address is not None:
                db.new_borrower(ccid, name, email, phone, address, mailbox, '')
            else:
                message = bc_templates.tmpl_message_request_send_fail_cern("Office address not available.")
        else:
            message = bc_templates.tmpl_message_request_send_fail_other("Office address not available.")

        return bc_templates.tmpl_ill_register_request_with_recid(
                                                            message=message,
                                                            ln=ln)

    address = db.get_borrower_address(user['email'])
    if not address:
        if CFG_CERN_SITE == 1:
            email = user['email']
            result = get_user_info_from_ldap(email)

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            if address is not None:
                db.add_borrower_address(address, email)
            else:
                message = bc_templates.tmpl_message_request_send_fail_cern("Office address not available.")
        else:
            message = bc_templates.tmpl_message_request_send_fail_other("Office address not available.")

        return bc_templates.tmpl_ill_register_request_with_recid(
                                                               message=message,
                                                               ln=ln)

    if not conditions:
        infos = []
        infos.append(_("You didn't accept the ILL conditions."))
        return bc_templates.tmpl_ill_request_with_recid(recid,
                                                        infos=infos,
                                                        ln=ln)

    elif conditions == 'register_acquisition_suggestion':
        # This ILL request entry is a book proposal.
        db.ill_register_request(book_info, borrower_id,
                                period_of_interest_from, period_of_interest_to,
                                CFG_BIBCIRCULATION_PROPOSAL_STATUS_NEW,
                                additional_comments,
                                only_edition or 'False','proposal-book', barcode=barcode)

    else:
        db.ill_register_request(book_info, borrower_id,
                                period_of_interest_from, period_of_interest_to,
                                CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                additional_comments,
                                only_edition or 'False','book', barcode=barcode)

        if CFG_CERN_SITE == 1:
            message = bc_templates.tmpl_message_request_send_ok_cern()
        else:
            message = bc_templates.tmpl_message_request_send_ok_other()

        #Notify librarian about new ILL request.
        send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                    toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                    subject='ILL request for books confirmation',
                    content='',
                    #hold_request_mail(recid=recid, borrower_id=borrower_id),
                    attempt_times=1,
                    attempt_sleeptime=10)

        return bc_templates.tmpl_ill_register_request_with_recid(
                                                               message=message,
                                                               ln=ln)
示例#6
0
def ill_register_request(uid,
                         title,
                         authors,
                         place,
                         publisher,
                         year,
                         edition,
                         isbn,
                         period_of_interest_from,
                         period_of_interest_to,
                         additional_comments,
                         conditions,
                         only_edition,
                         request_type,
                         barcode='',
                         ln=CFG_SITE_LANG):
    """
    Register new ILL request. Create new record (collection: ILL Books)

    @param uid: user id
    @type: int

    @param authors: book's authors
    @type authors: string

    @param place: place of publication
    @type place: string

    @param publisher: book's publisher
    @type publisher: string

    @param year: year of publication
    @type year: string

    @param edition: book's edition
    @type edition: string

    @param isbn: book's isbn
    @type isbn: string

    @param period_of_interest_from: period of interest - from(date)
    @type period_of_interest_from: string

    @param period_of_interest_to: period of interest - to(date)
    @type period_of_interest_to: string

    @param additional_comments: comments given by the user
    @type additional_comments: string

    @param conditions: ILL conditions
    @type conditions: boolean

    @param only_edition: borrower wants only the given edition
    @type only_edition: boolean
    """

    _ = gettext_set_language(ln)

    item_info = (title, authors, place, publisher, year, edition, isbn)
    create_ill_record(item_info)

    book_info = {
        'title': title,
        'authors': authors,
        'place': place,
        'publisher': publisher,
        'year': year,
        'edition': edition,
        'isbn': isbn
    }

    user = collect_user_info(uid)
    borrower_id = db.get_borrower_id_by_email(user['email'])

    #Check if borrower is on DB.
    if borrower_id != 0:
        address = db.get_borrower_address(user['email'])

        #Check if borrower has an address.
        if address != 0:

            #Check if borrower has accepted ILL conditions.
            if conditions:

                #Register ILL request on crcILLREQUEST.
                db.ill_register_request(book_info,
                                        borrower_id,
                                        period_of_interest_from,
                                        period_of_interest_to,
                                        CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                        additional_comments,
                                        only_edition or 'False',
                                        request_type,
                                        budget_code='',
                                        barcode=barcode)

                #Display confirmation message.
                message = _("Your ILL request has been registered and the " \
                          "document will be sent to you via internal mail.")

                #Notify librarian about new ILL request.
                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                           subject=_('ILL request for books confirmation'),
                           content="",
                           attempt_times=1,
                           attempt_sleeptime=10)

            #Borrower did not accept ILL conditions.
            else:
                infos = []
                infos.append(_("You didn't accept the ILL conditions."))
                body = bc_templates.tmpl_display_ill_form(infos=infos, ln=ln)

        #Borrower doesn't have an address.
        else:

            #If BibCirculation at CERN, use LDAP.
            if CFG_CERN_SITE == 1:

                email = user['email']
                result = get_user_info_from_ldap(email)

                try:
                    ldap_address = result['physicalDeliveryOfficeName'][0]
                except KeyError:
                    ldap_address = None

                # verify address
                if ldap_address is not None:
                    db.add_borrower_address(ldap_address, email)

                    db.ill_register_request(book_info,
                                            borrower_id,
                                            period_of_interest_from,
                                            period_of_interest_to,
                                            CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                            additional_comments,
                                            only_edition or 'False',
                                            request_type,
                                            budget_code='',
                                            barcode=barcode)

                    message = _("Your ILL request has been registered and" \
                              " the document will be sent to you via" \
                              " internal mail.")

                    send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                               toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                               subject=_('ILL request for books confirmation'),
                               content="",
                               attempt_times=1,
                               attempt_sleeptime=10)
                else:
                    message = _("It is not possible to validate your request.")
                    message += ' ' + _("Your office address is not available.")
                    message += ' ' + _("Please contact %(contact_email)s") % \
                           {'contact_email': CFG_BIBCIRCULATION_LIBRARIAN_EMAIL}

    else:

        # Get information from CERN LDAP
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user['email'])

            try:
                name = result['cn'][0]
            except KeyError:
                name = None

            try:
                email = result['mail'][0]
            except KeyError:
                email = None

            try:
                phone = result['telephoneNumber'][0]
            except KeyError:
                phone = None

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            try:
                mailbox = result['postOfficeBox'][0]
            except KeyError:
                mailbox = None

            try:
                ccid = result['employeeID'][0]
            except KeyError:
                ccid = ''

            # verify address
            if address is not None:
                db.new_borrower(ccid, name, email, phone, address, mailbox, '')

                borrower_id = db.get_borrower_id_by_email(email)

                db.ill_register_request(book_info,
                                        borrower_id,
                                        period_of_interest_from,
                                        period_of_interest_to,
                                        CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                        additional_comments,
                                        only_edition or 'False',
                                        request_type,
                                        budget_code='',
                                        barcode=barcode)

                message = _("Your ILL request has been registered and" \
                          " the document will be sent to you via" \
                          " internal mail.")

                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
                           subject='ILL request for books confirmation',
                           content="",
                           attempt_times=1,
                           attempt_sleeptime=10)

            else:
                message = _("It is not possible to validate your request.")
                message += ' ' + _("Your office address is not available.")
                message += ' ' + _("Please contact %(contact_email)s") % \
                           {'contact_email': CFG_BIBCIRCULATION_LIBRARIAN_EMAIL}

    body = bc_templates.tmpl__with_recid(message=message, ln=ln)

    return body
示例#7
0
def ill_register_request_with_recid(recid,
                                    uid,
                                    period_of_interest_from,
                                    period_of_interest_to,
                                    additional_comments,
                                    conditions,
                                    only_edition,
                                    barcode='',
                                    ln=CFG_SITE_LANG):
    """
    Register a new ILL request.

    @param recid: identify the record. Primary key of bibrec.
    @type recid: int

    @param uid: user id
    @type: int

    @param period_of_interest_from: period of interest - from(date)
    @type period_of_interest_from: string

    @param period_of_interest_to: period of interest - to(date)
    @type period_of_interest_to: string
    """

    _ = gettext_set_language(ln)

    # Create a dictionary.
    book_info = "{'recid': " + str(recid) + "}"

    user = collect_user_info(uid)
    borrower_id = db.get_borrower_id_by_email(user['email'])

    if borrower_id is None:
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user['email'])

            try:
                name = result['cn'][0]
            except KeyError:
                name = None

            try:
                email = result['mail'][0]
            except KeyError:
                email = None

            try:
                phone = result['telephoneNumber'][0]
            except KeyError:
                phone = None

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            try:
                mailbox = result['postOfficeBox'][0]
            except KeyError:
                mailbox = None

            try:
                ccid = result['employeeID'][0]
            except KeyError:
                ccid = ''

            if address is not None:
                db.new_borrower(ccid, name, email, phone, address, mailbox, '')
            else:
                message = bc_templates.tmpl_message_request_send_fail_cern(
                    "Office address not available.")
        else:
            message = bc_templates.tmpl_message_request_send_fail_other(
                "Office address not available.")

        return bc_templates.tmpl_ill_register_request_with_recid(
            message=message, ln=ln)

    address = db.get_borrower_address(user['email'])
    if not address:
        if CFG_CERN_SITE == 1:
            email = user['email']
            result = get_user_info_from_ldap(email)

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            if address is not None:
                db.add_borrower_address(address, email)
            else:
                message = bc_templates.tmpl_message_request_send_fail_cern(
                    "Office address not available.")
        else:
            message = bc_templates.tmpl_message_request_send_fail_other(
                "Office address not available.")

        return bc_templates.tmpl_ill_register_request_with_recid(
            message=message, ln=ln)

    if not conditions:
        infos = []
        infos.append(_("You didn't accept the ILL conditions."))
        return bc_templates.tmpl_ill_request_with_recid(recid,
                                                        infos=infos,
                                                        ln=ln)

    elif conditions == 'register_acquisition_suggestion':
        # This ILL request entry is a book proposal.
        db.ill_register_request(book_info,
                                borrower_id,
                                period_of_interest_from,
                                period_of_interest_to,
                                CFG_BIBCIRCULATION_PROPOSAL_STATUS_NEW,
                                additional_comments,
                                only_edition or 'False',
                                'proposal-book',
                                barcode=barcode)

    else:
        db.ill_register_request(book_info,
                                borrower_id,
                                period_of_interest_from,
                                period_of_interest_to,
                                CFG_BIBCIRCULATION_ILL_STATUS_NEW,
                                additional_comments,
                                only_edition or 'False',
                                'book',
                                barcode=barcode)

        if CFG_CERN_SITE == 1:
            message = bc_templates.tmpl_message_request_send_ok_cern()
        else:
            message = bc_templates.tmpl_message_request_send_ok_other()

        #Notify librarian about new ILL request.
        send_email(
            fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
            toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL,
            subject='ILL request for books confirmation',
            content='',
            #hold_request_mail(recid=recid, borrower_id=borrower_id),
            attempt_times=1,
            attempt_sleeptime=10)

        return bc_templates.tmpl_ill_register_request_with_recid(
            message=message, ln=ln)
示例#8
0
def search_user(column, string):
    if string is not None:
        string = string.strip()

    if CFG_CERN_SITE == 1:
        if column == 'name':
            result = db.search_borrower_by_name(string)
        else:
            if column == 'email':
                try:
                    result = db.search_borrower_by_email(string)
                except:
                    result = ()
            else:
                try:
                    result = db.search_borrower_by_ccid(string)
                except:
                    result = ()

            if result == ():
                from invenio.legacy.bibcirculation.cern_ldap \
                     import get_user_info_from_ldap

                ldap_info = 'busy'
                while ldap_info == 'busy':
                    time.sleep(1)
                    if column == 'id' or column == 'ccid':
                        ldap_info = get_user_info_from_ldap(ccid=string)
                    elif column == 'email':
                        ldap_info = get_user_info_from_ldap(email=string)
                    else:
                        ldap_info = get_user_info_from_ldap(nickname=string)

                if len(ldap_info) == 0:
                    result = ()
                else:
                    try:
                        name = ldap_info['displayName'][0]
                    except KeyError:
                        name = ""
                    try:
                        email = ldap_info['mail'][0]
                    except KeyError:
                        email = ""
                    try:
                        phone = ldap_info['telephoneNumber'][0]
                    except KeyError:
                        phone = ""
                    try:
                        address = ldap_info['physicalDeliveryOfficeName'][0]
                    except KeyError:
                        address = ""
                    try:
                        mailbox = ldap_info['postOfficeBox'][0]
                    except KeyError:
                        mailbox = ""
                    try:
                        ccid = ldap_info['employeeID'][0]
                    except KeyError:
                        ccid = ""

                    try:
                        db.new_borrower(ccid, name, email, phone,
                                    address, mailbox, '')
                    except:
                        pass
                    result = db.search_borrower_by_ccid(int(ccid))

    else:
        if column == 'name':
            result = db.search_borrower_by_name(string)
        elif column == 'email':
            result = db.search_borrower_by_email(string)
        else:
            result = db.search_borrower_by_id(string)

    return result