cancel
Showing results for 
Search instead for 
Did you mean: 

Create Users PHP -> Alfresco

chandana_weer
Champ in-the-making
Champ in-the-making
Hi,
Anybody know how to create users by PHP webservice? Can I write my own webserice client and server end for this?

Thank
CW
7 REPLIES 7

samudaya
Champ on-the-rise
Champ on-the-rise
My ideas is, it is easy to use exiting Alfresco service for server-end. And also you can use "ifresco-phplib" for client side php coding works.

You can download
http://forge.alfresco.com/projects/ifresco-phplib/


And you can have more ideas from;
http://forums.alfresco.com/en/viewtopic.php?f=21&t=38685'>http://forums.alfresco.com/en/viewtopic.php?f=21&t=38685

samudaya
Champ on-the-rise
Champ on-the-rise
Try to take ideas from with this forum;

http://forums.alfresco.com/en/viewtopic.php?f=21&t=38685

chandana_weer
Champ in-the-making
Champ in-the-making
Thanks samudaya,

There is an another error;
Fatal error: Uncaught SoapFault exception: [Client] Function ("newUsers") is not a valid method for this service


Thank you very much

samudaya
Champ on-the-rise
Champ on-the-rise
Hi,

Try to take ideas from with this forum;
http://forums.alfresco.com/en/viewtopic.php?f=21&t=38685


ifresco-phplib  -> Alfresco/Service/Administration.php

   public function createUser($userDetails) {
        $result = $this->administrationService->newUsers(array(
                            "newUsers" => $userDetails));
        $resultSet = $result->result;  
        return $this->resultSetToUserDetails($this->_session,$this->_store,$resultSet);       
   }

Correct Code

   public function createUser($userDetails) {
        $result = $this->administrationService->createUsers(array(
                            "newUsers" => $userDetails));
        $resultSet = $result->result;  
        return $this->resultSetToUserDetails($this->_session,$this->_store,$resultSet);       
   }

samudaya
Champ on-the-rise
Champ on-the-rise
This is the perfectly working code for me…..


$repositoryUrl = "http://test.com:8080/alfresco/api";
$userName = "admin";
$password = "password";

// Include the required Alfresco PHP API objects
require_once "Alfresco/Service/Repository.php";
require_once "Alfresco/Service/Session.php";
require_once "Alfresco/Service/SpacesStore.php";
require_once "Alfresco/Service/UserDetail.php";
require_once "Alfresco/Service/Administration.php";
require_once "Alfresco/Service/NamedValues.php";

// Authenticate the user and create a session
$repository = new Repository($repositoryUrl);
$ticket = $repository->authenticate($userName, $password);
$session = $repository->createSession($ticket);
$spacesStore = new SpacesStore($session);

$administration = new Administration($repository,$spacesStore,$session);

$NamedValues = new NamedValues($session);
$NamedValues->cm_firstName = "FIRSTNAME";
$NamedValues->cm_lastName = "LASTNAME";
$NamedValues->cm_email = "EMAIL@EMAIL.COM";

$userDetails = array("userName"=>"USERNAME",
"password"=>"PASSWORD",
"properties"=>$NamedValues->__toArray());

print_r($administration->createUser($userDetails));

chandana_weer
Champ in-the-making
Champ in-the-making
Thanks samu,

Finally I solved the problem.

Thanks
CW

ddanninger
Champ in-the-making
Champ in-the-making
Glad to see that the library works fine for most of you ;D and iam not the only one in php library who helps others Smiley Very Happy

ill fix the problem next week 😃

hope the php area will grow on alfresco Smiley Very Happy