cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize Alfresco users with another application

jco
Champ in-the-making
Champ in-the-making
Hello,

i've been looking through the Alfresco documentation and forums for one day, and i couldnt find a lot of help there to give me an answer…

I am looking for a way to synchronize my users / groups / spaces in Alfresco , using another user database from my own application. The synchronization would go in only one direction , considering i want to restrict user management in Alfresco itself.

My wish is to create a java application providing restful web-services to post/put users in Alfresco when they are modified on my app. This restful wrapping is already set up, but i need help for the alfresco side.

Are there any available alfresco REST api to do such things ? The only thing i could find were typical javascript side consuming APIs … And my wish is not to use the SOAP webservices, as i want to keep homogeneous technologies (Rest webservice from my app calling SOAP ws from alfresco sounds like a mess to me…).

If this is not possible through REST apis , is it possible to use alfresco native services (by adding dependencies to the repository, core etc..) to populate the database with my users ?


Thanks a lot for your help,

Jco.
6 REPLIES 6

openpj
Elite Collaborator
Elite Collaborator
If this is not possible through REST apis , is it possible to use alfresco native services (by adding dependencies to the repository, core etc..) to populate the database with my users ?
Yes, it is possible using REST and using native exposed services, most of the services are exposed using the following context path:

- /alfresco/service/api/people
- /alfresco/service/api/person

If you try to access at the WebScripts service page of Alfresco (/alfresco/service/) you should see the following details about person and people service:
Update user password
POST /alfresco/service/api/person/changepassword/{userName}

Update the password of a current user. It can only be executed for the current user or by an administrator to update any user.

Authentication:   user
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/changepassword.post
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/changepassword.post.desc.xml

Get People
GET /alfresco/service/api/people?filter={filterQuery?}

Get a collection of people stored in the repository. This can optionally be filtered according to a given filter query string

Authentication:   user
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/people.get
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/people.get.desc.xml

Add Person
POST /alfresco/service/api/people

Adds a new person based on the details provided.
userName
mandatory - the user name for the new user
firstName
mandatory - the given Name
lastName
mandatory - the family name
email
mandatory - the email address
password
optional - the new user's password. If not specified then a value of "password" is used which should be changed as soon as possible.
disableAccount
optional - If present and set to "true" the user is created but their account will be disabled.
quota
optional - Sets the quota size for the new user, in bytes.
groups
optional - Array of group names to assign the new user to.
title
optional - the title for the new user.
organisation
optional - the organisation the new user belongs to.
jobtitle
optional - the job title of the new user.

Authentication:   admin
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/people.post
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/people.post.desc.xml

Delete Person
DELETE /alfresco/service/api/people/{userName}

Delete a person.

Authentication:   admin
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/person.delete
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/person.delete.desc.xml

Get Person
GET /alfresco/service/api/people/{userName}

Get the details of a person.

Authentication:   user
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/person.get
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/person.get.desc.xml

Update Person
PUT /alfresco/service/api/people/{userName}

Update the details of a person.

Authentication:   user
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/person.put
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/person.put.desc.xml

Get sites
GET /alfresco/service/api/people/{userid}/sites?size={pagesize?}&pos={position?}

Get a collection of the sites of which a a person is an explicit member.

Authentication:   user
Transaction:   required
Format Style:   argument
Default Format:   json
Id:   org/alfresco/repository/person/person.sites.get
Descriptor:   classpath:alfresco/templates/webscripts/org/alfresco/repository/person/person.sites.get.desc.xml
If you need to expose from Alfresco a custom service you can implement your own WebScript using the People API:
http://wiki.alfresco.com/wiki/3.4_JavaScript_API#People_API

Hope this helps.

mrogers
Star Contributor
Star Contributor
The other thing you might like to look at is some sort of user import into alfresco.   Its probably easiest if you just throw your users into a directory system in particular one with an LDAP interface and then have both your app and alfresco use it.

jco
Champ in-the-making
Champ in-the-making
Thanks for giving me all these informations .
The REST API is definitely what i want to use to achieve this 🙂
Do you know if i can find samples of remote calling to these API using java ? i'm especially wondering on how can i authenticate with my "admin" user (my first attemps gives me a 401 http response).

Thank you for any hint  Smiley Wink

jco.

jco
Champ in-the-making
Champ in-the-making
Hello all,
after some trial&errors, i achieved to get and use a token to get or create users thanks to REST APis. I'm available if someone needs help about how to do this in java Smiley Wink

Everything is alright , but there is something i couldn't achieve. I would like to be able, during user creation, to create him in the alfresco system as an "admin" or a "guest", depending on a field's value on my own database.

The POST method in /api/people API describe a way to add the new user to alfresco groups , so i tried to send a JSON array in my post request :
"groups":["ALFRESCO_ADMINISTRATORS"]

but it doesn't work , even if i try to do the same with a custom group of my own. Furthermore, i couldn't find any other API for such purpose.
Does anyone would have some information about this ?

I would be very grateful.

Thanks,

JCO.

jco
Champ in-the-making
Champ in-the-making
To answer to myself,

the way i was doing things was good, i just didnt know that Alfresco group's ids are name like "GROUP_XXX" with XXX the actual group name. So a line like :
"groups":["GROUP_ALFRESCO_ADMINISTRATORS"]

in my json file do the job well.


JCO.

karthik_develop
Champ in-the-making
Champ in-the-making
Hi to all,

      In my Project,i have to access alfresco repository from external java application for creating user login information and their roles.
    
      After creating user information,it shoild be stored in alfresco mysql db but i need it should also reflected in my own db for external java application role mapping.

      How to achieve this?

      Thanks and any help appreciate to all,