Well, it is illegal to start with so if you are caught you could be prosecuted. This is sufficient to stop most people. Many courses have perimeters that aren't accessible so you can only gain access by going past the pro shop where you might get noticed. You might come across a course ranger who checks if you have a members tag or a green fee ticket.