by Andranik Sharabchian.
I can offer you some solution.
You can use another function. Create one universal user who is enrolled in the all courses. Then use the function "core_enrol_get_users_courses" with your universal user's ID.