cancel
Showing results for 
Search instead for 
Did you mean: 

Access to the Alfresco user list via the PHP API

rmanocha
Champ in-the-making
Champ in-the-making
Hi,

I am working on a PHP app that needs me to fetch the user list from alfresco (something like what the Manage System Users page/dialog does within the web client). I was wondering if there was any way to do this via the PHP API. If not, is there any other way to do this. Also, are there any directions on how to extend the PHP SDK to provide this functionality?

If none of the above can be done, is there some place I can go to understand the table structure of the alfresco database, and grab the list from in there?

Thanks
3 REPLIES 3

jariel06
Champ in-the-making
Champ in-the-making
Hi rmanocha:
There are a web service called Administration, what I did was to create a new class called Administration.php within the PHP API, this is the code:

<?php

   require_once 'WebServiceBase/WebServiceFactory.php';
   require_once 'BaseObject.php';
   
   class Administration extends BaseObject
   {
      private $_connectionUrl;
      private $_ticket;
      private $_administrationService;
   
      public function __construct($connectionUrl="http://localhost:8080/alfresco/api", $ticket)
      {
         $this->_connectionUrl = $connectionUrl;
         $this->_ticket = $ticket;
         $this->_administrationService = WebServiceFactory::getAdministrationService($this->_connectionUrl, $this->_ticket);
      }
   
      public function changePassword($username, $old_password, $new_password)
      {
         $this->_administrationService->changePassword(array (
         "userName" => $username,
         "oldPassword" => $old_password,
         "newPassword" => $new_password
         ));
      }
   
      public function getUser($username)
      {
         $result = $this->_administrationService->getUser(array("userName" => $username));
         return UserDetails::createUserDetails($result->result);
      }
   
      public function get_allUsers()
      {
         $result = $this->_administrationService->queryUsers();
         return UserQueryResult::createUserQueryResult($result->result);
      }
   }
   
   class UserQueryResult
   {
      public $query_session = null;
      public $users = array();
   
      public static function createUserQueryResult($web_service_result)
      {
         $user_query_result = new UserQueryresult();
         $user_query_result->query_session = $web_service_result->querySession;
   
         foreach($web_service_result->userDetails as $web_service_user_details)
         {
            $user_query_result->users[] = UserDetails::createUserDetails($web_service_user_details);
         }
   
         return $user_query_result;
      }
   }
   
   class UserDetails
   {
      public $name = null;
      public $user_name = null;
      public $first_name = null;
      public $last_name = null;
      public $email = null;
      public $home_folder = null;
      public $organization_id = null;
      public $password = null;  // Only set if these are the details of a new user
   
      public static function createUserDetails($web_service_user_details)
      {
         $user_details = new UserDetails();
         $user_details->user_name = $web_service_user_details->userName;
   
         foreach($web_service_user_details->properties as $property)
         {
            if ($property->name == "{http://www.alfresco.org/model/content/1.0}name")
            {
               $user_details->name = $property->value;
            }
            else if ($property->name == "{http://www.alfresco.org/model/content/1.0}firstName")
            {
               $user_details->first_name = $property->value;
            }
            else if ($property->name == "{http://www.alfresco.org/model/content/1.0}lastName")
            {
               $user_details->last_name = $property->value;
            }
            else if ($property->name == "{http://www.alfresco.org/model/content/1.0}email")
            {
               $user_details->email = $property->value;
            }
            else if ($property->name == "{http://www.alfresco.org/model/content/1.0}organizationId")
            {
               $user_details->organization_id = $property->value;
            }
            else if ($property->name == "{http://www.alfresco.org/model/content/1.0}homeFolder")
            {
               $user_details->home_folder = $property->value;
            }
         }
   
         return $user_details;
      }
   }

?>

with the function get_allUsers() you cant get all users….

sharmsram
Champ in-the-making
Champ in-the-making
On clicking preview website in both the sanboxes, getting page cannot be displayed error.

anyone plz.give me a solution.

-Cargo.

strophi
Champ in-the-making
Champ in-the-making
Hi Forum,

I think PHP API is dead and not maintained anymore.
I'm using the REST API, that's  the way to leverage PHP skills.

regards

strophi