
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2015 08:05 PM
I've been trying to make a widget that shows all users logged into lansweeper. Under Configuration > Website Access at the bottom there is a table that displays exactly what I want to be displayed in the widget however I haven't been successful porting it to a widget.
Any help would be appreciated.
Any help would be appreciated.
Solved! Go to Solution.
Labels:
- Labels:
-
General Discussion
1 ACCEPTED SOLUTION

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2015 02:13 PM
It should be as simple as pasting the code in the .cs and .aspx files together in one file. Below an example of just that. Some extra styling might be necessary. Keep in mind that users might be kept in the session up till 20 minutes after they log out.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="WidgetsCustom_test" %>
<%@ Import Namespace="LS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Dictionary<string, WebUser> sessions = new Dictionary<string, WebUser>();
lock (Application["lock_runningSessions"]) {
Dictionary<string, WebUser> dic = (Dictionary<string, WebUser>)Application["runningSessions"];
foreach (KeyValuePair<string, WebUser> pair in dic) {
sessions.Add(pair.Key, pair.Value);
}
}
%>
<div class="configbar">Current Logged on Users</div>
<table id="loggedonusers" cellspacing="0" cellpadding="0" class="configtable">
<thead>
<tr>
<th class="dummy"></th>
<th> </th>
<th>Displayname</th>
<th>IP Address</th>
<th>Web Roles</th>
</tr>
</thead>
<tbody>
<% foreach (KeyValuePair<string, WebUser> pair in sessions)
{
string windowsgroups = "Windows groups: \n";
foreach (string s in pair.Value.WindowsGroups)
{
windowsgroups += ("\t" + s + "\n");
}
%>
<tr title="<%:windowsgroups %>">
<td class="dummy"></td>
<td class="lock"><img src="../configuration/../images/user-white.png" width="16" height="16" /></td>
<td class="lock"><a href="<%=ResolveUrl("~/")%>User.aspx?username=<%= HttpUtility.UrlEncode(pair.Value.UserName) %>&userdomain=<%= HttpUtility.UrlEncode(pair.Value.UserDomain) %>" class="popup" rel="u||<%= HttpUtility.UrlEncode(pair.Value.UserDomain) %>||<%= HttpUtility.UrlEncode(pair.Value.UserName) %>" style="color: #0084B4;"><%: pair.Value.Displayname%></a></td>
<td class="lock"><%: pair.Value.IP %></td>
<td class="lock">
<% for (int teller = 0; teller < pair.Value.WebRoles.Count; teller++)
{
if (teller > 0) { %><%: ", " %><% } %>
<%: pair.Value.WebRoles[teller]%>
<% } %>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</form>
</body>
</html>
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2015 02:13 PM
It should be as simple as pasting the code in the .cs and .aspx files together in one file. Below an example of just that. Some extra styling might be necessary. Keep in mind that users might be kept in the session up till 20 minutes after they log out.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="WidgetsCustom_test" %>
<%@ Import Namespace="LS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Dictionary<string, WebUser> sessions = new Dictionary<string, WebUser>();
lock (Application["lock_runningSessions"]) {
Dictionary<string, WebUser> dic = (Dictionary<string, WebUser>)Application["runningSessions"];
foreach (KeyValuePair<string, WebUser> pair in dic) {
sessions.Add(pair.Key, pair.Value);
}
}
%>
<div class="configbar">Current Logged on Users</div>
<table id="loggedonusers" cellspacing="0" cellpadding="0" class="configtable">
<thead>
<tr>
<th class="dummy"></th>
<th> </th>
<th>Displayname</th>
<th>IP Address</th>
<th>Web Roles</th>
</tr>
</thead>
<tbody>
<% foreach (KeyValuePair<string, WebUser> pair in sessions)
{
string windowsgroups = "Windows groups: \n";
foreach (string s in pair.Value.WindowsGroups)
{
windowsgroups += ("\t" + s + "\n");
}
%>
<tr title="<%:windowsgroups %>">
<td class="dummy"></td>
<td class="lock"><img src="../configuration/../images/user-white.png" width="16" height="16" /></td>
<td class="lock"><a href="<%=ResolveUrl("~/")%>User.aspx?username=<%= HttpUtility.UrlEncode(pair.Value.UserName) %>&userdomain=<%= HttpUtility.UrlEncode(pair.Value.UserDomain) %>" class="popup" rel="u||<%= HttpUtility.UrlEncode(pair.Value.UserDomain) %>||<%= HttpUtility.UrlEncode(pair.Value.UserName) %>" style="color: #0084B4;"><%: pair.Value.Displayname%></a></td>
<td class="lock"><%: pair.Value.IP %></td>
<td class="lock">
<% for (int teller = 0; teller < pair.Value.WebRoles.Count; teller++)
{
if (teller > 0) { %><%: ", " %><% } %>
<%: pair.Value.WebRoles[teller]%>
<% } %>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</form>
</body>
</html>
