Skip to Content

Hello,

After many tries to get the list of logged in users in portal, I found a simple solution. Maybe this solution is not the better but it worked fine for me.

I’m was looking for a solution like Session Management functionality of SAP NW.

Attention:

I used an internal SAP API without any documentation and support. So, if SAP change the code of API, the functionality may not work properly.

Let’s go to the solution:

1 – I picked the JAR application “sap.com~tc~lm~itsam~ui~session~mngt~wd.jar” in folder “/usr/sap/<SID>/J<NN>/j2ee/cluster/bin/ext/tc~jmx/lib/private/”

2 – In NWDS I created a new Portal Application and a new Portal Application Object:

    a) Portal Application:

          /wp-content/uploads/2014/02/1_386432.jpg

          /wp-content/uploads/2014/02/2_386433.jpg

    b) Portal Application

          /wp-content/uploads/2014/02/3_386434.jpg

          /wp-content/uploads/2014/02/4_386435.jpg

          /wp-content/uploads/2014/02/5_386436.jpg

          /wp-content/uploads/2014/02/6_386437.jpg

          /wp-content/uploads/2014/02/7_386441.jpg

3 – Put the JAR into the lib folder:

    /wp-content/uploads/2014/02/8_386442.jpg

4 – Adjust the Build Path:

    /wp-content/uploads/2014/02/10_386443.jpg

    /wp-content/uploads/2014/02/12_386448.jpg

    Another necessary JARs:

    /wp-content/uploads/2014/02/13_386449.jpg

    sap.com~tc~bl~pj_jmx~Impl.jar(/usr/sap/<SID>/J<NN>/j2ee/cluster/bin/ext/tc~jmx/lib/private)

    /wp-content/uploads/2014/02/14_386453.jpg

5 – Put the below code in JSP created file(LoggedInUserInformation.jsp):

                    <%@page import=”com.sap.jmx.ObjectNameFactory”%>

<%@page import=”com.sap.jmx.remote.JmxConnectionFactory”%>
<%@page import=”com.sap.tc.logging.Location”%>
<%@page import=”java.util.*”%>
<%@page import=”javax.management.*”%>
<%@page import=”javax.management.openmbean.CompositeData”%>
<%@page import=”javax.naming.InitialContext”%>

<%@page import=”javax.management.openmbean.CompositeData”%>
<%@page import=”javax.management.MBeanServer”%>
<%@page import=”javax.naming.InitialContext”%>
<%@page import=”java.util.Set”%>

<%@page import=”com.sap.tc.lm.ui.itsam.session.mnt.SessionManagementModel”%><br>

<table border=”1″>
<tr>
  <td>UserName</td>
  <td>IP</td>
</tr>
<%

SessionManagementModel model = new SessionManagementModel();
CompositeData data[] = model.getSessions();

for(int i=0;i<data.length;i++){
 
%>
 
<tr>
  <td><%=data[i].get(“UserName”).toString().toLowerCase()%></td>

<%
  if(data[i].get(“RootContextID”) != null){
  String rootContextID = data[i].get(“RootContextID”).toString();
  CompositeData details[] = model.GetSessionsForAggSession(rootContextID);
  for(int j=0;j<details.length;j++){
  %>
  <td><%=details[j].get(“IP”) %></td>
  <% }
  }
%>
<%
}
%>
</table>

6 – Create EAR file:

    /wp-content/uploads/2014/02/15_386454.jpg

    ScreenShot001.jpg

    ScreenShot002.jpg

    ScreenShot003.jpg

7 – Deploy EAR in Portal

    ScreenShot004.jpg

    ScreenShot005.jpg

    ScreenShot006.jpg

    ScreenShot007.jpg

8 – Test Application:

    Log in Portal > Content Administration

    ScreenShot008.jpg

    ScreenShot009.jpg

    Result:

    ScreenShot010.jpg

All information are available like in Session Management. For use then, the CompositeData parameters must be knowed. For this, is possible to use toString to show all parameters.

Example:

<%

CompositeData data[] = model.getSessions();

for(int i=0;i<data.length;i++){ %>

     <%= data[i].toString()%><br>

<% } %>

The parameters will be displayed like this:

javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=Aggregated session data,items=((itemName=ActiveRequests,itemType=javax.management.openmbean.SimpleType(name=java.lang.Integer)),(itemName=ClusterNodeId,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=Cpu,itemType=javax.management.openmbean.SimpleType(name=java.lang.Integer)),(itemName=IncommingTime,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=ProfileZipDataName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=ProfileZipDataPath,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=Requests,itemType=javax.management.openmbean.SimpleType(name=java.lang.Integer)),(itemName=ResponceTime,itemType=javax.management.openmbean.SimpleType(name=java.lang.Integer)),(itemName=RootContextID,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=UserName,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=allocMemory,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=dbTime,itemType=javax.management.openmbean.SimpleType(name=java.lang.Integer)),(itemName=lastAccessed,itemType=javax.management.openmbean.SimpleType(name=java.util.Date)))),contents={ActiveRequests=0, ClusterNodeId=null, Cpu=0, IncommingTime=0, ProfileZipDataName=null, ProfileZipDataPath=null, Requests=0, ResponceTime=0, RootContextID=null, UserName=Administrator, allocMemory=0, dbTime=0, lastAccessed=Wed Feb 12 15:37:44 BRST 2014})

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Samuli Kaski

    Although I appreciate your effort, I want to raise two concerns. You know that you are using an internal API, that is not released for customer use? The only released APIs are documented in Javadocs. Another concern I have is that the solution lists only the sessions of the AS JAVA instance on which the component runs. If there are several instances, those sessions won’t be listed.

    (0) 

Leave a Reply