cancel
Showing results for 
Search instead for 
Did you mean: 

creating a new user

Former Member
0 Kudos

hi,

iam writing a program to create a new user in the portal. ins there any method to capture the password as requested by the user and assign the same to him during his first logon into the portal? also is commit() and save() enough to create a new user or any other detail is to be followed?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

this is the code i have. the program never enters the onFormSubmit event. so iam unable to create a new user. can u please guide me? on the button i have defined onClick="onFormSubmit".

public void onFormSubmit(Event event) throws PageException{

System.out.println("still here");

InputField userID = (InputField) this.getComponentByName("UserID");

InputField defPwd = (InputField) this.getComponentByName("DfinePwd");

InputField cnfPwd = (InputField) this.getComponentByName("CnfrmPwd");

InputField lstName = (InputField) this.getComponentByName("LstName");

InputField frstName = (InputField) this.getComponentByName("FrstName");

InputField email = (InputField) this.getComponentByName("emailAdd");

InputField form_Address = (InputField) this.getComponentByName("FormofAdd");

InputField validFrom = (InputField) this.getComponentByName("dateFrom");

InputField validTo = (InputField) this.getComponentByName("dateTo");

InputField Tel = (InputField) this.getComponentByName("telephone");

InputField Faxnum = (InputField) this.getComponentByName("fax");

InputField Cellnum = (InputField) this.getComponentByName("mobile");

InputField strtName = (InputField) this.getComponentByName("street");

InputField City = (InputField) this.getComponentByName("city");

InputField province = (InputField) this.getComponentByName("state");

InputField postalCode = (InputField) this.getComponentByName("zip");

InputField postinOrg = (InputField) this.getComponentByName("position");

InputField dept = (InputField) this.getComponentByName("department");

DropdownListBox lang = (DropdownListBox) this.getComponentByName("language");

DropdownListBox StartDay = (DropdownListBox) this.getComponentByName("fromDay");

DropdownListBox StartMonth = (DropdownListBox) this.getComponentByName("fromMonth");

DropdownListBox StartYear = (DropdownListBox) this.getComponentByName("fromYear");

DropdownListBox EndDay = (DropdownListBox) this.getComponentByName("toDay");

DropdownListBox EndMonth = (DropdownListBox) this.getComponentByName("toMonth");

DropdownListBox EndYear = (DropdownListBox) this.getComponentByName("toYear");

DropdownListBox Country = (DropdownListBox) this.getComponentByName("country");

DropdownListBox timezone = (DropdownListBox) this.getComponentByName("timeZone");

String uid = "";

String definePwd="";

String cnfrmPwd="";

String lastName="";

String firstName="";

String emailAdd="";

String formofAddress="";

String telephone = "";

String faxNumber = "";

String mobileNumber = "";

String streetName = "";

String cityName = "";

String State = "";

String zipCode = "";

String Position = "";

String Department = "";

String UserLang = "";

String validFromDay = "";

String validFromMonth = "";

String validFromYear = "";

String validToDay = "";

String validToMonth = "";

String validToYear = "";

String UserCountry = "";

String time_Zone = "";

if(userID != null)

{

uid = userID.getValueAsDataType().toString();

}

System.out.println("userid is :"+uid);

if(defPwd != null)

{

definePwd = defPwd.getValueAsDataType().toString();

}

if(cnfPwd != null)

{

cnfrmPwd = cnfPwd.getValueAsDataType().toString();

}

if(lstName != null)

{

lastName = lstName.getValueAsDataType().toString();

}

if(frstName != null)

{

firstName = frstName.getValueAsDataType().toString();

}

if(email != null)

{

emailAdd = email.getValueAsDataType().toString();

}

if(form_Address != null)

{

formofAddress = form_Address.getValueAsDataType().toString();

}

if(Tel != null)

{

telephone = Tel.getValueAsDataType().toString();

}

if(Faxnum != null)

{

faxNumber = Faxnum.getValueAsDataType().toString();

}

if( Cellnum != null)

{

mobileNumber = Cellnum.getValueAsDataType().toString();

}

if( strtName != null)

{

streetName = strtName.getValueAsDataType().toString();

}

if( City != null)

{

cityName = City.getValueAsDataType().toString();

}

if( province != null)

{

State = province.getValueAsDataType().toString();

}

if( postalCode != null)

{

zipCode = postalCode.getValueAsDataType().toString();

}

if( postinOrg != null)

{

Position = postinOrg.getValueAsDataType().toString();

}

if( dept != null)

{

Department = dept.getValueAsDataType().toString();

}

if( lang != null)

{

UserLang = lang.getSelection().toString();

}

if( StartDay != null)

{

validFromDay = lang.getSelection().toString();

}

if( StartMonth != null)

{

validFromMonth = lang.getSelection().toString();

}

if( StartYear != null)

{

validFromYear = lang.getSelection().toString();

}

if( EndDay != null)

{

validToDay = lang.getSelection().toString();

}

if( EndMonth != null)

{

validToMonth = lang.getSelection().toString();

}

if( EndYear != null)

{

validToYear = lang.getSelection().toString();

}

if( Country != null)

{

UserCountry = lang.getSelection().toString();

}

if( timezone != null)

{

time_Zone = lang.getSelection().toString();

}

IUserMaint newUser=null;

try {

newUser = UMFactory.getUserFactory().newUser(uid);

newUser.setFirstName(firstName);

newUser.setLastName(lastName);

newUser.setEmail(emailAdd);

newUser.setSalutation(formofAddress);

newUser.setTelephone(telephone);

newUser.setFax(faxNumber);

newUser.setCellPhone("mobileNumber");

newUser.setStreet("streetname");

newUser.setCity("cityName");

newUser.setState("State");

newUser.setZip("zipcode");

newUser.setJobTitle("Position");

newUser.setDepartment("Department");

newUser.setCountry("UserCountry");

newUser.save();

newUser.commit();

try

{

IUserAccount uacc = UMFactory.getUserAccountFactory().newUserAccount(uid,newUser.getUniqueID());

uacc.setPassword("trialuser");

//uacc.setPasswordChangeRequired(false);

uacc.save();

uacc.commit();

}

catch(UMException ex)

{

ex.printStackTrace();

}

} catch (UMException e) {

try {

UMFactory.getUserFactory().deleteUser(newUser.getUniqueID());

} catch (UMException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

e.printStackTrace();

}

}

}

}

