if (personNode == null) { if (createMissingPeople()) { personNode = createMissingPerson(userName); } else { throw new PersonException("No person found for user name " + userName); } }
if (results.size() == 0) { throw new AlfrescoRuntimeException("Required people system path not found: " + PEOPLE_FOLDER); } else { return results.get(0); } }
public void deletePerson(String userName) { NodeRef personNodeRef = getPersonOrNull(userName);
// delete the person if (personNodeRef != null) { nodeService.deleteNode(personNodeRef); }
// translate username based on user name case sensitivity String authorityName = userNamesAreCaseSensitive ? userName : userName.toLowerCase();
// remove user from any containing authorities Set<String> containerAuthorities = authorityService.getContainingAuthorities(null, userName, true);
for (String containerAuthority : containerAuthorities) { authorityService.removeAuthority(containerAuthority, authorityName); }
// remove any user permissions permissionServiceSPI.deletePermissions(authorityName); }
public Set<NodeRef> getAllPeople() { SearchParameters sp = new SearchParameters(); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setQuery("TYPE:\"" + ContentModel.TYPE_PERSON + "\""); sp.addStore(storeRef); sp.excludeDataInTheCurrentTransaction(false); LinkedHashSet<NodeRef> nodes = new LinkedHashSet<NodeRef>(); ResultSet rs = null;
try { rs = searchService.query(sp);
for (ResultSetRow row : rs) { NodeRef nodeRef = row.getNodeRef();
if (nodeService.exists(nodeRef)) { nodes.add(nodeRef); } } } finally { if (rs != null) { rs.close(); } }
return nodes; }
public void setCreateMissingPeople(boolean createMissingPeople) { this.createMissingPeople = createMissingPeople; }
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver) { this.namespacePrefixResolver = namespacePrefixResolver; }
public void setAuthorityService(AuthorityService authorityService) { this.authorityService = authorityService; }
public void setPermissionServiceSPI(PermissionServiceSPI permissionServiceSPI) { this.permissionServiceSPI = permissionServiceSPI; }
public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }
public void setSearchService(SearchService searchService) { this.searchService = searchService; }
public void setStoreUrl(String storeUrl) { this.storeRef = new StoreRef(storeUrl); }
public void setCompanyHomePath(String companyHomePath) { this.companyHomePath = companyHomePath; }
public void setUsersHomePath(String usersHomePath) { this.usersHomePath = usersHomePath; }
public synchronized NodeRef getCompanyHome() { if (companyHomeNodeRef == null) { List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(storeRef), companyHomePath, null, namespacePrefixResolver, false);
if (refs.size() != 1) { throw new IllegalStateException("Invalid company home path: found : " + refs.size()); }
if (refs.size() != 1) { throw new IllegalStateException("Invalid users home path: found : " + refs.size()); }
usersHomeNodeRef = refs.get(0); }
return usersHomeNodeRef; } // IOC Setters }
We need modify the authentication-services-context.xml file for configuring the parent users home folder:
<bean id="personService" class="es.intecna.alfresco.repo.security.person.PersonServiceImpl"> <property name="nodeService"> <ref bean="nodeService" /> </property> <property name="searchService"> <ref bean="searchService" /> </property> <property name="permissionServiceSPI"> <ref bean="permissionServiceImpl" /> </property> <property name="authorityService"> <ref bean="authorityService" /> </property> <property name="namespacePrefixResolver"> <ref bean="namespaceService" /> </property> <!– Configurable properties. –> <!– –> <!– TODO: –> <!– Add support for creating real home spaces adn setting –> <!– permissions on the hame space and people created. –> <!– –> <!– The store in which people are persisted. –> <property name="storeUrl"> <value>${spaces.store}</value> </property> <!– The path to the company home space, used to set the –> <!– default home space for users that are created if –> <!– missing. –> <property name="companyHomePath"> <value>/${spaces.company_home.childname}</value> </property> <property name="usersHomePath"> <value>/${spaces.company_home.childname}/cm:Usuarios</value> </property> <!– Some authentication mechanisms may need to create people –> <!– in the repository on demand. This enables that feature. –> <!– If dsiabled an error will be generated for missing –> <!– people. If enabled then a person will be created and –> <!– persisted. –> <!– –> <!– This value should be false or only true if the –> <!– repository is mutable; set from the property –> <!– ${server.transaction.allow-writes} –> <property name="createMissingPeople"> <value>${server.transaction.allow-writes}</value> </property> <!– Set is user names are case sensitive - taken from the –> <!– repository wide setting - you are advised not to change –> <!– this setting. –> <!– This value should be ${user.name.caseSensitive} –> <property name="userNamesAreCaseSensitive"> <value>${user.name.caseSensitive}</value> </property> </bean>
<!– The ticket component. –> <!– Used for reauthentication –> <bean id="ticketComponent" class="org.alfresco.repo.security.authentication.InMemoryTicketComponentImpl"> <!– The period for which tickets are valid in XML duration format. –> <!– The default is P1H for one hour. –> <property name="validDuration"> <value>P1H</value> </property> <!– Do tickets expire or live for ever? –> <property name="ticketsExpire"> <value>false</value> </property> <!– Are tickets only valid for a single use? –> <property name="oneOff"> <value>false</value> </property> </bean> </beans>
I was unable to get this to work. What version of Alfresco are you running? As I have traced the process, it appears the when the LDAP sync runs, the xml import file is created. That import file, creates the users without using the Person class.
I am using 1.3. Please let me know if you were able to get this working on 1.3.
ok, I see what you are doing now… not syncing the users, just authenticating with LDAP… when the user logs in the first time and their profile is created, you create the home directory…
I would prefer to sync and have the directory created at that time, will see if I can get that to work.