How to add a user to a group with cURL ?

Hi

—– New additional remark at the bottom of the page… —-

My local group : g_toto
My ldap user : titi
My local powerusers user : puadmin
My ldap administrator user : ldamin

I tried to add the Titi user in the G_toto group and it works with Nuxeo/nxadmin > Admin Center > Users and Groups.

If I create the group with cUrl and I directly adds the user, it also works :

  • curl -X POST 'http://mysite/nuxeo/api/v1/group' -u puadmin:pupwd -H 'Content-Type: application/json' -d '{ “entity-type”: “group”, “groupname”:“g_toto”,“memberUsers”: [“titi”,“tata”] , “memberGroups”: [“alltxtx”] } '

But this seems not to work with Curl to add a new user.
I tried multiple combinations :

  • curl -X POST 'http://mysite/nuxeo/api/v1/user/titi/group/g_toto' -u puadmin:pupwd -H 'Content-Type: application/json'
    => not authorized (powerusers)

  • curl -X POST 'http://mysite/nuxeo/api/v1/group/g_toto/user/titi' -u puadmin:pupwd -H 'Content-Type: application/json'
    => not authorized (powerusers)

  • curl -X POST 'http://mysite/nuxeo/api/v1/user/titi/group/g_toto' -u ldadmin:ldpwd -H 'Content-Type: application/json'
    => no error, but titi is not in “g_toto” (administrator)

  • curl -X POST 'http://mysite/nuxeo/api/v1/group/g_toto/user/titi' -u ldadmin:ldpwd -H 'Content-Type: application/json'
    => no error, but titi is not in “g_toto” (administrator)

Do you have an idea ?
I used the API Playground samples…

Additional remark :

I create the group “g_tata” with cURL an with the Web interface, i add this group with reading's right at the folder “MyFolder” :

  • I search g_tata and i click on “add” button
  • The group does not appear in the “Local rights” part, but Nuxeo still suggests save changes “Local rights” and when I click, it remains on the proposal but never “g_tata” will appear.
  • Yet if I look at the acl with curl, everything is good :
  • curl -X POST 'http://mysite/…/Pilote.xxx/workspaces/MyFolder/@acl' -u puadmin:pupwd -H 'Content-Type: application/json' :
    public 'name' => string 'local' (length=5)
      public 'ace' => <br>
        array (size=2)<br>
          0 => <br>
            object(stdClass)[243]<br>
              public 'username' => string '<b>g_tata</b>' (length=6)<br>
    
    …..


    Thanks a lot
1 votes

0 answers

3802 views

ANSWER