cancel
Showing results for 
Search instead for 
Did you mean: 

Creating alfresco user through Java API

efycaci_ramesh
Champ in-the-making
Champ in-the-making
Hi,

I have a requirement to create an Alfresco user from the external application. Through Java API I need to write a external java class through which i need to create and validate that particular user inside Alfresco repository. Can anyone provide sample for this requirement.

Thanks is advance.
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
I'd do this by writing a simple web script. The web script can use either the Java API or the JavaScript API to create a user. Your external app can then make a RESTful call to the web script.

Look at the People API on the Alfresco wiki for an example of how to do it in JavaScript: http://wiki.alfresco.com/wiki/3.3_JavaScript_API

In Java, you'd use the AuthenticationService to create the authority:
authenticationService.createAuthentication(userName, password.toCharArray());

And the PersonService to create the person:
personService.createPerson(personProps);

If you need help creating a web script, take a look at this tutorial (http://ecmarchitect.com/archives/2007/10/25/777) or the Web Scripts page on the Alfresco wiki (http://wiki.alfresco.com/wiki/Web_Scripts).

Make sure your web script runs as "admin", either by requiring admin-level authentication or using runas (which would be a potential security hole), otherwise your code won't be executed with enough access to create the new user.

Jeff