cancel
Showing results for 
Search instead for 
Did you mean: 

How to create users in alfresco...

k4sourabh
Champ in-the-making
Champ in-the-making
1. How to create user in alfresco using Alfresco Java Api or JCR.

2. How to create groups and assign user to a group using Alfresco Java Api or JCR.


PLease reply..

Thanks in advance.
22 REPLIES 22

ranvirkumar
Champ in-the-making
Champ in-the-making
Hi,Faisal would u help me because i am still not able to create user in alfresco..bec i am not geeting proper examples so please ,its my pleasure if u post example i.e program example to create user

madhu2710
Champ in-the-making
Champ in-the-making
Hi Sourabh,

Thanks for the clue.. I am able to create user by following  your instructions..

Can you give details how u have done this.Probably what is more important is the integration of the code. How to use the source code accordingly….
Please help..!

witho
Champ on-the-rise
Champ on-the-rise
Hi Faisal,

The true is that I'm using CAS authentication to log in Alfresco because I have Liferay and Alfresco integrated. Can you tell me if you get some error when you try to log in? That would help to solve your problem. How do you put your password in Java? By the way I leave my last code here:

   
   //get the user data
            
      String userName;
      userName = user.getScreenName();   
      String passwd = user.getPassword();
      String firstName = user.getFirstName();
      String lastName = user.getLastName();
      String email = user.getEmailAddress();      
                  
      Map<QName, Serializable> props = null;
      props = new HashMap<QName, Serializable>(5);
      // homeFolder value must be a nodeRef
      props.put(ContentModel.PROP_USERNAME, userName);
      props.put(ContentModel.PROP_FIRSTNAME, firstName);
      props.put(ContentModel.PROP_LASTNAME, lastName);
      props.put(ContentModel.PROP_PASSWORD, passwd);
      props.put(ContentModel.PROP_EMAIL, email);
      
      try{
         //WebApplicationContext configurationApplicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext());
         
         //Alfresco connection
         
         peopleService = (PeopleServiceImpl) configurationApplicationContext.getBean("peopleService");
         searchService = (SearchServiceImpl) configurationApplicationContext.getBean("searchService");
         nodeService = (NodeServiceImpl) configurationApplicationContext.getBean("nodeService");
         
                        configurationApplicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext());
              
                       authenticationService = (AuthenticationServiceImpl) configurationApplicationContext.getBean("authenticationService");                      
        
                       ticket = authenticationService.authenticate(repositoryUri, userid, password.toCharArray());
         
         //Create the user in Alfresco and add it to the convenient groups
         
         System.out.println("Creating the user called pruebaLray");
           NodeRef userRef = peopleService.createPerson(ticket, userName, passwd.toCharArray(), props);

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi Witho,

Regarding your question:

I want to set the folder "Company Home" as the user folder home, if anyone knows a better way to get the nodeRef of "Company Home" and how to set the property homeFolder as "Company Home" y will apreciate any help.

The code that you had gets the root of Spaces Store which is the parent of "Company Home" . To get the noderef of Company home you need to use lucene query and search service.
      

         List<QName> properties = new Vector<QName>();
         properties.add(ContentModel.PROP_NAME);

         String query = "PATH:\"/app:company_home\"";

         nodes = searchService.query(ticket, new StoreRef("workspace://SpacesStore"), SearchService.QueryLanguage.lucene, query,
                                 properties, false, false, false, false, null, 1, null);

         if (nodes != null) {
             for (Node node: nodes) {
                props.put(homeFolderQName, node.getNodeRef());
             }
          }

      

- Praveen C Elineni.

witho
Champ on-the-rise
Champ on-the-rise
Thanks a lot, finally I found the solution with lucene search and I got success.

faisal
Champ in-the-making
Champ in-the-making
Hi thanks a lot for u r reply… I have been able to solve my problem in a different way though… After creating the user What i am doing is

authenticationService.setAuthenticationEnabled("username", true);

That solves the problem.

maha
Champ in-the-making
Champ in-the-making
Hi

I have installed Alfresco enterprise edition 3. I can able to login as default user admin. can anyone please tell me how to create other users…

Thanks,

mikeh
Star Contributor
Star Contributor
The Admin console, one of the icons at the top of the page.

Mike

luminesens
Champ in-the-making
Champ in-the-making
I have trying to create that script using alfresco web service, but I have this error:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
        {http://www.alfresco.org/ws/service/authentication/1.0}AuthenticationFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>Read-Write transaction started within read-only transaction</ns1:message>
        {http://xml.apache.org/axis/}exceptionNameSmiley Surprisedrg.alfresco.repo.webservice.authentication.AuthenticationFa...
        {http://xml.apache.org/axis/}stackTrace:
        at org.alfresco.repo.webservice.authentication.AuthenticationWebService.endSession(AuthenticationWebService.java:135)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
        at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
        at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
        at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
        at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.alfresco.module.vti.VtiContextFilter.doFilter(VtiContextFilter.java:94)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Thread.java:595)

        {http://xml.apache.org/axis/}hostname:kms


        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at java.lang.Class.newInstance0(Class.java:350)
        at java.lang.Class.newInstance(Class.java:303)
        at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
        at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
        at org.alfresco.webservice.authentication.AuthenticationFault.getDeserializer(AuthenticationFault.java:146)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
        at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
        at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
        at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
        at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
        at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
        at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
        at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:2443)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.alfresco.webservice.authentication.AuthenticationServiceSoapBindingStub.endSession(AuthenticationServiceSoapBindingStub.java:229)
        at org.alfresco.webservice.util.AuthenticationUtils.endSession(AuthenticationUtils.java:109)
        at alfrescowebservice.AlfrescoCreateUser.addUsersToGroup(AlfrescoCreateUser.java:125)
        at alfrescowebservice.Main.main(Main.java:26)
Exception in thread "main" org.alfresco.webservice.util.WebServiceException: Error ending session.
        at org.alfresco.webservice.util.AuthenticationUtils.endSession(AuthenticationUtils.java:115)
        at alfrescowebservice.AlfrescoCreateUser.addUsersToGroup(AlfrescoCreateUser.java:125)
        at alfrescowebservice.Main.main(Main.java:26)
Caused by:
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at java.lang.Class.newInstance0(Class.java:350)
        at java.lang.Class.newInstance(Class.java:303)
        at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
        at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
        at org.alfresco.webservice.authentication.AuthenticationFault.getDeserializer(AuthenticationFault.java:146)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
        at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
        at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
        at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
        at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
        at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
        at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
        at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:2443)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.alfresco.webservice.authentication.AuthenticationServiceSoapBindingStub.endSession(AuthenticationServiceSoapBindingStub.java:229)
        at org.alfresco.webservice.util.AuthenticationUtils.endSession(AuthenticationUtils.java:109)
        … 2 more

Any idea what should I do?
I am running on Alfresco Labs 3b on Windows Server 2003 with Tomcat and MySql database.

Thanks,
Hakim

fracat71
Champ on-the-rise
Champ on-the-rise
Hi all,
i'm using alfresco 3.2 r2 and i want to upgrade to 3.3 but i have developed some classes.
One of them contains:
authenticationService.createAuthentication("testUser","testUser".toCharArray());
And now it doesn't compile.
Why? Is it my Eclipse problem?
I have tried to download the 3.3 SDK but i have problem, so i configured the WEB-INF/lib folder.

Regards