I want to create 5-6 SalesForce users programmatically using the SOAP API. I use the Partner API and I have a sandbox for developers. I am extracting user information from a database table and then using the API, I want to create these 5-6 users at a time. I can create one user, however, after creating another user, he throws the LICENSE_LIMIT_EXCEEDED:License Limit Exceeded error.
This is a snapshot of my code that retrieves user information from a database and then creates the user programmatically:
SObject user = new SObject(); user.setType("User"); while (rs.next()) { user.setField("Alias", rs.getString("Alias")); user.setField("Email", rs.getString("Email")); user.setField("EmailEncodingKey", rs.getString("EmailEncodingKey")); user.setField("LanguageLocaleKey", "En_US"); user.setField("LastName", rs.getString("LastName")); user.setField("LocaleSidKey", rs.getString("LocaleSidKey")); user.setField("TimeZoneSidKey", "America/Los_Angeles"); user.setField("Username", rs.getString("Username")); user.setField("UserPermissionsCallCenterAutoLogin", "false"); user.setField("UserPermissionsMarketingUser", "false"); user.setField("UserPermissionsOfflineUser", "false"); user.setField("ProfileId", connection.getUserInfo().getProfileId()); SaveResult[] results = connection.create(new SObject[] { user }); System.out.println("Created user: " + results[0].getId()); if (results[0].isSuccess()) out.println("Created user: " + results[0].getId()); else out.println("Error: " + results[0].getErrors()[0].getStatusCode() + ":" + results[0].getErrors()[0].getMessage()); } QueryResult queryResults = connection .query("SELECT Id, Name from User " + "ORDER BY CreatedDate DESC LIMIT 5"); if (queryResults.getSize() > 0) { for (SObject s : queryResults.getRecords()) { out.println("Id: " + s.getField("Id") + " - Name: " + s.getField("Name")); } }
Here I can create one user, however, after creating one user, he gives the error LICENSE_LIMIT_EXCEEDED:License Limit Exceeded .
This is the number of licenses available: 
I see that the licenses remaining for SalesForce are 0. However, I just want to create some users who do not have to be SalesForce users. This can be any type of user who just needs to log into my organization. When I try to create several different users, such as "Chatter Free", which has 5000 licenses using user.setField("UserType", "CsnOnly") , it gives the error INVALID_FIELD_FOR_INSERT_UPDATE:Unable to create/update fields: UserType
These are the users in my SalesForce: 
How to solve this problem? I just want to create some users from the database, which can then log into SalesForce. They are not required to be administrators. They may have minimal privileges, but they must be able to log into SalesForce.