Use radar instead of RadiusClient

This commit is contained in:
Jakob A. Dam 2015-04-15 13:57:04 +02:00
parent b90799184b
commit 01c78645ad
6 changed files with 24 additions and 50 deletions

View file

@ -6,7 +6,7 @@
<% @Import Namespace="System.Security" %> <% @Import Namespace="System.Security" %>
<% @Import Namespace="Microsoft.TerminalServices.Publishing.Portal.FormAuthentication" %> <% @Import Namespace="Microsoft.TerminalServices.Publishing.Portal.FormAuthentication" %>
<% @Import Namespace="Microsoft.TerminalServices.Publishing.Portal" %> <% @Import Namespace="Microsoft.TerminalServices.Publishing.Portal" %>
<% @Import Namespace="RadiusClient" %>
<script language="C#" runat=server> <script language="C#" runat=server>
// //

View file

@ -3,31 +3,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!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"> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <head runat="server">
<title></title> <title></title>
<script type="text/javascript"> <script type="text/javascript">
function doSomething() { function doSomething() {
} }
</script> </script>
</head> </head>
<body> <body>
<form id="form1" runat="server"> <form id="form1" runat="server">
<div> <div>
<asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label> <asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label>
</div> </div>
</form> </form>
</body> </body>
</html> </html>

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using RadiusClient; using RADAR;
using System.Configuration; using System.Configuration;
@ -13,39 +13,25 @@ public partial class Pages_en_US_token : System.Web.UI.Page
{ {
string tmpUser = Request.QueryString["User"]; string tmpUser = Request.QueryString["User"];
string DomainUserName = tmpUser.Replace("UserName:s:", ""); string DomainUserName = tmpUser.Replace("UserName:s:", "");
// Label1.Text = DomainUserName; HttpCookie sessionId = new HttpCookie("RadiusSessionId");
HttpCookie myCookie = new HttpCookie("RadiusSessionId"); sessionId = Request.Cookies["RadiusSessionId"];
myCookie = Request.Cookies["RadiusSessionId"];
// Read the cookie information and display it. // Read the cookie information and display it.
if (myCookie != null) if (sessionId != null)
{ {
string RadiusServer = ConfigurationManager.AppSettings["RadiusServer"]; string RadiusServer = ConfigurationManager.AppSettings["RadiusServer"];
string RadiusSecret = ConfigurationManager.AppSettings["RadiusSecret"]; string RadiusSecret = ConfigurationManager.AppSettings["RadiusSecret"];
Radius_Client myRadius = new Radius_Client(RadiusServer, 1812);
RADIUSPacket rp = default(RADIUSPacket); RADIUSClient client = new RADIUSClient(RadiusServer, 1812, RadiusSecret);
VendorSpecificAttribute vsa = new VendorSpecificAttribute(VendorSpecificType.Generic, "LAUNCH"); VendorSpecificAttribute vsa = new VendorSpecificAttribute(VendorSpecificType.Generic, "LAUNCH");
RADIUSAttributes atts = new RADIUSAttributes(); RADIUSAttributes atts = new RADIUSAttributes();
// Dim ost As New RADIUSAttribute(RadiusAttributeType.VendorSpecific, att.VendorName & att.VendorType & att.VendorValue)
vsa.SetRADIUSAttribute(ref atts); vsa.SetRADIUSAttribute(ref atts);
// RADIUSAttribute AppLaunch = new RADIUSAttribute(RadiusAttributeType.VendorSpecific, "LAUNCH");
//RADIUSAttribute AppLaunch = new RADIUSAttribute(RadiusAttributeType.VendorSpecific, att.VendorName + att.VendorType + att.VendorValue);
// atts.Add(AppLaunch);
// myRadius.Debug = true;
try try
{ {
rp = myRadius.Authenticate(RadiusSecret, DomainUserName, myCookie.Value, atts); RADIUSPacket response = client.Authenticate(DomainUserName, sessionId.Value, atts);
if (response.Code == RadiusPacketCode.AccessAccept)
if ((int)rp.Code == 2)
{ {
Response.Write("Ready to launch application. Granted access!"); Response.Write("Ready to launch application. Granted access!");
} }
@ -53,14 +39,11 @@ public partial class Pages_en_US_token : System.Web.UI.Page
{ {
Response.Write("Failure to authenticate session launch"); Response.Write("Failure to authenticate session launch");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Response.Write("Exception!! failure. " + ex.Message); Response.Write("Exception!! failure. " + ex.Message);
} }
// Response.Write("<p>" + myCookie.Name + "<p>" + myCookie.Value);
} }
else else
{ {