Advertisement
Guest User

Untitled

a guest
Mar 17th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <pre>
  2. &lt;?php
  3. echo "Begun processing credentials , first it will be stored in local variables" . "<br/>";
  4.  
  5. // Loading into local variables
  6. $userName = $_POST['username'];
  7. $RRpassword = $_POST['password'];
  8.  
  9. echo "Hello " . $userName . "<br/>";
  10. echo "Your password is " . $RRpassword . "<br/>";
  11.  
  12. // Login Credentials as Admin
  13. $ownAdminname = 'ownAdmin';
  14. $ownAdminpassword = 'ufi2016%%';
  15.  
  16.  
  17. // Add data, to owncloud post array and then Send the http request for creating a new user
  18. $url = 'http://' . $ownAdminname . ':' . $ownAdminpassword . '@localhost/owncloud/ocs/v1.php/cloud/users';
  19. echo "Created URL is " . $url . "<br/>";
  20.  
  21. $ownCloudPOSTArray = array('userid' => $userName, 'password' => $RRpassword );
  22.  
  23. $ch = curl_init($url);
  24. curl_setopt($ch, CURLOPT_POST, 1);
  25. curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray);
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  27. $response = curl_exec($ch);
  28. curl_close($ch);
  29. echo "Response from curl :" . $response;
  30. echo "<br/>Created a new user in owncloud<br/>";
  31.  
  32. // Add to a group called 'Users'
  33. $groupUrl = $url . '/' . $userName . '/' . 'groups';
  34. echo "Created groups URL is " . $groupUrl . "<br/>";
  35.  
  36. $ownCloudPOSTArrayGroup = array('groupid' => 'Users');
  37.  
  38. $ch = curl_init($groupUrl);
  39. curl_setopt($ch, CURLOPT_POST, 1);
  40. curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArrayGroup);
  41. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  42. $response = curl_exec($ch);
  43. curl_close($ch);
  44. echo "Response from curl :" . $response;
  45. echo "<br/>Added the new user to default group in owncloud";
  46.  
  47. ?>
  48. </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement