cancel
Showing results for 
Search instead for 
Did you mean: 

add a new folder to a user home on log in with LDAP-AD

valter_85
Champ in-the-making
Champ in-the-making
hello,

I need some help!
What I want to do is this:
I want to configure a way that when an LDAP-AD user logs in for the first time, it automatically creates a folder within his user_homes. This folder is defined in the company home. The problem is I don't know how to define the path to do so.
Being more specific it's something like this that I need:

/${spaces.company_home.childname}/${spaces.user_homes.childname}/{new space template folder}

I've consulted the documentation on http://wiki.alfresco.com/wiki/Security_Services#Creating_home_spaces_-_from_1.4_onwards but it wasn't clear for me  :?
I also searched at the forum and found this thread https://forums.alfresco.com/en/viewtopic.php?f=9&t=23007, but it's not what I really need Smiley Sad

I have already tryed editing the value property in the authentication-services-context.xml, by doing the follow:

<bean name="userHomesHomeFolderProvider" class="org.alfresco.repo.security.person.UIDBasedHomeFolderProvider" parent="baseHomeFolderProvider">
         <property name="path">
           <value>/${spaces.company_home.childname}/${spaces.user_homes.childname}/cm:Work</value>
        </property>
        <property name="storeUrl">
           <value>${spaces.store}</value>
        </property>
        <property name="onCreatePermissionsManager">
            <ref bean="defaultOnCreatePermissionsManager" />
        </property>
        <property name="onReferencePermissionsManager">
            <ref bean="defaultOnReferencePermissionsManager" />
        </property>
    </bean>

where Work is the folder that I need to add to the user home, but with no success  Smiley Sad
It gives me this error:

javax.faces.FacesException: Error calling action method of component with id loginForm:submit
caused by:
javax.faces.el.EvaluationException: Exception while invoking expression #{LoginBean.login}
caused by:
java.lang.IllegalStateException: Non-unique path: found : /app:company_home/app:user_homes/cm:Work 0

Does anyone know how can I solve this? Any suggestions about what am I doing wrong? or what am I missing?
I really need help, it's urgent!

thanks in advance

valter
6 REPLIES 6

afaust
Legendary Innovator
Legendary Innovator
Hello,

for this to work, the folder "Work" has to exist. New user folders will be created within that folder and if doesn't exist, that can't be done.

But a basic question: This is a standard feature - why did you find it necessary to have to configure it manually? It should already be working out-of-the-box, that is each user will have a private folder within the User Homes created when the user is first created (not when first logged in, but created via sync). Have you encountered any problems with the standard configuration?

Regards
Axel

valter_85
Champ in-the-making
Champ in-the-making
hello Axel,
thanks for your quick response.

The folder "Work" exists in the Company Home, i've created it as the Administrator.

Insted of creating an empty user home space, i want to be created a folder inside of it, so the users wouldn't need to do that by the tradicional way. This folder contains a space template, which i have created before under the Data Dictionary\Space Templates, and it allows the users to better organize their files.
I need to do this because my project superviser requested, and he keeps insisting on it. He believes this feature would help the new users and simplifies their interaction.
The default configs are working fine, when the user logs in for the first time, it creates his user space.
But I still don't know how to figure this out.
Do you have any suggestions on how to do this?
Thanks again.

regards,
valter

afaust
Legendary Innovator
Legendary Innovator
Hello,

ok, this makes more sense to me now.

In Alfresco 4 you can use the new UsernameHomeFolderProvider (which replaces the UIDBasedHomeFolderProvider) or any subclass of it to specify a template node / space via an XPath expression, which would be
/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}/cm:YourTemplateSpaceName
in your case. When a new user space is created, that template space is copied as the new user home.

In Alfresco 3.4 and earlier, your best bet would be to subclass the UIDBasedHomeFolderProvider, override its onCreateNode method (the provider itself appears to listen on this event) and copy your space template via the Java API to NodeService.

