Background
This article demonstrates how to programmatically change user passwords in SAP NetWeaver Portal using available API.
[wp_ad_camp_1]
Software Environment
- Windows 7 Professional SP1
- SAP NetWeaver Developer Studio Version 7.0.09 for Java
- SAP NetWeaver Application Server
- sap.com/SAP-JEECOR – 7.00 SP26 (1000.7.00.26.1.20120307143343)
- sap.com/SAP-JEE – 7.00 SP26 (1000.7.00.26.0.20120109175405)
The Codes
[wp_ad_camp_3]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // get user id from context String userId = wdContext.currentContextElement().getUserid(); // get new user password from context String newPassword = wdContext.currentContextElement().getPassword(); // get user account IUserAccount userAccount = UMFactory.getUserAccountFactory().getUserAccountByLogonId(userId); IUserAccount userAccountModifiable = UMFactory.getUserAccountFactory().getMutableUserAccount(userAccount.getUniqueID()); userAccountModifiable.setPassword(newPassword); userAccountModifiable.commit(); // these codes throw several exceptions // place them within try-catch block |