private static final String NAME = "INSERT_NAME_HERE";
public static void runExample(DfpServices dfpServices, DfpSession session, String emailAddress,
String name) throws Exception {
// Get the UserService.
UserServiceInterface userService = dfpServices.get(session, UserServiceInterface.class);
// Create a user.
User traffickerUser = new User();
traffickerUser.setEmail(emailAddress);
traffickerUser.setName(name);
traffickerUser.setPreferredLocale("en_US");
// Set the system defined ID of the trafficker role.
// To determine what other roles exist, run GetAllRoles.java.
traffickerUser.setRoleId(-7L);
// Create the user on the server.
User[] users = userService.createUsers(new User[] {traffickerUser});
for (User createdUser : users) {
System.out.printf("A user with ID \"%d\" and name \"%s\" was created.\n",
createdUser.getId(), createdUser.getName());
}