Create a user when the logged in user doesnt have Mendix administrator rights

I would like to create an user after a new customer is saved. According to previous questions in this forum i used a java action for this. After running i still get an security warning in the mendix system. ...code... currentCustomer.setName(currentCustomer.getEmailaddress()); currentCustomer.setPassword("welcome"); currentCustomer.setUserRoles(customerUserRole); currentCustomer.setBlocked(false); Core.commit(getContext(), currentCustomer.getMendixObject()); .... 2010-04-28 09:06:23.625 WARNING - CORE: User 'nydj' attempted to commit an object of type 'Customer.Customer', but does not have the required permissions. I think that the commit is still running under the restriction of the current user instead of the administrator.
1 answers

Is this in version 2.5? If so, try getting a sudo context (i.e. a context with all rights) using this code:

IContext sudoContext = getContext().getSudoContext();

For 2.4, use the following code:

IContext sudoContext = Core.getSystemContext();

Then set changes and commit using this context:

Core.commit(sudoContext, currentCustomer.getMendixObject());