Return the unit id to the unit 'unit_name'

def get_unit_id(unit_name):
    """
    Return the unit id to the unit 'unit_name'
    """
    unit_name = unit_name.lower()
    attribute = 'uniqueIdentifier'
    response = LDAP_search(
        pattern_search='(cn={})'.format(unit_name),
        attribute=attribute
    )

    unit_id = ""
    try:
        for element in response:
            if 'dn' in element and element['dn'].startswith('ou={},'.format(unit_name)):
                unit_id = element['attributes'][attribute][0]
    except Exception:
        raise EpflLdapException("The unit named '{}' was not found".format(unit_name))
    finally:
        if not unit_id:
            raise EpflLdapException("The unit named '{}' was not found".format(unit_name))

    return unit_id