Former Member
0 Kudos

Hi Arun,

u getting some error?

Former Member
0 Kudos

hi,

Iam not getting any error at all. infact after i enter the details and click submit the page gets refreshed. also i have put certain values in quotes as newUser.setCellPhone("mobileNumber"); iam not yet picking this data and trying to create a user with the basic details. any pointers? its urgent too.

Former Member
0 Kudos

Hi Arun,

so it seems that you have a problem with the portal component itself, not with the UME coding. Am I right?

Jannis

Former Member
0 Kudos

Hi Arun,

There is a possiblity.

When you create a new user, you can set the password in the code itself.

<u>Example</u>:

<i><b>String uid = "saras";

IUserMaint newUser = UMFactory.getUserFactory().newUser(uid);

newUser.setFirstName("saras");

newUser.setLastName("saras");

newUser.setEmail("saras@kpitsap.com");

newUser.commit();

IUserAccount uacc =UMFactory.getUserAccountFactory().newUserAccount(uid,newUser.getUniqueID());

uacc.setPassword("saras");</b></i>

Using the above code am creating a new user named "saras".

-


Now if I add this below statement, this would allow the user an option to change the password the first time she/he logs into Portal.

<b>uacc.setPasswordChangeRequired(true);</b>

If set to true - option enabled

If set to false - option disabled.

Hope this helps solve your query.

All the best!

Warm Regards,

Ritu

Former Member
0 Kudos

Hello Arun,

In the situation that you describe, at the first login, the password of the user should be stored in it's password field. Only I guess that the user cannot login, because the userid need be assigned a password for a succesful login.

You're assuming that the user doesn't have a password when attempting to logon for the first time, so why not use a default password (or generate one) and set this as an administrator. Then, request the user to change it's password at first login (the possibility of an user changing it's password is an UME property which needs to be enabled for this).

Good luck.

Walter