def transform_ldap_user_search(users_search_list, ldap_server_type='active_directory'):
    """
    Transform list of this module's user_search model format to the Tower API user_search format and
    visa-versa.
    """
    results = []
    if isinstance(users_search_list, list):
        # From Tower API -> module data model
        if len(users_search_list) > 0 and isinstance(users_search_list[0], list):
            for _entry in users_search_list:
                results.append(_entry[0])
        # From module data model -> Tower API
        else:
            user_search_str = ""
            if ldap_server_type == 'active_directory':
                user_search_str = '(sAMAccountname=%(user)s)'
            elif ldap_server_type == 'open_ldap':
                user_search_str = '(cn=%(user)s)'
            elif ldap_server_type == 'freeipa':
                user_search_str = '(uid=%(user)s)'
            for _entry in users_search_list:
                results.append(
                [
                    _entry,
                    "SCOPE_SUBTREE",
                    user_search_str
                ])
    return results