cancel
Showing results for 
Search instead for 
Did you mean: 

how to change portal password through web dynpro application

Former Member
0 Kudos

Hi,

Can any one tell how to change portal password through web dynpro application.

Code to do that and procedure to do that.

Regards,

H.V.Swathi

Accepted Solutions (1)

Accepted Solutions (1)

siddharth_jain
Active Contributor
0 Kudos

Hi,

Getting the Existing portal user Password is not possible ,u can get the hashed encrypted Password value but not the actual stored password fro SAP UME DB.

there could be 2 options :1:-Find out the decryption Algo and decrypt the hashed value:good amount of reasearch required as well as time consuming ,Also not sure whether it will work at the end.

second option would be first store the user passowrd with user id in Dummy system User mapping.for all the users via administrator.

-retrieve this information Via UME Api

-Set the new password in UME Database via UME API

-Set the new password in UserMapping VIA UME API

-in case of exception revert the changes at both the places.

-good amount of syncronization required.

-only work in Portal ,Will not work if Portal is not installed(Standalone WD)

Siddharth

Former Member
0 Kudos

Hi,

I am new to WDJ can u just give the code to do it.

At present i am using this code.

and i am getting this error for the given code

com.sap.security.api.UMRuntimeException: Maint method setAttribute cannot be used because the principal is not mutable!

pass=wdContext.currentContextElement().getPassword();
	newpass=wdContext.currentContextElement().getNewPass();
	cnfpass=wdContext.currentContextElement().getConfPass();
    try{
	wdUser = WDClientUser.getCurrentUser();
	user = wdUser.getSAPUser();
	if (user != null)
	{
	IUserAccount[] acct = user.getUserAccounts();
	if(acct[0] != null)
	{
	b = acct[0].checkPassword(pass);
	wdComponentAPI.getMessageManager().reportSuccess("tset"+ b);
	
	if(b == true)
		{
			if(newpass.equals(cnfpass))
			{
				IUserAccount acc[] = user.getUserAccounts();
				wdComponentAPI.getMessageManager().reportSuccess("tsettttt");
			acc[0].setPassword(newpass);
			wdComponentAPI.getMessageManager().reportSuccess("tset"+ acct[0].getHashedPassword());
			}
			else
			{
				String errorMessage = " Incorrect password !";
											IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
											IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
											windowDialog.open();
											windowDialog.setWindowPosition(300,250);
			}
		}
		else
		{
			String errorMessage = " Old pass word is wrong !";
										IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
										IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
										windowDialog.open();
										windowDialog.setWindowPosition(300,250);
		}
	}
	}	
    }
    catch(Exception e)
    {
		wdComponentAPI.getMessageManager().reportException(
								e.toString(),
								true);	
    }

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jun 19, 2009 2:11 PM

Edited by: H.V Swathi on Jun 19, 2009 7:30 PM

Former Member
0 Kudos

Hi Shlipa,

Instead of the IUser (provides only read access) you will have to use IUserMaint interface.

For editing always use the getMutable<Name> methods.

Get the mutable IUserAccount by passing the unique id of the logged user.

Please try the following code where :


userAccount = UMFactory.getUserAccountFactory().getMutableUserAccount
(loggedUser.getUniqueID());
//change password from old to new
userAccount.setPassword (u201C<OldPassword>u201D,u201D<NewPassword>u201D);
// set the password change required attribute to false
userAccount.setPasswordChangeRequired(false);
userAccount.save();
userAccount.commit ();

Regards,

Kartikaye

Former Member
0 Kudos

Hi,

thanks for ur reply.

I ahve changed my code as given bellow. But still i am getting error.

pass=wdContext.currentContextElement().getPassword();
	newpass=wdContext.currentContextElement().getNewPass();
	cnfpass=wdContext.currentContextElement().getConfPass();
	IUserMaint mnt=null;
	IUserFactory userFactory = UMFactory.getUserFactory();
    try{
	wdUser = WDClientUser.getCurrentUser();
	user=wdUser.getSAPUser();
	mnt= userFactory.getMutableUser(user.getUniqueID());	
	if (user != null)
	{
	IUserAccount[] acct = user.getUserAccounts();
	if(acct[0] != null)
	{
	b = acct[0].checkPassword(pass);
	wdComponentAPI.getMessageManager().reportSuccess("tset"+ b);
	
	if(b == true)
		{
			if(newpass.equals(cnfpass))
			{
				IUserAccount userAccount = UMFactory.getUserAccountFactory().getMutableUserAccount(user.getUniqueID());
				wdComponentAPI.getMessageManager().reportSuccess("tsettttt"+userAccount);
			userAccount.setPassword(pass,newpass);
			userAccount.setPasswordChangeRequired(false);
			userAccount.save();
			userAccount.commit ();
			wdComponentAPI.getMessageManager().reportSuccess("tset"+ acct[0].getHashedPassword());
			}
			else
			{
				String errorMessage = " Incorrect password !";
											IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
											IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
											windowDialog.open();
											windowDialog.setWindowPosition(300,250);
			}
		}
		else
		{
			String errorMessage = " Old pass word is wrong !";
										IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
										IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
										windowDialog.open();
										windowDialog.setWindowPosition(300,250);
		}
	}
	}	
    }
    catch(Exception e)
    {
		wdComponentAPI.getMessageManager().reportException(
								e.toString(),
								true);	
    }

I am getting this error.

com.sap.security.api.NoSuchUserAccountException: The given id "USER.R3_DATASOURCE.000985"is not a unique id of a user account!

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jun 22, 2009 1:03 PM

Former Member
0 Kudos

what about:


IUserAccount account = currentUserSAP.getUserAccounts()[0];
IUserAccountFactory accountFactory = UMFactory.getUserAccountFactory();
IUserAccount mutableAccount = accountFactory.getMutableUserAccount(account.getUniqueID());
mutableAccount.setPassword(newPass);
mutableAccount.setPasswordChangeRequired(false);
mutableAccount.commit();

Edited by: Jean Carlo Abreu on Jun 22, 2009 1:34 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Swathi

Check it out.

try{

IWDClientUser User = WDClientUser.getCurrentUser();

IUser user = User.getSAPUser();

if(user != null) {

IUserAccount acct[] = user.getUserAccounts();

if(acct[0] != null) {

acct[0].setPassword("<New Password>");

}

}

}

catch(Exception e )

{

e.printStackTrace();

}

Thanks

Tulasi

Edited by: Tulasi Palnati on Jun 19, 2009 11:55 AM

Former Member
0 Kudos

Hi,

Thnaks for ur reply.

how to get the existing password and set the different one.

Regards,

H.V.Swathi

Former Member
0 Kudos

Hi Swathi

Check out this links swathi it will help

Thanks

Tulasi