From Wookieepedia, the Star Wars wiki.

Midshipmen were trainees onboard capital ships. The captain of the ship would often spend a short time with them each day for instruction. The midshipmen were ranked higher than enlisted men, such as stormtroopers, but below regular officers. When the captain felt the midshipman was ready, they would be promoted to ensign. As an ensign, they would begin a road eventually, hopefully, leading to command of their own captaincy and ship someday.