on 07-06-2010 7:55 AM
Hello All,
In web dynpro, I want to find out which UME group does the logged in user belong to ? Which API should I use ? Which method of the API to use to get the UME group of the logged in user ?
regards
Mrinalini
Hi,
Try the below code, it will list all the Groups which is assigned to a user.
You can implement your own logic and change it as required.
Please add com.sap.security.api.jar in your project build path.
IWDClientUser clientUser = WDClientUser.forceLoggedInClientUser();
IUser user = clientUser.getSAPUser();
Iterator groupIterato = user.getParentGroups(true);
IGroupFactory groupFactory = UMFactory.getGroupFactory();
IGroupSearchFilter groupFilter = groupFactory.getGroupSearchFilter();
groupFilter.setSearchAttribute(IPrincipal.DEFAULT_NAMESPACE,
IPrincipal.DESCRIPTION,"*",ISearchAttribute.LIKE_OPERATOR,false);
ISearchResult result = groupFactory.searchGroups(groupFilter);
while(result.hasNext()){
String groupName = (String)result.next();
IGroup group = groupFactory.getGroup(groupName);
wdComponentAPI.getMessageManager().reportSuccess("groupName "+groupName);
wdComponentAPI.getMessageManager().reportSuccess("display name "+group.getDisplayName());
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mrinalini,
First you have to add the .jar file to Java Build Path com.sap.security.api
This File Path C:\Program Files\SAP\IDE\IDE70\eclipse\plugins\com.sap.security_2.0.0\lib
try
{
IUser user = WDClientUser.getCurrentUser().getSAPUser();
boolean result = user.isMemberOfGroup("Unique ID of you are UserGroup", true) ;
if(user.isMemberOfGroup("GRUP.PRIVATE_DATASOURCE.un:TEST_USERGROUP", true))
{
if(result)
{
Here you will mention U r Condition
}
}
else
{
Here you will mention U r Condition
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
Hope this is Help full for you
Regards
Vijay Kalluri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use IGroupFactory interface to get the group by "getGroupByUniqueName()"
PFB the link for more info:
http://help.sap.com/javadocs/NW04S/SPS09/se/com/sap/security/api/IGroupFactory.html
Sample code:
IGroupFactory groupFact= UMFactory.getGroupFactory();
groupFact.getGroupByUniqueName("yourGroup").getUniqueId()
Regards,
Lavanya.G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mrinalini,
You can get the UME group of the logged in user using UME APIs. You can use UM factory and IGroupFactory.
Refer code below:
try {
IUser usr = WDClientUser.getCurrentUser().getSAPUser();
Iterator groups = usr.getParentGroups(true);
while (groups.hasNext()) {
String grpStr = (String) groups.next();
IGroup grp = UMFactory.getGroupFactory().getGroup(grpStr);
}
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Also refer http://help.sap.com/javadocs/NW04S/SPS09/se/com/sap/security/api/IUserFactory.html for more details
Regards
Abhinav Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.