cancel
Showing results for 
Search instead for 
Did you mean: 

Create Users By Using Remote PHP-Apache System

samudaya
Champ on-the-rise
Champ on-the-rise
Hi,
I'm currently running Alfresco Community 3.4.d on Ubuntu 10.04 server. I want to create user accounts by using PHP module which runs on Apache web server (this should be separate physical server) . Anyone have achieved this so far? Could you please post the codes, configurations and relevant library files.

This is a grate help for me…… 

Thanks
15 REPLIES 15

samudaya
Champ on-the-rise
Champ on-the-rise
Hello ddanninger,

Thank you for your great job…..

samudaya
Champ on-the-rise
Champ on-the-rise
Hello ddanninger,

I want to add additional properties to when creating user account by using PHP library.


<?php

   $repositoryUrl = "http://dms.abc.com:8080/alfresco/api";
   $userName = "admin";
   $password = "my-admin-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    = "user1";
   $NamedValues->cm_lastName    = "user1";
   $NamedValues->cm_email       = "user1@abc.com";
   $userDetails             = array("userName"=>"user1", "password"=>"user1", "properties"=>$NamedValues->__toArray());
   $administration->createUser($userDetails);   
?>

Do you know how to define "User-Group" and "User-Home" when we create user account by using "ifresco-phplib" ?

Thanks for your great help…

Any ideas from our forum friends?

Thanks
Samudaya

ddanninger
Champ in-the-making
Champ in-the-making
Hi,

how about if u add this to the NamedValues:


$NamedValues->cm_homeFolder  = "workspace://SpacesStore/nodeid";

did u try that already?

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

Thanks for your post. My issue is how to create folder for each user inside specific folder.

Eg:
|
|——-User (Management)
|————|
|————|——— User-1
|————|
|————|——— User-2
|————|
|————|——— User-3
|
|


When I use
$NamedValues->cm_homeFolder  = "workspace://SpacesStore/nodeid";
User (Management) is become a all users' (User-1, User-2 and  User-3) home folder.

So how to create new folder for each user (User-name is perfect for folder name)  when I create new users by using "ifresco-phplib"?

Thanks
Samudaya

ddanninger
Champ in-the-making
Champ in-the-making
Well should be a simple thing.

before you create the user create a folder -

e.g you got the input data of the user which u wanna create

username: dominik
and so on….

Get the node of the "User Homes" folder like u know the nodeid or you use lucene or you check the childs of company home.

And then create a Child node under User Homes: and set this node to the user which u will create then




$username = "dominik";
$usermail = "mail@example.com";
$password = "xxx";
$firstName = "dominiK";

$repositoryUrl = "http://dms.abc.com:8080/alfresco/api";
   $userName = "admin";
   $password = "my-admin-password";

   $repository       = new Repository($repositoryUrl);
   $ticket          = $repository->authenticate($userName, $password);
   $session          = $repository->createSession($ticket);
   $spacesStore       = new SpacesStore($session);

$MainNode = $session->getNode($spacesStore, "workspace://SpacesStore/nodeidof-user-homes");
$folderName = $username;
$userNode = $MainNode->createChild("cm_folder", "cm_contains", "cm_".$folderName);
$userNode->name = $folderName;
$sesssion->save();

$administration = new Administration($repository,$spacesStore,$session);
  
$NamedValues             = new NamedValues($session);
$NamedValues->cm_firstName    = $username;
   $NamedValues->cm_lastName    = $firstName;
   $NamedValues->cm_email       = $usermail;
$NamedValues->cm_homeFolder      = $userNode->__toString();
   $userDetails             = array("userName"=>$username, "password"=>$password, "properties"=>$NamedValues->__toArray());
   $administration->createUser($userDetails);  

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

Thanks for your post.

$MainNode = $session->getNode($spacesStore, "workspace://SpacesStore/nodeidof-user-homes");

How can I find nodeidof-user-homes ?


Thanks
Samudaya