cancel
Showing results for 
Search instead for 
Did you mean: 

List of Portal users with the assigned Roles.....

Former Member
0 Kudos

Hello All,

I am working on EP6 SP9 and want to know from where can I get a list of all Portal users along with the assigned roles for each of them.

One way I found is by searching for all users in User Administration role and along with the searched users, there is also an icon for Assigned roles.

Apart from the above mentioned way, is there any other way by which I can get a direct list of the same. Is there a Java sample code for this.....?

Please help.

Awaiting Reply.

Thanks and Warm Regards,

Ritu R Hunjan

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Ritu,

Yes it is possible to get the roles of the users. You can try the following java code.

package com.hcl.user;

import java.util.Iterator;
import java.util.Vector;

import com.sap.security.api.IRole;
import com.sap.security.api.IRoleFactory;
import com.sap.security.api.IRoleSearchFilter;
import com.sap.security.api.ISearchResult;
import com.sap.security.api.IUser;
import com.sap.security.api.IUserAccount;
import com.sap.security.api.IUserFactory;
import com.sap.security.api.UMFactory;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;

public class role_member extends AbstractPortalComponent {
public void doContent(
IPortalComponentRequest request,
IPortalComponentResponse response) {

try {

IUserFactory userfactory = UMFactory.getUserFactory();

IRoleFactory rolefactory = UMFactory.getRoleFactory();
IRoleSearchFilter rolefltr = rolefactory.getRoleSearchFilter();
rolefltr.setMaxSearchResultSize(2000);
ISearchResult result = rolefactory.searchRoles(rolefltr);

while (result.hasNext()) {

response.write("<table border=0>n");

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

IRole role = rolefactory.getRole(uniqueid);

response.write("<tr><td bgcolor=Red>"+ role.getDisplayName()+ "</tr></td>n");

Iterator users = role.getUserMembers(true);

while (users.hasNext()) {
String unique_user = (String) users.next();
IUser user = userfactory.getUser(unique_user);
IUserAccount account[] = user.getUserAccounts();

response.write(
"<tr><td>" + account[0].getLogonUid() + "</tr></td>n");
}

response.write("</table>n");
response.write("</br>n");
}


} catch (Exception e) {
}

}
}

This code gives you the list of all the users of your portal along with the roles assigned to them.

Apart from this if you want you want to know all the roles assigned to the user on portal itself then the way you mentioned is the correct method.

Regards

Pravesh

PS: Please consider awarding points.

Former Member
0 Kudos

Hi Pravesh and Ranjith,

Firstly thank you for the entire code.

I have tried both the codes and each of them gives me an output as:

" <b>Name===rituh UserId===USER.PRIVATE_DATASOURCE.un:rituh Job Title=null List of roles... ROLE.PCD_ROLE_PERSISTENCE.La6WlL5paeF8nl7U2DZLWXvKans= ROLE.PCD_ROLE_PERSISTENCE.VvlvkEGjiW9zPFaxR/4pd2/bX5Q= ROLE.PCD_ROLE_PERSISTENCE.q3C4FsluddsTqyHfaLsF26DZBEg= ROLE.PCD_ROLE_PERSISTENCE.A1QvNFo40UQXOnwfid9lLII9yjM= ROLE.PCD_ROLE_PERSISTENCE.luXYnOuprtsl+QMfTCXgkmgom5o=</b> "

Is there a way I can de-crypt the data/roles-list in the above output?

I basically want to remove a list of all Portal users along with a list showing the roles assigned to them, the details of the roles (like PCD content..iViews, pages, worksets) and the ACL for them (iView, pages, worksets...)

Please help me solve this query.

Awaiting Reply.

Thanks and Warm Regards,

Ritu R Hunjan

Former Member
0 Kudos

Hi Ritu,

Hope you tried my code as it is. Because, when I try it on my server, it is giving me the roles in a proper readable format like super_admin_role,eu_role etc.

Just check and get back.

Ranjith

Former Member
0 Kudos

Hi Ranjith,

I tried the code again and it does me a list of usernames and roles.

But when i create an iview of this deployed .par file, it does not scroll.

Any reason why....?

I changed width & height of the iView to Full-Page but still the iView does not scroll.

Please help.

Awaiting Reply.

Thanks and Warm Regards,

Ritu R Hunjan

Former Member
0 Kudos

Hi Ritu,

I think you are previewing the iview from the iview editing screen. Go to Content Administration -> Portal Content -> Your Folder. You will see the list of your iviews. <b>Right Click on this user list iview and select preview. It will open up in a new browser window which will be scrollable.</b>

This should solve your problem. If you face problems again, get back.

Ranjith

Former Member
0 Kudos

Hi Ranjith,

Yahoo....yes it worked.

But can you explain the reason why does it act like this...?

Awaiting Reply.

Thanks and Warm Regards,

Ritu R Hunjan

Former Member
0 Kudos

Hi Ritu,

Sorry to say that I don't know the reason. I too had faced this issues earlier. That's why I was able to identify your problem easily.

Ranjith

Former Member
0 Kudos

Hi Ranjith,

Firstly thanks a lot for your help.

I have another query.

Wanted to know if its possible to integrate Portal with externally placed J2EE applications?

I have read the notes on help pages but am still confused as to how exactly its done.

Have also posted another query for the same.

Awaiting Reply.

Thanks and Warm Regards,

Ritu R Hunjan

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ritu,

The following piece of code may be of help to you.


ISearchResult rst=UMFactory.getUserFactory().getUniqueIDs();
IUser iuser=null;
while(rst.hasNext())
{
	iuser=UMFactory.getUserFactory().getUser(rst.next().toString());
	response.write("<b>"+iuser.getDisplayName()+"</b><br>");
	Iterator  itr=iuser.getRoles(true);
	while(itr.hasNext())
	{
		IRole ir=UMFactory.getRoleFactory().getRole(itr.next().toString());
		response.write("<br><b>Role:"+ir.getDisplayName()+"</b>");
	}
}

Hope this helps.

Ranjith