Skip to Content

User, Groups and Roles Requirement

Hello Friends,

I need help from you. I have one requirement in Webdynpro JAVA

You should loop all users, group and roles in ePort and gather the following information

Roles: name of the role // which groups the role has // which users the role has

Groups: name of the group // which users the group has // which roles the group has

Users: name of the user // which groups the user has // which roles the user is has

By using the code. i will find all Uers,Groups and Roles from the Portal

how to check

weather the User and Group Belongs to Role?

weather the Group and Role Belongs to User?

weather the User and Role Belongs to Group?

String schCriteriaText ="*";

if (schCriteriaText == null || schCriteriaText.trim().length() == 0) {

schCriteriaText = "*";

}


try

{

IGroupFactory groupFact = UMFactory.getGroupFactory();

IGroupSearchFilter groupFilt = groupFact.getGroupSearchFilter();

groupFilt.setUniqueName(schCriteriaText.trim(), ISearchAttribute.LIKE_OPERATOR, false);

ISearchResult result = groupFact.searchGroups(groupFilt);

if (result.size() != 0)

{

if(result.getState() == ISearchResult.SEARCH_RESULT_OK)

{

while(result.hasNext())

{

String groupUniqId = (String)result.next();

IGroup thisGroup = groupFact.getGroup(groupUniqId);

IPrivateCO_GenerateUGRFile.IGroupTableElement grpTable = wdContext.createGroupTableElement();

//grpTable.setGroupNames(groupUniqId);

grpTable.setDisplayName(thisGroup.getDisplayName());

grpTable.setUniqueID(thisGroup.getUniqueID());

wdContext.nodeGroupTable().addElement(grpTable);


}

}

}else

{

msgMgr.reportWarning("No element found.");

}


IRoleFactory rFactory = UMFactory.getRoleFactory();

IRoleSearchFilter roleSrcFilter = rFactory.getRoleSearchFilter();

roleSrcFilter.setUniqueName(schCriteriaText.trim(),ISearchAttribute.LIKE_OPERATOR,false);

ISearchResult srhResults = rFactory.searchRoles(roleSrcFilter);

if (srhResults.size() != 0){

if(srhResults.getState() == ISearchResult.SEARCH_RESULT_OK) {

while(srhResults.hasNext()) {

String rUniqId = (String)srhResults.next();

IRole thisRole = rFactory.getRole(rUniqId);

IPrivateCO_GenerateUGRFile.IRoleTableElement rTable = wdContext.createRoleTableElement();

rTable.setRoles(thisRole.getDisplayName());

wdContext.nodeRoleTable().addElement(rTable);

}

}

} else {

wdComponentAPI.getMessageManager().reportWarning("No element found.");

}


IUserFactory uFactory = UMFactory.getUserFactory();

IUserSearchFilter usrSrchFilter = uFactory.getUserSearchFilter();

usrSrchFilter.setUniqueName(schCriteriaText.trim(),ISearchAttribute.LIKE_OPERATOR,false);

ISearchResult srchresults = uFactory.searchUsers(usrSrchFilter);

//wdComponentAPI.getMessageManager().reportWarning("srchresults:" +srchresults.size());

if (srchresults.size() != 0){

if(srchresults.getState() == ISearchResult.SEARCH_RESULT_OK) {

while (srchresults.hasNext()){

String userID = (String) srchresults.next();

com.sap.security.api.IUser sapUser = uFactory.getUser(userID);

IPrivateCO_GenerateUGRFile.IUserTableElement usrTable = wdContext.createUserTableElement();

usrTable.setLogonId(sapUser.getUserAccounts()[0].getLogonUid());

//usrTable.setUserNames(sapUser.getLastName()+','+" "+sapUser.getFirstName());

wdContext.nodeUserTable().addElement(usrTable);

}

}

} else {

wdComponentAPI.getMessageManager().reportWarning("No element found.");

}

wdComponentAPI.getMessageManager().reportSuccess("---Group Node Size----:"+wdContext.nodeGroupTable().size());

wdComponentAPI.getMessageManager().reportSuccess("---Role Node Size----:"+wdContext.nodeRoleTable().size());

wdComponentAPI.getMessageManager().reportSuccess("---User Node Size----:"+wdContext.nodeUserTable().size());

}catch(Exception ex){


}

Regards

Vijay Kalluri

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 16, 2014 at 09:47 AM

    Closed this thread

    this is code i developed...

    Roles, Groups and User information from the Enterprise portal 7.0 using Webdynpro JAVA

    Regards

    Vijay Kalluri

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 25, 2014 at 12:19 PM

    Hi Vijay!

    Maybe this blog How to get Current logged in user and the roles assigned to the user. will provide you with some idea of how to do this...

    Regards

    Michael

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.