Reputation: 33534
Here is alfresco-demo-data, they create user, group and some pieces of repository. But if you look a little deeper into code and examine PeopleUsersGroupAcpExporter, you see that to create some users you need:
123
password.PeopleUsersGroupAcpExporter
,
DynamicBootstrapPatchPostProcessor
, ResourcesResolver
,
UsersImporterPatch
, GroupsImporterPatch
with a lot of code.And finally this classes wrap (put) some data into spring bean definition.
Definitely there are must much simpler way to create/import user and group at alfresco start up.
Note 1
Here is very similar question, but they used authenticationService
, whithout telling what type it is. There is org.jbpm.security.AuthenticationService
and org.alfresco.service.cmr.security.AuthenticationService
but both do not have any *create*
methods
Note 2
Alfresco already has a feature csv import/expport user, but it is about users only. It do not provides attaching imported users to group automatically.
Upvotes: 0
Views: 686
Reputation: 107
Yes you can here is the code
if (this.authenticationService.authenticationExists(userName) == false)
{
this.authenticationService.createAuthentication(userName, password.toCharArray());
PropertyMap ppOne = new PropertyMap(4);
ppOne.put(ContentModel.PROP_USERNAME, userName);
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
ppOne.put(ContentModel.PROP_EMAIL, userName+"@example.com");
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
this.personService.createPerson(ppOne);
}
Upvotes: 1
Reputation: 10538
If you define your users and groups in an LDAP directory such as OpenLDAP or Apache Directory Server then you can simply add about ten lines of config to your alfresco-global.properties file, and all your users and groups will be sync'd into Alfresco on every startup. This has the added advantages of:
Upvotes: 1