cancel
Showing results for 
Search instead for 
Did you mean: 

User, Groups and Roles Requirement

vijay_kumar49
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

vijay_kumar49
Active Contributor
0 Kudos

Closed this thread

this is code i developed...

Regards

Vijay Kalluri

Answers (1)

Answers (1)

michael_voss2
Participant
0 Kudos

Hi Vijay!

Maybe this blog will provide you with some idea of how to do this...

Regards

Michael