Bear in mind that these two options only apply when the user home is initially create - existing user homes will not be adapted upon next login.

Regards
Axel

valter_85
Champ in-the-making
Champ in-the-making
hello,

thanks for your reply.
I changed the configs in the authentication.services.context.xml as you suggested.
Firstly I did this changes in the alfresco community 3.4.d, which worked but not in the way I wanted to.
Then I instaled the newest version of alfresco community (4.0) on a win server 2008 to see if it had different results, but still not what I wanted (basically it gave the same results).
When a user logs in for the first time, according to the path you've suggest, it creates the user space home inside the space template for the user joana, as follow (viewing from alfresco explorer)

Company Home > Data Dictionary > Space Templates > Work > joana

but again this is not what need.
what I need to be created is: each user is created in the user_home directory, and then inside each user space, it should be created the folder "Work", which corresponds to the predefined space template. It should be something like this that I need:

Company Home > User Homes > Joana > Work

As I mentioned before, "Work" is a space template that contains several sub-folders, structured to allow users to better organize their files.
Do you know any other way to achieve this?

thanks,

regards
Valter

afaust
Legendary Innovator
Legendary Innovator
Hello,

based on your description, I believe some of your configuration is still not correct. This indicates that you set Work as the user home path instead of the template path:
Company Home > Data Dictionary > Space Templates > Work > joana

1) Create a template node structure (manually)
Company Home > Data Dictionary > Space Templates > UserHomeTemplate > Work

2) Configure your provide like this:

<bean name="customHomeFolderProvider" class="org.alfresco.repo.security.person.UsernameHomeFolderProvider" abstract="true" parent="baseHomeFolderProvider2">
   <property name="onCreatePermissionsManager">
      <ref bean="defaultOnCreatePermissionsManager" />
   </property>
   <property name="onReferencePermissionsManager">
      <ref bean="defaultOnReferencePermissionsManager" />
   </property>
        <property name="templatePath">
           <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}/cm:UserHomeTemplate</value>
        </property>
</bean>

3) restart and retest

Regards
Axel

valter_85
Champ in-the-making
Champ in-the-making
hello,

thanks for your quick reply.
After some experiments and testing, it finally works exactly as I wanted Smiley Very Happy

I've created the bean you suggested according to the folder that I needed to be created in the user home space, however I had to do a small change on the configs.
I had to add the property name="templatePath" to my bean name="userHomesHomeFolderProvider" so it could to work properly.
here is all the order that I've done, if someone has this problem.

1º create the space template in alfresco explorer:
    Company Home > Data Dictionary > Space Templates > Your_Template

2º create the follow bean in the authentication.services.context.xml


   <bean name="customHomeFolderProvider" class="org.alfresco.repo.security.person.UsernameHomeFolderProvider" abstract="true" parent="baseHomeFolderProvider2">
      <property name="onCreatePermissionsManager">
         <ref bean="defaultOnCreatePermissionsManager" />
      </property>
      <property name="onReferencePermissionsManager">
         <ref bean="defaultOnReferencePermissionsManager" />
      </property>
        <property name="templatePath">
         <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}/cm:Your_Template</value>
        </property>
   </bean>


3º add the property name="templatePath" to the following bean:


   <bean name="userHomesHomeFolderProvider" parent="usernameHomeFolderProvider">
      <property name="rootPath">
         <value>/${spaces.company_home.childname}/${spaces.user_homes.childname}</value>
      </property>
      <property name="templatePath">
     <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}/cm:Your_Template</value>
        </property>
      <property name="storeUrl">
         <value>${spaces.store}</value>
      </property>
   </bean>

4º Restart the server and log in with a user as the first time.

As Axel mentioned before, this only works when a user logs in for the first time. Users that have already logged in and therefore have a home_space created, that space template will not appear.

This is it Smiley Very Happy

Thanks a lot Axel for your help Smiley Very Happy

Best regards,
Valter