on 01-06-2009 8:56 AM
Hi
Iam creating portal users in the web dynpro. Iam getting error in the code
*Error : The method setPassword(String) is undefined for the type IUserMaint *
Will anyone help me to sort this issue.
Please reply the necessary code.
public void onActionCreateUser(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionCreateUser(ServerEvent)
String user = wdContext.currentUserDataElement().getUser();
String password = wdContext.currentUserDataElement().getPassword();
String lastName = wdContext.currentUserDataElement().getLastName();
String firstName = wdContext.currentUserDataElement().getFirstName();
String email = wdContext.currentUserDataElement().getEmail();
IUserFactory userFact = UMFactory.getUserFactory();
try
{
IUserMaint userMaint = userFact.newUser(user);
{code}userMaint.setPassword(password);
userMaint.setLastName(lastName);
userMaint.setFirstName(firstName);
userMaint.setEmail(email);
userMaint.commit();
wdComponentAPI.getMessageManager().reportSuccess("User Created "+user);
}
catch (UMException e)
{
wdComponentAPI.getMessageManager().reportException(e.getMessage(),false);
e.printStackTrace();
}
//@@end
}
Regards
Sushma
Hi,
You need to use IUserAccount Interface
IUserAccount: This interface is used to get and set user account data for instances passwords, roles and group membership.
Just try this code
public void onActionCreateUser(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionCreateUser(ServerEvent)
String user = wdContext.currentUserDataElement().getUser();
String password = wdContext.currentUserDataElement().getPassword();
String lastName = wdContext.currentUserDataElement().getLastName();
String firstName = wdContext.currentUserDataElement().getFirstName();
String email = wdContext.currentUserDataElement().getEmail();
IUserAccount userAcc = null;
IUserFactory userFact = UMFactory.getUserFactory();
try
{
IUserMaint userMaint = userFact.newUser(user);
{code}userMaint.setPassword(password);
userMaint.setLastName(lastName);
userMaint.setFirstName(firstName);
userMaint.setEmail(email);
userMaint.commit();
try {
userAcc = UMFactory.getUserAccountFactory().newUserAccount( u201Cmiltongu201D,
epUser.getUniqueID());
userAcc.setPassword( u201Cmilton@123u201D );
userAcc.save();
userAcc.commit();
} catch (Exception e)
{
System.out.println(e.toString());
return;
}
wdComponentAPI.getMessageManager().reportSuccess("User Created "+user);
}
catch (UMException e)
{
wdComponentAPI.getMessageManager().reportException(e.getMessage(),false);
e.printStackTrace();
}
//@@end
}
Also go through the below link Programmatical Approach to User Management in Enterprise Portal
[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40d562b7-1405-2a10-dfa3-b03148a9bd19]
Revert me if you have any queries
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
tx
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
try this
IUserMaint user = UMFactory.getUserFactory().newUser("AAA");
user.setFirstName("BBB");
user.setLastName("CCC");
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushma,
use this code to set the password.
IUserAccountFactory mAccountFact = UMFactory.getUserAccountFactory();
IUserAccount userAccount =mAccountFact.getUserAccountByLogonId(login); // Provide login
IUserAccount muserAccount = mAccountFact.getMutableUserAccount(userAccount.getUniqueID());
muserAccount.setPassword(oldPassword.trim(), confirmPassword.trim());
muserAccount.save();
muserAccount.commit();
also refer to this link
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/createandeditEPuserwithJava+code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.