68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using ScheMe_Data;
|
|
|
|
namespace ScheMe.WebUserControls
|
|
{
|
|
public partial class mod_enrollByJumperAuthKey : System.Web.UI.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// procedo alla ricerca di dati via sessione x User AuthKey
|
|
tryAutoEnroll();
|
|
}
|
|
/// <summary>
|
|
/// prova a fare auto enroll
|
|
/// </summary>
|
|
public void tryAutoEnroll()
|
|
{
|
|
// recupero dati da session
|
|
string UserAuthKey = "";
|
|
string email = "";
|
|
string userAgent = "";
|
|
bool fatto = false;
|
|
string DeviceName = "";
|
|
string IPv4 = "";
|
|
try
|
|
{
|
|
//UserAuthKey = memLayer.ML.StringSessionObj("UserAuthkey");
|
|
//email = memLayer.ML.StringSessionObj("email");
|
|
UserAuthKey = Request["UserAuthkey"];
|
|
email = Request["USER_NAME"];
|
|
userAgent = Request.UserAgent;
|
|
}
|
|
catch
|
|
{ }
|
|
// se ci sono i dati effettua tentativo di AutoEnroll del device
|
|
if (email != "" && UserAuthKey != "")
|
|
{
|
|
IPv4 = Request.UserHostAddress;
|
|
DeviceName = SteamWare.dnsUtils.ReverseLookup(IPv4);
|
|
//DeviceName = SteamWare.dnsUtils.DetermineCompName(IPv4); // WIN2012R2SAM
|
|
//DeviceName = Request.UserHostName; // ::1
|
|
|
|
// prova ad usare la chiave DECODIFICATA x autorizzare device
|
|
fatto = devicesAuthProxy.stObj.enrollDevice(devicesAuthProxy.decodeKey(UserAuthKey), IPv4, DeviceName, userAgent, email);
|
|
// se NON ce l'ha fatta ed è abilitata l'autenticazione "plain" cerca di eseguire anche quella...
|
|
if (memLayer.ML.confReadBool("enablePlain") && !fatto)
|
|
{
|
|
fatto = devicesAuthProxy.stObj.enrollDevice(UserAuthKey, IPv4, DeviceName, userAgent, email);
|
|
}
|
|
if (fatto)
|
|
{
|
|
Response.Redirect("Default");
|
|
}
|
|
else
|
|
{
|
|
Response.Redirect("UserAdmin");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} |