/// <summary> /// Creazione oggetto "UserLogin" a partire dai metadati dalla sessione utente corrente /// </summary> /// <param name="password">La password deve essere fornita dall'utente, in quanto non è mantenuta nella sessione</param> /// <returns></returns> public static DocsPaWR.UserLogin CreateUserLoginCurrentUser(string password, bool changePwd) { DocsPaWR.UserLogin userLogin = null; // Reperimento oggetto infoutente corrente DocsPaWR.InfoUtente infoUtente = UserManager.GetInfoUser(); if (infoUtente != null) { userLogin = new DocsPaWR.UserLogin(); userLogin.SystemID = infoUtente.idPeople; userLogin.UserName = infoUtente.userId; userLogin.Password = password; if (changePwd) { userLogin.IdAmministrazione = "0"; } else { userLogin.IdAmministrazione = infoUtente.idAmministrazione; } userLogin.DST = infoUtente.dst; userLogin.IPAddress = HttpContext.Current.Request.UserHostAddress; } return(userLogin); }
/// <summary> /// User Login /// </summary> /// <param name="page">Page</param> /// <param name="login">UserLogin</param> /// <param name="loginResult">LoginResult</param> /// <param name="ipaddress">string</param> /// <returns>Utente</returns> public static Utente Login(Page page, DocsPaWR.UserLogin login, out DocsPaWR.LoginResult loginResult, out string ipaddress) { Utente utente = null; loginResult = DocsPaWR.LoginResult.OK; ipaddress = string.Empty; try { loginResult = docsPaWS.Login(login, false, page.Session.SessionID, out utente, out ipaddress); } catch (Exception exception) { //logger.Debug("Login Error", exception); loginResult = DocsPaWR.LoginResult.APPLICATION_ERROR; utente = null; } //catch (System.Exception ex) //{ // UIManager.AdministrationManager.DiagnosticError(ex); // return null; //} return(utente); }
private bool ForcedLogin(DocsPaWR.UserLogin lgn) { bool result = false; DocsPaWR.LoginResult loginResult; DocsPaWR.Utente utente = UserManager.ForcedLogin(this, lgn, out loginResult); if (loginResult == DocsPaWR.LoginResult.OK) { //PROVA SIGALOT per selezionare l'utente del centro servizi /* * utente.extApplications = new DocsPaWR.ExtApplication[1]; * utente.extApplications[0] = new DocsPaWR.ExtApplication(); * utente.extApplications[0].codice = "CS"; */ if (utente != null) { //MODIFICATO PER GESTIONE APPLICAZIONE CENTRO SERVIZI utente.codWorkingApplication = "CS"; } result = true; // L'utente e' stato connesso // utente.urlWA = Utils.getHttpFullPath(this); Session["userData"] = utente; } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.Request.QueryString["userID"]) && !string.IsNullOrEmpty(this.Request.QueryString["password"]) ) { txt_userID.Value = this.Request.QueryString["userID"]; txt_password.Value = this.Request.QueryString["password"]; DocsPaWR.UserLogin userLogin = CreateUserLogin(); DocsPaWR.LoginResult loginResult; string ipAddress = string.Empty; DocsPaWR.Utente utente = UserManager.login(this, userLogin, out loginResult, out ipAddress); Session["userData"] = utente; if (loginResult == DocsPAWA.DocsPaWR.LoginResult.OK) { utente.urlWA = Utils.getHttpFullPath(this); LaunchApplication(); } else { this.Server.Transfer("login.aspx"); } } }
public static DocsPAWA.DocsPaWR.Utente EsercitaDelega(Page page, DocsPaWR.UserLogin userLogin, string id_delega, string id_ruoloDelegante, out DocsPaWR.LoginResult loginResult) { //verifica che l'utente delegante non sia connesso //chiamata al metodo che alla login riempe per la prima volta l'oggetto infoUtente; DocsPAWA.DocsPaWR.InfoUtente infoUtente = UserManager.getInfoUtente(page); DocsPAWA.DocsPaWR.Utente utente = null; utente = docsPaWS.DelegaEsercita(infoUtente, userLogin, page.Session.SessionID, id_delega, id_ruoloDelegante, out loginResult); return(utente); }
private DocsPaWR.UserLogin CreateUserLogin(string pwd, string userId) { DocsPaWR.UserLogin userLogin = new DocsPaWR.UserLogin(); userLogin.UserName = userId; if (!string.IsNullOrEmpty(this.Request.QueryString["token"])) { // // Modifica per PGU // Dal PGU il token viene passato a partire dal UserId_idAmm //Old CODE //userLogin.Password = this.GenerateAuthenticationToken(this.GetInputToken()); string usrID = GetInputToken(); if (usrID.Contains('_')) { usrID = usrID.Split('_')[0]; } userLogin.Password = this.GenerateAuthenticationToken(usrID); // End PGU // } else { userLogin.Password = pwd; } userLogin.IdAmministrazione = ""; userLogin.IPAddress = this.Request.UserHostAddress; // Abilitazione dell'utente al modulo centro servizi userLogin.Modulo = DocsPaUtils.Moduli.ListaModuli.CENTRO_SERVIZI; this.hd_pwd.Value = pwd; this.hd_userId.Value = userId; // // Popolo valori per multiAmm if (this.pnl_ddlAmm.Visible && this.ddl_Amministrazioni.Visible) { userLogin.IdAmministrazione = this.ddl_Amministrazioni.SelectedValue; if (this.hd_userId != null) { userLogin.UserName = this.hd_userId.Value; } if (this.hd_pwd != null) { userLogin.Password = this.hd_pwd.Value; } } // // End multiAmm return(userLogin); }
/// <summary> /// Change user password /// </summary> /// <param name="user">UserLogin</param> /// <param name="oldPassword">string</param> /// <returns>ValidationResultInfo</returns> public static DocsPaWR.ValidationResultInfo UserChangePassword(DocsPaWR.UserLogin user, string oldPassword) { try { return(docsPaWS.UserChangePassword(user, oldPassword)); } catch (System.Exception ex) { UIManager.AdministrationManager.DiagnosticError(ex); return(null); } }
private void createBrowserInfo(DocsPaWR.UserLogin userLogin) { DocsPaWR.BrowserInfo bra = new DocsPaWR.BrowserInfo(); bra.activex = Request.Browser.ActiveXControls.ToString(); bra.browserType = Request.Browser.Browser; bra.browserVersion = Request.Browser.Version; string clientIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (String.IsNullOrEmpty(clientIP)) { clientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } bra.ip = clientIP; bra.javaApplet = Request.Browser.JavaApplets.ToString(); bra.javascript = Request.Browser.JavaScript.ToString(); bra.userAgent = Request.UserAgent; userLogin.BrowserInfo = bra; }
public static DocsPaWR.Utente ForcedLogin(Page page, DocsPaWR.UserLogin login, out DocsPaWR.LoginResult loginResult) { DocsPaWR.Utente utente = null; loginResult = DocsPaWR.LoginResult.OK; string ipaddress; try { loginResult = wss.Login(login, true, page.Session.SessionID, out utente, out ipaddress); } catch (Exception ex) { loginResult = DocsPaWR.LoginResult.APPLICATION_ERROR; utente = null; Debugger.Write("Errore nella ForcedLogin: " + ex.Message); } return(utente); }
/// <summary> /// Login tramite servizi CAS /// </summary> protected bool LoginShibboleth() { string netId = string.Empty; netId = Request.Headers["idada"]; // modifica unitn - shibboleth string adaroles = string.Empty; adaroles = Request.Headers["adaroles"]; logger.DebugFormat("netID {0}, adaroles {1}", netId, adaroles); if (string.IsNullOrEmpty(netId) || (string.IsNullOrEmpty(adaroles) || !adaroles.ToUpper().Contains("ADAP3USER(6873)"))) { logger.Debug("Si e' verificato un problema nell'autenticazione con il Single Sign On. Chiudere il browser e riprovare. Se il problema persiste, contattatare l'amministratore."); this.lblCasAuthenticationMessage.Text = "Si e' verificato un problema nell'autenticazione con il Single Sign On. Chiudere il browser e riprovare. Se il problema persiste, contattatare l'amministratore."; return(false); } else { //DocsPAWA.Logger.log(string.Format("netId: {0}; sessionName: {1}", netId, sessionName)); // Generazione del token di autenticazione string token = DocsPaUtils.Security.SSOAuthTokenHelper.Generate(netId); DocsPaWR.UserLogin login = this.CreateUserLogin(netId, token, token); login.SSOLogin = true; // Login utente al sistema documentale if (!this.ForcedLogin(login)) { // Errore di autenticazione al sistema this.lblCasAuthenticationMessage.Text = "Errore nell'autenticazione al sistema documentale: utente non riconosciuto"; return(false); } return(true); } //DocsPAWA.Logger.log("END - LoginCAS"); }
//protected static DocsPaWR.DocsPaWebService wss = new DocsPaWR.DocsPaWebService(); public static DocsPaWR.Utente login(Page page, DocsPaWR.UserLogin login, out DocsPaWR.LoginResult loginResult, out string ipaddress) { DocsPaWR.Utente utente = null; loginResult = DocsPaWR.LoginResult.OK; ipaddress = ""; try { loginResult = wss.Login(login, false, page.Session.SessionID, out utente, out ipaddress); } catch (Exception e) { //string msg = "Login Error"; //DocsPaUtils.LogsManagement.Debugger.Write(msg, exception); loginResult = DocsPaWR.LoginResult.APPLICATION_ERROR; utente = null; Debugger.Write("Errore nel login result: " + e.Message); } return(utente); }
/// <summary> /// Forced User Login /// </summary> /// <param name="login">UserLogin</param> /// <param name="loginResult">LoginResult</param> /// <returns>Utente</returns> public static Utente ForcedLogin(Page page, DocsPaWR.UserLogin login, out DocsPaWR.LoginResult loginResult) { Utente user = null; loginResult = DocsPaWR.LoginResult.OK; string ipaddress; try { loginResult = docsPaWS.Login(login, true, page.Session.SessionID, out user, out ipaddress); } catch (Exception exception) { //logger.Debug("Login Error", exception); loginResult = DocsPaWR.LoginResult.APPLICATION_ERROR; user = null; } //catch (System.Exception ex) //{ // UIManager.AdministrationManager.DiagnosticError(ex); // return null; //} return(user); }
private void Page_Load(object sender, System.EventArgs e) { if (GetShibSSOEnabled()) { LoginShibboleth(); } else if (this.IsActiveCAS) { this.loginMultiView.ActiveViewIndex = 1; this.LoginCAS(); } else { //Interazione IAM-GFD string policyAgent = null; policyAgent = ConfigSettings.getKey(ConfigSettings.KeysENUM.POLICY_AGENT_ENABLED); //Autenticazione Windows bool windows_auth = Convert.ToBoolean(ConfigSettings.getKey(ConfigSettings.KeysENUM.AUTENTICAZIONE_WINDOWS)); if (windows_auth) { RegisterStartupScript("nascondiSitoAccessibile", "<script>nascondiSitoAccessibile();</script>"); } else if ((policyAgent != null && policyAgent.ToUpper() == Boolean.TrueString.ToUpper())) { RegisterStartupScript("nascondiSitoAccessibile", "<script>nascondiSitoAccessibile();</script>"); } //Fine Integrazione IAM-GFD if (Request.QueryString["ForceLogin"] != null && Request.QueryString["ForceLogin"].ToUpper() == Boolean.TrueString.ToUpper()) { // Gestione login forzato Page.RegisterStartupScript("NotifyUser", null); // Fa in modo che lo script non venga lanciato string administeredLogin = null; try { administeredLogin = ConfigSettings.getKey(ConfigSettings.KeysENUM.ADMINISTERED_LOGIN_MODE); } catch (Exception) { } if (administeredLogin == null || administeredLogin.ToUpper() == Boolean.FalseString.ToUpper()) { if (Session["loginData"] == null || !this.ForcedLogin((DocsPAWA.DocsPaWR.UserLogin)Session["loginData"])) { this.lbl_error.Text = "Errore durante la chiusura della connessione esistente."; } } } else { Session.RemoveAll(); } // Se la query string contiene groupId, docNumber o idProfile... if (!(String.IsNullOrEmpty(Request["groupId"]) || String.IsNullOrEmpty(Request["docNumber"]) || String.IsNullOrEmpty(Request["idProfile"]))) { // ...è stata richiesta la visualizzazione di un oggetto dall'esterno // quindi viene immesso in sessione la query string Session["visualizzaLink"] = Request.QueryString.ToString(); } // Se la query string contiene idAmministrazione, tipoOggetto, idObj o tipoProto... if (!(String.IsNullOrEmpty(Request["idAmministrazione"]) || String.IsNullOrEmpty(Request["tipoOggetto"]) || String.IsNullOrEmpty(Request["idObj"]))) { // ...è stata richiesta la visualizzazione di un oggetto dall'esterno // quindi viene immesso in sessione la query string Session["visualizzaOggetto"] = Request.QueryString.ToString(); } m_idAmministrazione = this.sel_amministrazioni.Value; getQueryStringParameter(); this.caricaLoghi(); this.LoadStaticRootPath(); this.caricaLogoAmministrazione(); //Inizio integrazione IAM-GFD if ((policyAgent != null && policyAgent.ToUpper() == Boolean.TrueString.ToUpper())) { #region iam RegisterStartupScript("nascondiSitoAccessibile", "<script>nascondiSitoAccessibile();</script>"); this.lblPassword.Visible = false; this.passwordConfirm.Visible = false; this.userid.Visible = false; this.Label2.Visible = false; this.lblPasswordConfirm.Visible = false; this.btn_login.Visible = false; this.password.Visible = false; if ((Request.QueryString["ForceLogin"] == null || !(Request.QueryString["ForceLogin"].ToUpper() == Boolean.TrueString.ToUpper()))) { vic.Integra VIC = new vic.Integra(Context, ""); this.userid.Text = VIC.amData.account.ToString(); if (this.ddl_Amministrazioni.SelectedItem != null) { m_idAmministrazione = this.ddl_Amministrazioni.SelectedItem.Value; } this.sel_amministrazioni.Value = m_idAmministrazione; string message = string.Empty; DocsPaWR.UserLogin userLogin = this.CreateUserLogin(); userLogin.Token = VIC.amData.account.ToString() + '&' + VIC.amData.codFiscale.ToString() + '&' + VIC.amData.matricola.ToString(); //DocsPaVO.utente. string appo = VIC.amData.account.ToString() + "&" + ConfigSettings.getKey(ConfigSettings.KeysENUM.CHIAVE_TOKEN).ToString() + '&' + VIC.amData.codFiscale.ToString() + '&' + VIC.amData.matricola.ToString(); byte[] bt_datiInput = ASCIIEncoding.ASCII.GetBytes(appo); userLogin.Token = userLogin.Token + '&' + DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(bt_datiInput); //userLogin.Token = "aaa"; if (String.IsNullOrEmpty(VIC.amData.account.ToString()) || String.IsNullOrEmpty(VIC.amData.codFiscale.ToString()) || String.IsNullOrEmpty(VIC.amData.matricola.ToString())) { this.lbl_error.Text = "L'utente non è autorizzato ad accedere all'applicazione"; this.lbl_error.Visible = true; this.pnl_error.Visible = true; this.logged = false; } else { if (!loginAction(userLogin, out message)) { this.lbl_error.Text = message; this.lbl_error.Visible = true; this.pnl_error.Visible = true; } else { this.logged = true; } } } #endregion iam } else if (windows_auth) { #region windows auth WindowsPrincipal windows_user = (HttpContext.Current.User as WindowsPrincipal); var dati_user = windows_user.Identity.Name.Split('\\'); var dominio = dati_user[0].ToString().ToUpper(); var userN = dati_user[1].ToString().ToUpper(); string tipo_auth = windows_user.Identity.AuthenticationType; RegisterStartupScript("nascondiSitoAccessibile", "<script>nascondiSitoAccessibile();</script>"); this.lblPassword.Visible = false; this.passwordConfirm.Visible = false; this.userid.Visible = false; this.Label2.Visible = false; this.lblPasswordConfirm.Visible = false; this.btn_login.Visible = false; this.password.Visible = false; if ((Request.QueryString["ForceLogin"] == null || !(Request.QueryString["ForceLogin"].ToUpper() == Boolean.TrueString.ToUpper()))) { this.userid.Text = userN; if (this.ddl_Amministrazioni.SelectedItem != null) { m_idAmministrazione = this.ddl_Amministrazioni.SelectedItem.Value; } this.sel_amministrazioni.Value = m_idAmministrazione; string message = string.Empty; DocsPaWR.UserLogin userLogin = this.CreateUserLogin(); userLogin.Token = userN + '&' + dominio + '&' + tipo_auth; //DocsPaVO.utente. string appo = userN + "&" + ConfigSettings.getKey(ConfigSettings.KeysENUM.CHIAVE_TOKEN).ToString() + '&' + dominio + '&' + tipo_auth; byte[] bt_datiInput = ASCIIEncoding.ASCII.GetBytes(appo); userLogin.Token = userLogin.Token + '&' + DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(bt_datiInput); //userLogin.Token = "aaa"; if (String.IsNullOrEmpty(userN) || String.IsNullOrEmpty(dominio) || String.IsNullOrEmpty(tipo_auth)) { this.lbl_error.Text = "L'utente non è autorizzato ad accedere all'applicazione"; this.lbl_error.Visible = true; this.pnl_error.Visible = true; this.logged = false; } else { if (!loginAction(userLogin, out message)) { this.lbl_error.Text = message; this.lbl_error.Visible = true; this.pnl_error.Visible = true; } else { this.logged = true; } } } #endregion windows auth } //Fine Integrazione IAM-GFD } }
/// <summary> /// Login tramite servizi CAS /// </summary> protected void LoginCAS() { //DocsPAWA.Logger.log("INIT - LoginCAS"); string CASHOST = this.GetCASServiceUrl(); string tkt = Request.QueryString["ticket"]; string service = Request.Url.GetLeftPart(UriPartial.Path); //DocsPAWA.Logger.log(string.Format("CASHOST: {0}; tkt: {1}; service: {2};", CASHOST, tkt, service)); if (tkt == null || tkt.Length == 0) { this.Session["SSO_ReturnURL"] = service; string redir = (CASHOST + "login?" + "service=") + service; //DocsPAWA.Logger.log(string.Format("RedirectTo: {0};", redir)); Response.Redirect(redir); return; } string returnUrl = Session["SSO_ReturnUrl"].ToString(); if (!string.IsNullOrEmpty(returnUrl)) { Session["SSO_ReturnUrl"] = ""; string redir = Request.Url.GetLeftPart(UriPartial.Query) + "&ReturnUrl=" + returnUrl; //DocsPAWA.Logger.log(string.Format("RedirectTo: {0};", redir)); Response.Redirect(redir); } string validateUrl = CASHOST + "serviceValidate?" + "ticket=" + tkt + "&" + "service=" + service; //DocsPAWA.Logger.log(string.Format("validateUrl: {0};", validateUrl)); StreamReader RespRead = new StreamReader(new WebClient().OpenRead(validateUrl)); string Resp = RespRead.ReadToEnd(); NameTable NT = new NameTable(); XmlNamespaceManager NSMgr = new XmlNamespaceManager(NT); XmlParserContext Context = new XmlParserContext(null, NSMgr, null, XmlSpace.None); XmlTextReader ReadXML = new XmlTextReader(Resp, XmlNodeType.Element, Context); string netId = null; string sessionName = null; while (ReadXML.Read()) { if (ReadXML.IsStartElement()) { string Tag = ReadXML.LocalName; if (Tag == "user") { netId = ReadXML.ReadString(); } if (Tag == "name") { sessionName = ReadXML.ReadString(); } if (Tag == "value") { this.Session["SSO_" + sessionName] = ReadXML.ReadString(); } } } ReadXML.Close(); if (string.IsNullOrEmpty(netId)) { this.lblCasAuthenticationMessage.Text = "Si e' verificato un problema nell'autenticazione con il Single Sign On. Chiudere il browser e riprovare. Se il problema persiste, contattatare l'amministratore."; } else { //DocsPAWA.Logger.log(string.Format("netId: {0}; sessionName: {1}", netId, sessionName)); netId = netId.Substring(1); // Generazione del token di autenticazione string token = DocsPaUtils.Security.SSOAuthTokenHelper.Generate(netId); DocsPaWR.UserLogin login = this.CreateUserLogin(netId, token, token); // Login utente al sistema documentale if (!this.ForcedLogin(login)) { // Errore di autenticazione al sistema this.lblCasAuthenticationMessage.Text = "Errore nell'autenticazione al sistema documentale: utente non riconosciuto"; } } //DocsPAWA.Logger.log("END - LoginCAS"); }
protected void Page_Load(object sender, EventArgs e) { string tema = this.Page.Theme; if (tema.ToUpper().Equals("TEMAROSSO")) { this.img_logologinente1.Visible = false; this.img_logologinente2.Visible = false; } else if (tema.ToUpper().Equals("TEMAMILANO")) { this.img_logologinente1.Visible = false; this.img_logologinente2.Visible = false; this.img_logologin.Width = 232; } this.btn_accedi.ImageUrl = "App_Themes\\" + this.Page.Theme + "\\Butt_Accedi.jpg"; string inputToken = this.GetInputToken(); // // Modifica Per PGU // il Token Passato dal PGU string idAmm = string.Empty; // // MEV CS 1.4 - Esibizione if (!string.IsNullOrEmpty(inputToken)) { Session["PGU"] = "PGU"; } // End MEV CS 1.4 - Esibizione // // // Provengo dal PGU if (inputToken.Contains('_')) { idAmm = inputToken.Split('_')[1]; inputToken = inputToken.Split('_')[0]; } // End Modifica // // // Mev Cs 1.4 - esibizione if (this.pnl_profili.Visible && !string.IsNullOrEmpty(this.hf_profiloUtente.Value)) { if (ddl_profili.SelectedValue.Equals("0")) { Session["ProfiloUtente"] = "CONSERVAZIONE"; } if (ddl_profili.SelectedValue.Equals("1")) { Session["ProfiloUtente"] = "ESIBIZIONE"; } } // End Mev cs 1.4 // if (!string.IsNullOrEmpty(inputToken) || this.hd_forceLogin.Value == "true") { string pwd = this.hd_pwd.Value; string userId = string.Empty; if (string.IsNullOrEmpty(inputToken)) { userId = this.hd_userId.Value; } else { userId = inputToken; } DocsPaWR.UserLogin lgn = this.CreateUserLogin(pwd, userId); // // Modifica per PGU if (!string.IsNullOrEmpty(idAmm)) { lgn.IdAmministrazione = idAmm; } // End Modifica // if (this.ForcedLogin(lgn)) { user = (DocsPaWR.Utente)Session["userData"]; Session["DbType"] = ConservazioneManager.getDbType(); this.LaunchApplication(); } else { this.lbl_error.Visible = true; this.lbl_error.Text = "Nome utente o password non validi."; } } }
private bool loginAction(DocsPaWR.UserLogin lgn, out string message) { bool resLogin = false; message = string.Empty; string ipaddress = ""; DocsPaWR.LoginResult loginResult; DocsPaWR.Utente utente = UserManager.login(this, lgn, out loginResult, out ipaddress); this.user = utente; if (user != null) { //PROVA SIGALOT per selezionare l'utente del centro servizi /* * user.extApplications = new DocsPaWR.ExtApplication[1]; * user.extApplications[0] = new DocsPaWR.ExtApplication(); * user.extApplications[0].codice = "CS"; */ //MODIFICATO PER GESTIONE APPLICAZIONE CENTRO SERVIZI user.codWorkingApplication = "CS"; } switch (loginResult) { case DocsPaWR.LoginResult.OK: //PROVA SIGALOT per selezionare l'utente del centro servizi //user.extApplications = new DocsPaWR.ExtApplication[1]; //user.extApplications[0] = new DocsPaWR.ExtApplication(); //user.extApplications[0].codice = "CS"; resLogin = true; Session["DbType"] = ConservazioneManager.getDbType(); this.LaunchApplication(); break; case DocsPaWR.LoginResult.UNKNOWN_USER: message = "Nome utente o password non validi."; break; case DocsPaWR.LoginResult.USER_ALREADY_LOGGED_IN: // Gestione autonoma da parte dell'utente message = "L'utente ha gia' una connessione aperta."; // // Store login object // Session.Add("loginData", lgn); string script = "<script>forceLogin('" + ipaddress + "');</script>"; Page.RegisterStartupScript("NotifyUser", script); // } break; case DocsPaWR.LoginResult.NO_RUOLI: message = "L'utente non ha un ruolo associato."; break; case DocsPaWR.LoginResult.DISABLED_USER: message = "Utente non abilitato"; break; case DocsPaWR.LoginResult.PASSWORD_EXPIRED: message = "La password dell'utente risulta scaduta. Immettere una nuova password."; break; case DocsPaWR.LoginResult.NO_AMMIN: this.hf_loginResult.Value = DocsPaWR.LoginResult.NO_AMMIN.ToString(); message = "Selezionare un'amministrazione"; break; default: // Application Error message = "Errore nella procedura di Login. Contattare l'amministrazione."; break; } if (resLogin) { //utente.urlWA = Utils.getHttpFullPath(this); Session["userData"] = utente; } return(resLogin); }
static void Main(string[] args) { XmlConfigurator.Configure(); string myDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string configFile = myDir + "\\Config\\multistampa.ini"; string modelFile = myDir + "\\Config\\model.config"; string printBinary = myDir + "\\Stamparegistri\\StampaRegistri.exe"; string printWorkdir = myDir + "\\Stamparegistri"; string printConfigFile = myDir + "\\Stamparegistri\\StampaRegistri.exe.config"; string printUserPrefix = String.Empty; string printPassword = String.Empty; ArrayList admBlackList = new ArrayList(); DateTime d = DateTime.Now; string filename = myDir + "\\" + d.ToString("yyyyMMdd") + "_multistampa.log"; try { writeLog("Multistampa registro v1.0.7\nReading config..."); ConfigManager config = new ConfigManager(configFile); if (config.ExistKey("PRINTUSERPREFIX")) { printUserPrefix = config.GetValue("PRINTUSERPREFIX"); } if (config.ExistKey("PRINTPWD")) { printPassword = config.GetValue("PRINTPWD"); } if (config.ExistKey("BLACKLIST")) { string val = config.GetValue("BLACKLIST"); admBlackList.AddRange(val.Split(';')); writeLog(admBlackList.Count + " blacklisted administrations found."); } DocsPaWR.Amministrazione[] ammWSlist = null; string resultmsg = string.Empty; DocsPaWR.DocsPaWebService WS = new DocsPaWR.DocsPaWebService(); WS.Timeout = System.Threading.Timeout.Infinite; ammWSlist = WS.amministrazioneGetAmministrazioni(out resultmsg); writeLog(ammWSlist.Length + " administrations found."); int okCount = 0; int errCount = 0; int blkCount = 0; int unknCount = 0; foreach (DocsPaWR.Amministrazione amm in ammWSlist) { writeLog("-----------------------------------"); string idAmm = "" + amm.systemId; string codAmm = "" + amm.codice; string descAmm = "" + amm.descrizione; string printUser = codAmm + printUserPrefix; string logPath = codAmm; string logPathHistory = codAmm + "\\History"; string ipaddress = String.Empty; DocsPaWR.Utente utente = null; DocsPaWR.UserLogin userLogin = new DocsPaWR.UserLogin(); userLogin.UserName = printUser; userLogin.Password = printPassword; userLogin.IdAmministrazione = amm.systemId; DocsPaWR.LoginResult lr = WS.Login(userLogin, true, Guid.NewGuid().ToString(), out utente, out ipaddress); if (utente == null) { writeLog("Utente non loggato in DocsPA: " + printUser + " per idAmm: " + amm.systemId); } else { WS.Logoff(utente.userId, utente.idAmministrazione, utente.sessionID, utente.dst); // verificare che ruoli e registri siano valorizzati if (utente.ruoli == null || utente.ruoli[0] == null) { writeLog("Ruoli non configurati per utente: " + printUser + " per idAmm: " + amm.systemId); } else { if (utente.ruoli[0].registri == null || utente.ruoli[0].registri[0] == null) { writeLog("Registri non configurati per utente: " + printUser + " per idAmm: " + amm.systemId); } else { foreach (DocsPaWR.Registro registro in utente.ruoli[0].registri) { string idRegistro = registro.systemId; // Skip if blacklisted if (admBlackList.Contains(codAmm)) { writeLog("Skipped print for " + codAmm + " - " + descAmm + ". Blacklisted."); blkCount++; continue; } // Delete current print config if (System.IO.File.Exists(printConfigFile)) { File.Delete(printConfigFile); } String logString = "Writing config for " + codAmm + " - " + descAmm + " (" + idAmm + ") " + "user: "******"_IDAMM_", idAmm); newline = newline.Replace("_USERNAME_", printUser); newline = newline.Replace("_PASSWORD_", printPassword); newline = newline.Replace("_LOGPATH_", logPath); newline = newline.Replace("_LOGPATHHISTORY_", logPathHistory); newline = newline.Replace("_IDREGISTRO_", idRegistro); configWriter.WriteLine(newline); } configWriter.Flush(); configWriter.Close(); writeLog("Running print service..."); RunResults exeResult = null; try { exeResult = RunExecutable(printBinary, "", printWorkdir); } catch (Exception e) { writeLog("Error running print service:" + e.Message); } string output = exeResult.Output.ToString(); writeLog(output); if (output.Contains("Docspa fallita")) // login failed { writeLog("Print ERROR - Login failed"); errCount++; } else if (output.Contains("Stampa del registro fallita")) // nothing to print or file chars error (invalid chars in reg desc) { if (output.Contains("Non ci sono protocolli da stampare")) { writeLog("Print OK"); okCount++; } else { writeLog("Print ERROR - Check print log for details"); errCount++; } } else if (output.Contains("Docspa eseguita")) // login ok { writeLog("Print OK"); okCount++; } else { writeLog("Print returned an unknown status. See print log for details."); unknCount++; } // Console.ReadKey(); } } } } } writeLog("-----------------------------------"); writeLog("Print process finished. OK: " + okCount + ", ERRORS: " + errCount + ", BLACKLISTED: " + blkCount + ", UNKNOWN: " + unknCount + " over a total of " + ammWSlist.Length); } catch (Exception e) { writeLog("Ex: " + e.Message + "\nStack: " + e.StackTrace); } }
/// <summary> /// /// </summary> protected virtual void ExecuteChangePassword() { bool isUserMultiAmm = false; bool continua = true; string pwdUser = string.Empty; if (Session["ok_multiAmm"] != null) { this.txt_vecchiaPWD.Text = Session["oldPwd"].ToString(); Session.Remove("oldPwd"); this.txt_nuovaPWD.Text = Session["newPwd"].ToString(); Session.Remove("newPwd"); this.txt_confermaPWD.Text = Session["confPwd"].ToString(); Session.Remove("confPwd"); } //sono stati inseriti entrambi i campi if (this.txt_vecchiaPWD.Text.Trim().Equals(string.Empty) || this.txt_nuovaPWD.Text.Trim().Equals(string.Empty) || this.txt_confermaPWD.Text.Trim().Equals(string.Empty)) { if (!this.Page.IsStartupScriptRegistered("alertJS")) { string scriptString = "<SCRIPT>alert('Inserire valori per tutti i campi!');</SCRIPT>"; this.Page.RegisterStartupScript("alertJS", scriptString); } } else { // inserita Vecchia Password errata DocsPaWR.LoginResult loginResult; string ipaddress = ""; DocsPaWR.Utente utente = UserManager.login(this, this.CreateUserLogin(), out loginResult, out ipaddress); if (loginResult == DocsPAWA.DocsPaWR.LoginResult.UNKNOWN_USER) { if (!this.Page.IsStartupScriptRegistered("alertJS")) { string scriptString = "<SCRIPT>alert('La vecchia password risulta essere errata!');</SCRIPT>"; this.Page.RegisterStartupScript("alertJS", scriptString); } } else { // i campi sono uguali if (!this.txt_confermaPWD.Text.Trim().Equals(this.txt_nuovaPWD.Text.Trim())) { if (!this.Page.IsStartupScriptRegistered("alertJS")) { string scriptString = "<SCRIPT>alert('La nuova password e la sua conferma non coincidono!');</SCRIPT>"; this.Page.RegisterStartupScript("alertJS", scriptString); } } else { DocsPaWR.UserLogin ut = UserManager.CreateUserLoginCurrentUser(this.txt_confermaPWD.Text); isUserMultiAmm = (VerificaUtenteMultiAmministrazioneMod(ut.UserName)); if (Session["ok_multiAmm"] == null) { if (isUserMultiAmm) { //TODO SHOW ALERT MESSAGE.... continua = false; Session.Add("ok_multiAmm", ut); Session.Add("oldPwd", this.txt_vecchiaPWD.Text); Session.Add("newPwd", this.txt_nuovaPWD.Text); Session.Add("confPwd", this.txt_confermaPWD.Text); msg_modifica.Confirm("E’ presente almeno un utente con stessa UserID in un’altra amministrazione, vuoi procedere con la modifica? Attenzione: l’eventuale modifica della password verrà ereditata dagli altri utenti."); } } else { Session.Remove("ok_multiAmm"); } if (continua) { DocsPaWR.DocsPaWebService ws = new DocsPAWA.DocsPaWR.DocsPaWebService(); DocsPaWR.ValidationResultInfo result = ws.UserChangePassword(UserManager.CreateUserLoginCurrentUser(this.txt_confermaPWD.Text, true), string.Empty); if (!result.Value) { string errorMessage = result.BrokenRules[0].Description; // Se la modifica password non è andata a buon fine this.lbl_message.Text = errorMessage; //this.lbl_message.Text = "<br><font color='#ff0000'>attenzione!<br>errore durante la procedura di cambia password!</font><br>"; } else { if (isUserMultiAmm) { this.ModificaPasswordUtenteMultiAmm(ut.UserName.ToUpper(), ut.IdAmministrazione); } this.lbl_message.Text = "<br>Aggiornamento avvenuto con successo<br><br><br><br>"; this.lbl_oggetto.Visible = false; this.Label3.Visible = false; this.Label2.Visible = false; this.txt_nuovaPWD.Visible = false; this.txt_confermaPWD.Visible = false; this.txt_vecchiaPWD.Visible = false; this.btn_OK.Visible = false; } this.lbl_message.Visible = true; } } } } }
//private logedUser = null; protected void Page_Load(object sender, EventArgs e) { this.strFrom = this.Request.QueryString["from"]; this.docNumber = this.Request.QueryString["docNumber"]; this.idProfile = this.Request.QueryString["idProfile"]; this.groupId = this.Request.QueryString["groupId"]; this.numVersion = string.IsNullOrEmpty(this.Request.QueryString["numVersion"]) ? "1" : this.Request.QueryString["numVersion"]; string tknVCAP = this.Request.QueryString["tknVCAP"]; this.idAmministrazione = this.Request.QueryString["idAmministrazione"]; this.idObj = this.Request.QueryString["idObj"]; this.tipoProto = this.Request.QueryString["tipoProto"]; //verifico utente loggato Utente loggedUser = UIManager.UserManager.GetUserInSession(); //UIManager.UserManager.SetUserLanguage("English"); UIManager.LoginManager.IniInitializesLanguages(); string login = Utils.utils.getHttpFullPath() + "/Login.aspx?from=" + this.strFrom + "&idProfile=" + this.idProfile + "&groupId=" + this.groupId + "&numVersion=" + this.numVersion + "&idAmministrazione=" + this.idAmministrazione + "&idObj=" + this.idObj + "&tipoProto=" + this.tipoProto; if (loggedUser == null && !string.IsNullOrEmpty(tknVCAP)) { string authInfo = Decrypt(tknVCAP); string[] authInfoArray = authInfo.Split('|'); DocsPaWR.UserLogin userLogin = new DocsPaWR.UserLogin(); userLogin.UserName = authInfoArray[5]; NttDataWA.Utils.CryptoString crypto = new NttDataWA.Utils.CryptoString(authInfoArray[5]); string encodedValue = crypto.Encrypt(string.Format("UID={0};SESSIONID={1};DATETIME={2}", authInfoArray[5], Guid.NewGuid().ToString(), DateTime.Now)); string passTkn = string.Format("{0}{1}", "SSO=", encodedValue); userLogin.Password = passTkn; userLogin.IdAmministrazione = authInfoArray[4]; userLogin.IPAddress = this.Request.UserHostAddress; userLogin.SessionId = this.Session.SessionID; createBrowserInfo(userLogin); bool result = false; DocsPaWR.LoginResult loginResult; DocsPaWR.Utente user = UIManager.LoginManager.ForcedLogin(this, userLogin, out loginResult); bool result2 = false; if (loginResult == DocsPaWR.LoginResult.OK) { result2 = true; UIManager.UserManager.SetUserInSession(user); UIManager.RoleManager.SetRoleInSession(user.ruoli[0]); UIManager.RegistryManager.SetRFListInSession(UIManager.UserManager.getListaRegistriWithRF(user.ruoli[0].systemId, "1", "")); UIManager.RegistryManager.SetRegAndRFListInSession(UIManager.UserManager.getListaRegistriWithRF(user.ruoli[0].systemId, "", "")); UIManager.DocumentManager.GetLettereProtocolli(); loggedUser = UIManager.UserManager.GetUserInSession(); } } if (loggedUser == null) { HttpContext.Current.Session["directLink"] = Utils.utils.GetHttpRootPath() + this.Request.Url.PathAndQuery; this.ResetSession(); Response.Redirect(login); } else { if (!string.IsNullOrEmpty(groupId)) { Ruolo[] roles = UIManager.UserManager.GetUserInSession().ruoli; Ruolo role = (from r in roles where r.idGruppo.Equals(groupId) select r).FirstOrDefault(); if (role != null) { UIManager.RoleManager.SetRoleInSession(role); UIManager.RegistryManager.SetRegAndRFListInSession(UIManager.UserManager.getListaRegistriWithRF(role.systemId, "", "")); UIManager.RegistryManager.SetRFListInSession(UIManager.UserManager.getListaRegistriWithRF(role.systemId, "1", "")); } } HttpContext.Current.Session["directLink"] = null; switch (strFrom) { case "file": SchedaDocumento schedaDocumento = UIManager.DocumentManager.getDocumentDetails(this, idProfile, docNumber); if (schedaDocumento != null) { UIManager.DocumentManager.setSelectedRecord(schedaDocumento); FileRequest fileToView = schedaDocumento.documenti[int.Parse(this.numVersion) - 1]; FileDocumento fileDoc = UIManager.FileManager.getInstance(schedaDocumento.systemId).GetFile(this.Page, fileToView, false); UIManager.FileManager.setSelectedFile(fileToView); HttpContext.Current.Session["fileDoc"] = fileDoc; HttpContext.Current.Session["OpenDirectLink"] = "true"; this.IsZoom = true; //this.fra_main.Attributes["src"] = ResolveUrl("~/Popup/DocumentViewer.aspx"); //this.fra_main.Attributes["src"] = Utils.utils.getHttpFullPath() + "/Popup/DocumentViewer.aspx"; DocumentViewer.OpenDocumentViewer = true; Response.Redirect(Utils.utils.getHttpFullPath() + "/Popup/DocumentViewer.aspx"); } else { this.fra_main.Visible = false; this.Link1.Visible = true; this.messager.Visible = true; this.lblTxt.Text = Utils.Languages.GetMessageFromCode("ErrorOpenDirectLinkNotAllowed", UIManager.UserManager.GetUserLanguage()); } break; case "record": SchedaDocumento schedaDoc = UIManager.DocumentManager.getDocumentDetails(this, idObj, idObj); if (schedaDoc != null) { UIManager.DocumentManager.setSelectedRecord(schedaDoc); HttpContext.Current.Session["isZoom"] = null; HttpContext.Current.Session["OpenDirectLink"] = "true"; //this.fra_main.Attributes["src"] = ResolveUrl("~/Document/Document.aspx"); //this.fra_main.Attributes["src"] = Utils.utils.getHttpFullPath() + "/Document/Document.aspx"; Response.Redirect(Utils.utils.getHttpFullPath() + "/Document/Document.aspx"); } else { this.fra_main.Visible = false; this.Link1.Visible = true; this.messager.Visible = true; this.lblTxt.Text = Utils.Languages.GetMessageFromCode("ErrorOpenDirectLinkNotAllowed", UIManager.UserManager.GetUserLanguage()); } break; case "project": Fascicolo proj = UIManager.ProjectManager.getFascicoloDaCodice(this, idObj); if (proj != null) { proj.template = ProfilerProjectManager.getTemplateFascDettagli(proj.systemID); UIManager.ProjectManager.setProjectInSession(proj); HttpContext.Current.Session["isZoom"] = null; HttpContext.Current.Session["OpenDirectLink"] = "true"; // this.fra_main.Attributes["src"] = ResolveUrl("~/Project/Project.aspx"); //this.fra_main.Attributes["src"] = Utils.utils.getHttpFullPath() + "/Project/Project.aspx"; Response.Redirect(Utils.utils.getHttpFullPath() + "/Project/Project.aspx"); } else { this.fra_main.Visible = false; this.Link1.Visible = true; this.messager.Visible = true; this.lblTxt.Text = Utils.Languages.GetMessageFromCode("ErrorOpenDirectLinkNotAllowed", UIManager.UserManager.GetUserLanguage()); } break; } } }
private void EsercitaDelega() { GridViewRow item = null; //Ricerca delle delega selezionata che si vuole esercitare for (int i = 0; i < this.gridViewResult.Rows.Count; i++) { RadioButton rbSelection = this.gridViewResult.Rows[i].Cells[0].FindControl("rbSel") as RadioButton; if (rbSelection.Checked) { item = this.gridViewResult.Rows[i]; } } if (item != null) { DocsPaWR.InfoUtente infoUtDelegato = UserManager.GetInfoUser(); //Imposto nuovo utente (delegante) per esercitare la delega DocsPaWR.UserLogin userLogin = new DocsPaWR.UserLogin(); DocsPaWR.Utente utente = DelegheManager.getUtenteById(this, item.Cells[7].Text); userLogin.UserName = utente.userId; userLogin.Password = ""; userLogin.IdAmministrazione = UserManager.GetInfoUser().idAmministrazione; userLogin.IPAddress = this.Request.UserHostAddress; DocsPaWR.LoginResult loginResult; utente = DelegheManager.EsercitaDelega(this, userLogin, item.Cells[11].Text, item.Cells[9].Text, out loginResult); switch (loginResult) { case DocsPaWR.LoginResult.OK: if (utente != null) { utente.urlWA = utils.getHttpFullPath(); //Memorizzo le info sul delegato che serviranno nel momento in cui //si dismette la delega UserManager.setDelegato(infoUtDelegato); DocsPaWR.Utente utenteDelegato = UserManager.GetUserInSession(); DocsPaWR.Ruolo ruoloDelegato = RoleManager.GetRoleInSession(); UserManager.setUtenteDelegato(this, utenteDelegato); RoleManager.setRuoloDelegato(ruoloDelegato); //Nuovo utente (delegante) RoleManager.SetRoleInSession(utente.ruoli[0]); UIManager.RegistryManager.SetRFListInSession(UIManager.UserManager.getListaRegistriWithRF(utente.ruoli[0].systemId, "1", "")); UIManager.RegistryManager.SetRegAndRFListInSession(UIManager.UserManager.getListaRegistriWithRF(utente.ruoli[0].systemId, "", "")); UserManager.SetUserInSession(utente); Session["ESERCITADELEGA"] = true; // disconnessione utente delegante se loggato LoginManager.LogOut(utente.userId, utente.idAmministrazione, this.Session.SessionID); //Rimuovo le notifiche del vecchio utente per far si che il centro notifiche venga aggiornato correttamente HttpContext.Current.Session.Remove("ListAllNotify"); Response.Redirect("../Index.aspx"); } break; case DocsPaWR.LoginResult.USER_ALREADY_LOGGED_IN: ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('WarningMandateUserAlreadyLoggedIn', 'warning', '');", true); break; case DocsPaWR.LoginResult.NO_RUOLI: ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('WarningMandateNoRoles', 'warning', '');", true); break; default: // Application Error ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateGeneral', 'error', '');", true); break; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateNoneSelected', 'error', '');", true); } }