Automatically set anonymous users' role to Visitor in ejabberd?
===

I'm working on a project that has group chat capability using XMPP and moc_muc, in which only registered users can send messages (while anonymous users can only read but not write). I'm using ejabberd, with SASL anonymous support (registered users are authenticated using a custom external script). 

The only method that I can come up right now is to use 2 different hosts for the 2 types of users, and write a component to set the roles of a user based on his/her host anytime he/she joins a room. This might work, but seems to be a quite complicated method for a seemingly trivial problem. I don't know too much about XMPP and all the specifications/modules/components in the wild, so I might have missed something obvious. I would appreciate any pointer!

Thanks a bunch