restrict usernames for signup

Hi There i have a question about userloginname restriction.
I want to be able to restrict the signup to a Wordpress site. My future user are students with a student account consisting of 6 numbers. I want them to signup for a site and force them to use a valid studentaccountnumber. I'm thinking of the next scenario. A students wants to signup, the site checks if the accountnumber is not already in use or available.( something with a list or file?)

Do you have suggestions for me how to accomplish this? Is there a plugin that does similair things? If not , do you have suggestions on how to code this? Uploading a csv file, and use a hook or filter somewhere?

Can you put me on the right track?