direct sql is not very recommendable.
we used an approach of:
* web scripts (javascript): the entry point
* java extensions : backing logic
the WIKI describes it quite nicely. you might want to have also a look at the Alfresco Maven AMP Plugin.
resulting in the following:
* you can create users programmatically via WEB-URL (POST)
* an AMP (alfresco module package)
This approach required some "assembly", but once you are through, it is quite flexible.
We reused code from the Alfresco Web-Client module (source code is available).
kind regards