What is the proper and legal procedure to obtain a work permit?

To work as a teacher? Also, for other types of work that a farang may do according to Thai law.