Executing some action after registering thru SIP



is there any way to execute some script when somebody is registered using SIP (or H.323, IAX, whatever…)? I need to lock users in external DB whenever they’re registered. AGI isn’t a solution, beceause for running AGI scripts user has to be registered already…