I stuck with the use of user provisoning and php.
I tried all example like discribed in the user manual and if I do the example with curl and my terminal they are working.
But I like to send some commands via php. I like to create a new user, assign him to a group, assign a quota to him and an email adress.
<pre>
<?php
echo "Begun processing credentials , first it will be stored in local variables" . "<br/>";
// Loading into local variables
$userName = "tom";
$RRpassword = "tom";
echo "Hello " . $userName . "<br/>";
echo "Your password is " . $RRpassword . "<br/>";
// Login Credentials as Admin
$ownAdminname = 'rob';
$ownAdminpassword = 'hallo';
// Add data, to owncloud post array and then Send the http request for creating a new user
$url = 'http://' . $ownAdminname . ':' . $ownAdminpassword . '@localhost/nextcloud/ocs/v1.php/cloud/users';
echo "Created URL is " . $url . "<br/><br/>";
$ownCloudPOSTArray = array('userid' => $userName, 'password' => $RRpassword );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('OCS-APIRequest:true'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "Response from curl :" . $response;
echo "<br/>Created a new user in owncloud<br/>";
/*****************************************************************************/
// Add to a group called 'team'
$groupUrl = $url . '/' . $userName . '/' . 'groups';
echo "Created groups URL is " . $groupUrl . "<br/>";
$ownCloudPOSTArrayGroup = array('groupid' => 'team');
$ch = curl_init($groupUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('OCS-APIRequest:true'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArrayGroup);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "Response from curl :" . $response;
echo "<br/>Added the new user to default group in nextcloud<br/><br/>";
/*****************************************************************************/
// Add to a quota with 5 GB
$userUrl = $url . '/' . $userName;
echo "Created groups URL is " . $userUrl . "<br/>";
// $ownCloudPOSTArray = array( key => "email", value => "franksnewemail@example.org" );
$ch = curl_init($userUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('OCS-APIRequest:true'));
// $fields = array("quota" => "5GB");
$fields = array(
'key' => 'quota',
'value' => '5GB',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo "Response from curl :" . $response;
echo "<br/>Added the new user to default group in nextcloud<br/><br/>";
/*****************************************************************************/
?>
</pre>
This sample is working with creating the new user and assigning to a group.
I stuck with creating the quota and the email. Maybe someone else struggeld with this topic too, but was able to solve. Thanks for any help
Katasun ( sorry for all mistakes in my english )