I configured the portal login using DatabaseServerLoginModule
And I want to get the user role at
jboss-portal.sar\portal-core.war\WEB-INF\jsp\loginindex.jsp
Below is the code adding to the index.jsp to retrieve the user role.
But i can't get the user role which only create in our custom database.
It only work on default portal user (user / admin)
How can i get the role name of the login user?
<%
try{
Context initContext = new InitialContext();
RoleModule role = (RoleModule)initContext.lookup("java:/portal/RoleModule");
UserModule user = (UserModule)initContext.lookup("java:/portal/UserModule");
String username = request.getRemoteUser();
if(username != null){
if(role != null){
%>
HAS ROLE <%= username %> ROLE COUNT = <%=role.getRolesCount() %>
<%
User u = null;
if(user != null){
//u = user.findUserByUserName(username);
}else{
%>
NO USER OBJECT
<%
u = new UserImpl(username);
}
if(u != null){
Set s = role.getRoles(u);
Iterator i = s.iterator();
while(i.hasNext()){
Role r = (Role)i.next();
%>
AA <%= r.getName() %>
<%
}
}
%>
HAS ROLE
<%
}else{
%>
NO ROLE
<%
}
}
}catch(Exception e){
e.printStackTrace();
%>
System Exception
<%
}
%>
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033001#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...