Background
[wp_ad_camp_1]
This article demonstrates how to programmatically change user passwords in SAP NetWeaver Portal using available API. For applications with very high number of users, they may be better off keeping some references to portal users in their databases. For instance, an application can cache user ids in its database when new users are created. In that that way, it has readily available list of users at its disposal. Certain non-critical queries can be delegated to the RDBMS to reduce hits to the portal.
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_5]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // Get new user id from context String newUserId = wdContext.currentContextElement().getUserId(); IUserMaint newUser = UMFactory.getUserFactory().newUser(newUserId); // Set user details newUser.setLastName(wdContext.currentContextElement().getLname()); newUser.setFirstName(wdContext.currentContextElement().getFname()); // e.g., Australia newUser.setCountry(wdContext.currentContextElement().getCountryName()); Locale userLocale = new Locale(wdContext.currentContextElement().getLanguage()); newUser.setLocale(userLocale); newUser.save(); newUser.commit(); // Update the user account's with initial password IUserAccount userAccount = UMFactory.getUserAccountFactory().newUserAccount(newUserId,newUser.getUid()); userAccount.setPassword(wdContext.currentContextElement().getPassword()); userAccount.save(); userAccount.commit(); // These codes throw several exceptions // Place them within a try-catch block |
[wp_ad_camp_3]