Create a user on Owncloud

I searched, could not find the right way to create new users on my own server. I tried applying what the User Provisioning API says, but I always get this answer:

<ocs> <meta> <status>failed</status> <statuscode>999</statuscode> <message>Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT: debug output: http request method: POST http request uri: /owncloud/ocs/v1.php/cloud/users%20-d%20userid=%22Frank%22%20-d%20password=%22frankspassword%22</message> </meta> </ocs> 

My HTTP POST:

 http://myuser: mypassword@ip _owncloud_server/owncloud/ocs/v1.php/cloud/users -d userid="Frank" -d password="frankspassword" 

What is wrong here?

+1
source share
3 answers

first, the example provided in the OwnCloud documentation is not complete. It is suggested that you use curl or another command line utility. I got this script to work using jQuery AJAX:

 <script> function doMake() { $.ajax({ type: 'POST', url: 'http://myowncloud.local:8080/ocs/v1.php/cloud/users', data: {'userid':'test', 'password':'test'}, crossDomain: true, beforeSend: function(xhr) { xhr.setRequestHeader('Authorization', 'Basic ' + window.btoa(unescape(encodeURIComponent('owncloud-dev' + ':' + 'password')))) } }).done( function(data, status, xhr) { document.write(status); }).fail( function(xhr, status, error) { document.write(status + ":" + error); }); } </script> 

save the above as adduser.html in your root directory of your own keyboard. replace the username / password of the administrator in the RequestHeader authorization.

+1
source

The message shows that he complains about the presence of quotes in your user ID (and, possibly, a password). I know you took this from an example, but if you delete the quotes, it will probably have a better chance of working:

 http://myuser: mypassword@ip _owncloud_server/owncloud/ocs/v1.php/cloud/users -d userid=Frank -d password=frankspassword 

If you want to quote things that need to be protected from the shell, put quotation marks around the entire argument, e.g.

 http://myuser: mypassword@ip _owncloud_server/owncloud/ocs/v1.php/cloud/users -d "userid=Frank" -d "password=frankspassword" 
0
source

Hi, I am posting here the answer found here for anyone who would follow on this topic: I found this to find a similar solution for myself on the Owncloud deve mailing list: http://owncloud.10557.n7.nabble.com/User- Provisioning-API-PHP-Authentification-Error-td15927.html

It seems like using this in php w / cURL:

 <?php $username = 'lukas'; $password = 'lukas'; $ch = curl_init('http://localhost/master/ocs/v1.php/cloud/groups'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); $output = curl_exec($ch); curl_close($ch); echo $output; 

Hope this helps

0
source

Source: https://habr.com/ru/post/1239670/


All Articles