public UserVO createUser() throws SecurityException,
UserException
{
// create a new user data value object
UserVO user = new UserVO();
// set the name and login information for the user
user.setFirstName("Anthony");
user.setMiddleName("Joseph");
user.setLastName("Allman");
// note that user identifiers must be unique among
// all users
user.setLogin("tonyjoe");
// set the user's company and employee detail information
user.setBusinessTitle("Junior Executive");
user.setCompanyName("Systemz, Inc.");
user.setDepartment("Sales and Marketing");
user.setEmployeeNumber("10398");
// set the user's e-mail settings so that the user is
// notified of pending work via e-mail and that the user
// can change their own e-mail settings
user.setEmailNotifyInd(new Integer(1));
user.setEmailOverrideInd(new Integer(1));
// encrypt the password for the user
String password = "secret";
String encryptedPassword =
CryptoHelper.encryptString(password);
user.setPswd(encryptedPassword);
// add a contact phone number for the user
PhoneVO phone = new PhoneVO();
phone.setPhoneNumber("800.555.1212");
// set country code to US = 1
phone.setTerritoryId(new Integer(1));
user.addPhoneOfUser(phone);
// add an e-mail address for the user
EmailAddressVO email = new EmailAddressVO();
user.addEmailAddressOfUser(email);
// add the business address for the user
AddressVO address = new AddressVO();
address.setStreet1("1000 Corporate Way");
address.setStreet2("Suite 500");
address.setCity("Anytown");
address.setState("VA");
address.setCountry("US");
user.addAddressOfUser(address);
// call the API to create the user
UserVO createdUser = administrationFacade_.createUser
(this.getSessionProfile(), user, password);
// now update
return createdUser;
}
}