cancel
Showing results for 
Search instead for 
Did you mean: 

Error creating user:

jtorres
Champ in-the-making
Champ in-the-making
Hi people, I'm trying to use webservice to create new user. I use the following code:



// To fill the person properties
    private NamedValue[] createPersonProperties(
            String homeFolder,
            String firstName,
            String lastName,
            String email,
            String orgId)
    {
        // Create the new user objects
        return new NamedValue[] {
                new NamedValue(Constants.PROP_USER_HOMEFOLDER, Boolean.FALSE, homeFolder, null),
                new NamedValue(Constants.PROP_USER_FIRSTNAME, Boolean.FALSE, firstName, null),
                new NamedValue(Constants.PROP_USER_LASTNAME, Boolean.FALSE, lastName, null),
                new NamedValue(Constants.PROP_USER_EMAIL, Boolean.FALSE, email, null),
                new NamedValue(Constants.PROP_USER_ORGID, Boolean.FALSE, orgId, null) };
    }

// The main function

      NamedValue[] properties = createPersonProperties(…data…);
      NewUserDetails[] newUser = new NewUserDetails[]{new NewUserDetails(user.getUserName(), password, properties)};
      try {
         administrationService.createUsers(newUser);
                        // and the upper line crash, it produces RemoteExceptio


What's wrong? I'm confused, thanks a lot.
3 REPLIES 3

sergio
Champ in-the-making
Champ in-the-making
Try this. It works for me.

/*
   * —————————————————————————————-
   *                                                       USER CREATION
   * —————————————————————————————-
   */
  public static boolean wsCreateUser(   String schema,
                                                        String address,
                                                        String userName,
                                                        String password,
                                                        String homeFolderId,
                                                        String firstName,
                                                        String lastName,
                                                        String email)
   {
     NewUserDetails[] newUsers = new NewUserDetails[1] ;
     NewUserDetails newUser = new NewUserDetails(userName,
                                                                       password,
                                                                       createPersonProperties(   homeFolderId,
                                                                                                           firstName,
                                                                                                           "middleName",
                                                                                                           lastName,
                                                                                                           email,
                                                                                                           "CINECA"));
     boolean userCreationSuccess = false;
     
     try
     {
        Store store = new Store (schema, address);
        Reference ref = new Reference();
         ref.setStore(store);
         ref.setUuid(homeFolderId);
         Predicate pred = new Predicate();
         pred.setStore(store);
         pred.setNodes(new Reference[]{ref});
         
         UserDetails[] userDetails = administrationService.createUsers(new NewUserDetails[]{newUser});
         if (userDetails.length > 0)
            userCreationSuccess = true;
     }
     catch (AdministrationFault e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
     catch (RemoteException e)
     {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
     
     return (userCreationSuccess);
   }

Hope this helps you.

All the best,

Sergio

jtorres
Champ in-the-making
Champ in-the-making
Thanks Segio, let's try this code  :wink:

alfredomuã_ozco
Champ in-the-making
Champ in-the-making
I have proven the code that you have provided, but the following error takes place:

{}faultData:<ns1:errorCode xmlns:ns1="http://www.alfresco.org/ws/service/action/1.0">0</ns1:errorCode><ns2:message xmlns:ns2="http://www.alfresco.org/ws/service/action/1.0">Invalid node ref - does not contain forward slash: e19b0319-d151-11db-ad5e-4d1453a05539</ns2:message>


The data that I provide to the method are the following ones:

adm.wsCreateUser  "workspace", "SpacesStore", "testuser", "testuser", "e19b0319-d151-11db-ad5e-4d1453a05539",   "testuser", "testuser", "alfmuco@gmail.com");

You could help me.
Greetings 
      Alfredo  :cry: