on 06-11-2008 5:09 PM
Hi Ppl,
Tech Details:
Portal Version: 2004s Sp12
NWDS Version: 7.0.10
-
Requirement:
I have a requirement where i need to write code to unlock users, application which will be used by the helpdesk team. I've designed the following way:
Layout: An input field for user ID and a button
Context: Attribute -> UserID type string for UserID bind to the input field
Code: In Action Method of button, wrote the following code:
import com.sap.security.api.IUserAccount;
import com.sap.security.api.IUserAccountFactory;
import com.sap.security.api.UMException;
import com.sap.security.api.UMFactory;
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
IUserAccountFactory accntFactory = UMFactory.getUserAccountFactory();
try {
IUserAccount accnt =
accntFactory.getUserAccount(wdContext.currentContextElement().getUserID());
IUserAccount mAccnt = accntFactory.getMutableUserAccount(accnt.getUniqueID());
if (mAccnt.isUserAccountLocked())
{
mAccnt.setLocked(false, IUserAccount.LOCKED_BY_ADMIN);
mAccnt.save();
mAccnt.commit();
msgMgr.reportSuccess("ID Unlocked Successfully");
}else{
msgMgr.reportException("ID not locked",false);
}
} catch (UMException e) {
msgMgr.reportException(e.getMessage(), false);
}
I've added the external jar file com.sap.security.api to use the methods IUserAccounts in my application.
Am using NWDI for code enhancements.
-
Issues Faced:
1. I tried to modify the standard User Admin Role(by coying to custom role) to achieve this functionality but wasn't able to do it. Please let me know if this can be achieved somehow. 2. Not sure if this code works. If somehow this functionality can be achieved through coding, or if any one has code to achieve same, help will be really appreciated.* 3. The main issue am facing now is: when i activate the code through NWDI, the build is failing due to compilation errors. When i see the build log it errors out saying due to the external jar added by me (com.sap.security.api) is not available. the build log error is provided below. Please help me in resolving this issue as am not sure how to remove this error.
[javac] ERROR: D:\temp\CBS\37\.B\11523\t\6AB875926D2D8AD61B447CC61551A7D7\gen_wdp\packages\com\test\first\FirstTestApplView.java:18: package com.sap.security.api does not exist
[javac] ERROR: import com.sap.security.api.IUserAccount;
-
Points will be rewarded.
Thanks,
Santosh Verma,
Deloitte.
3. The main issue am facing now is: when i activate the code through NWDI, the build is failing due to compilation errors. When i see the build log it errors out saying due to the external jar added by me (com.sap.security.api) is not available. the build log error is provided below. Please help me in resolving this issue as am not sure how to remove this error.
If your project is in NWDI, you have to add security lib in different way. In your DC, goto
DC MetaData -> Used DCs -> (rightClick)Add Used DC -> Select SAP-JEE -- com.sap.security.api.sda
Cheers,
~kranthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kranthi/Jhansi,
Thanks for your response, am able to resolve the issue. I've awarded the points.
-
Guys, here's the correct code for future reference.
Layout: An input field for user ID and a button
Context: Attribute -> UserID type string for UserID bind to the input field
Code: In Action Method of button, wrote the following code:
import com.sap.security.api.IUserAccount;
import com.sap.security.api.IUserAccountFactory;
import com.sap.security.api.UMException;
import com.sap.security.api.UMFactory;
public void onActionulock(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionulock(ServerEvent)
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
IUserAccountFactory accntFactory = UMFactory.getUserAccountFactory();
try {
IUserAccount accnt = accntFactory.getUserAccountByLogonId(wdContext.currentContextElement().getUserID());
IUserAccount mAccnt = accntFactory.getMutableUserAccount(accnt.getUniqueID());
if (mAccnt.isPasswordLocked())
{
mAccnt.setLocked(false, IUserAccount.LOCKED_BY_ADMIN);
mAccnt.save();
mAccnt.commit();
msgMgr.reportSuccess("ID Unlocked Successfully");
}else{
msgMgr.reportException("ID not locked",false);
}
} catch (UMException e) {
msgMgr.reportException(e.getMessage(), false);
}
//@@end
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Santosh,
Try adding the "com.sap.security.api.sda" as Used DC.ie.,
Expand DC MetaData -> DC Definition. Right click in Used DC and Add Used DC. Then you find a com.sap_SAP-JEE a package(Expand it) ->Now select com.sap.security.api.sda and press finish.
Thanks n Regards,
Jhansi Miryala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.