111 lines
4.5 KiB
C#
111 lines
4.5 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_login : BaseUserControl
|
|
{
|
|
#region eventi pubblici esposti
|
|
|
|
public event EventHandler Login_ok;
|
|
public event EventHandler Login_Error;
|
|
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
AdLogin();
|
|
}
|
|
}
|
|
|
|
private void AdLogin()
|
|
{
|
|
lblMessage.Text = "User not authenticated...";
|
|
if (Page.User.Identity.IsAuthenticated)
|
|
{
|
|
//recupera user windows se c'è...
|
|
string ad_name = Page.User.Identity.Name;
|
|
if (string.IsNullOrEmpty(ad_name))
|
|
{
|
|
lblMessage.Text = user_std.UtSn.Traduci("AccessFail") + user_std.UtSn.Traduci("EmptyAdName");
|
|
logger.lg.scriviLog(String.Format("Accesso fallito, ad_name vuoto"), SteamWare.tipoLog.ERROR);
|
|
if (Login_Error != null)
|
|
{
|
|
Login_Error(this, new EventArgs());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string delimStr = "\\";
|
|
char[] delimiter = delimStr.ToCharArray();
|
|
string[] dom_user = ad_name.Split(delimiter, 2);
|
|
|
|
// passo al controllo di verifica ADuserOk...
|
|
user_std _utente = new user_std();
|
|
bool adLoginOk = false;
|
|
try
|
|
{
|
|
adLoginOk = _utente.ADuserOk(dom_user[0], dom_user[1]);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Exception in ADuserOk, ad_name: {ad_name}{Environment.NewLine}{exc}");
|
|
Login_Error(this, new EventArgs());
|
|
}
|
|
if (adLoginOk)
|
|
{
|
|
bool fattoStartup = false;
|
|
try
|
|
{
|
|
fattoStartup = _utente.startUpUtente(dom_user[0], dom_user[1]);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Exception in startUpUtente{Environment.NewLine}{exc}");
|
|
Login_Error(this, new EventArgs());
|
|
}
|
|
if (fattoStartup)
|
|
{
|
|
logger.lg.scriviLog(string.Format("L'utente {0} ({1}) ha effettuato il login correttamente", _utente.CognomeNome, _utente.userNameAD), SteamWare.tipoLog.INFO);
|
|
if (Login_ok != null)
|
|
{
|
|
Login_ok(this, new EventArgs());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessage.Text = String.Format("{0}<br>There are some problems instatiating user: {1}/{2}", user_std.UtSn.Traduci("AccessFail"), dom_user[0], dom_user[1]);
|
|
logger.lg.scriviLog(String.Format("Accesso fallito, problemi ad istanziare l'utente {0}/{1}", dom_user[0], dom_user[1]), SteamWare.tipoLog.ERROR);
|
|
if (Login_Error != null)
|
|
{
|
|
Login_Error(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessage.Text = String.Format("{0}<br>user not allowed: {1}/{2}", user_std.UtSn.Traduci("AccessFail"), dom_user[0], dom_user[1]);
|
|
logger.lg.scriviLog(String.Format("Utente non autorizzato: {0}/{1}", dom_user[0], dom_user[1]), SteamWare.tipoLog.WARNING);
|
|
if (Login_Error != null)
|
|
{
|
|
Login_Error(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessage.Text = user_std.UtSn.Traduci("AccessFail") + user_std.UtSn.Traduci("UsrNotAuth");
|
|
logger.lg.scriviLog(String.Format("Accesso fallito, utente non autenticato"), SteamWare.tipoLog.WARNING);
|
|
if (Login_Error != null)
|
|
{
|
|
Login_Error(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |