/// <summary> /// Verify that the user's account exists on the Unity Connection server and that they have administrator rights. The login /// to CUPI for admins will fail otherwise. /// If the login goes through add the user information to the session variable - this doesn't get used for anything other than /// as verification that the currently logged in user is authenticated - the credentials have to be resent with each CUPI command /// regardless. This just makes sure the user isn't getting cute and going directly to the user selection page. /// </summary> protected void ButtonLogin_Click(object sender, EventArgs e) { ConnectionServerRest currentConnectionServer; //check for empty strings - yes, you can use ASP form control checks for these but then you have difficulty with the Java Script //method of enabling/disabling the login button on the client side so I do the checks manually here and just use a single status //label for feedback - not quite as slick but the trade off is worth it. if (string.IsNullOrEmpty(TextBoxServerName.Text.Trim())) { LabelStatus.Text = "You must provide a Connection server name"; TextBoxServerName.Focus(); return; } if (string.IsNullOrEmpty(TextBoxName.Text.Trim())) { LabelStatus.Text = "You must provide a login name"; TextBoxName.Focus(); return; } if (string.IsNullOrEmpty(TextBoxPassword.Text.Trim())) { LabelStatus.Text = "You must provide a password"; TextBoxPassword.Focus(); return; } LabelStatus.Text = ""; try { currentConnectionServer = new ConnectionServerRest(new RestTransportFunctions(), TextBoxServerName.Text.Trim(), TextBoxName.Text.Trim(), TextBoxPassword.Text.Trim()); } catch { LabelStatus.Text = "Login failed, make sure the server name is valid, DNS is working properly and the user name and login are valid"; ButtonLogin.Enabled = true; return; } //if the class creation failed but the server login still didn't complete (this should really never happen, but just in case) if (currentConnectionServer.ServerName.Length == 0) { //login failed = give the user the chance to try again. LabelStatus.Text = "Login failed, make sure the server name is valid, DNS is working properly and the user name and login are valid"; ButtonLogin.Enabled = true; return; } //stuff the current connection server object into the session state where we can pull it out later. Then redirect to the select user //page which is where all the action takes place. Session["CurrentConnectionServer"] = currentConnectionServer; Response.Redirect("~/SelectUser.aspx"); }
public List <string> GetSettedData(ref string AStrCallReturn) { List <string> LListStrReturn = new List <string>(); string LStrDBServer = string.Empty; string LStrDBPort = string.Empty; string LStrLoginID = string.Empty; string LStrLoginPwd = string.Empty; int LIntDBPort = 0; string LStrVerificationCode004 = string.Empty; try { AStrCallReturn = string.Empty; LStrVerificationCode004 = App.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M004); LStrDBServer = TextBoxServerName.Text.Trim(); LStrDBPort = TextBoxServerPort.Text.Trim(); LStrLoginID = TextBoxLoginName.Text.Trim(); LStrLoginPwd = PasswordBoxLoginPassword.Password; if (string.IsNullOrEmpty(LStrDBServer)) { TextBoxServerName.Focus(); AStrCallReturn = "ER0001"; return(LListStrReturn); } if (string.IsNullOrEmpty(LStrDBPort)) { TextBoxServerPort.Focus(); AStrCallReturn = "ER0002"; return(LListStrReturn); } if (!int.TryParse(LStrDBPort, out LIntDBPort)) { TextBoxServerPort.Focus(); AStrCallReturn = "ER0002"; return(LListStrReturn); } if (LIntDBPort <= 0 || LIntDBPort > 65535) { TextBoxServerPort.Focus(); AStrCallReturn = "ER0002"; return(LListStrReturn); } if (string.IsNullOrEmpty(LStrLoginID)) { TextBoxLoginName.Focus(); AStrCallReturn = "ER0003"; return(LListStrReturn); } LStrDBServer = EncryptionAndDecryption.EncryptDecryptString(LStrDBServer, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004); LStrDBPort = EncryptionAndDecryption.EncryptDecryptString(LStrDBPort, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004); LStrLoginID = EncryptionAndDecryption.EncryptDecryptString(LStrLoginID, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004); LStrLoginPwd = EncryptionAndDecryption.EncryptDecryptString(LStrLoginPwd, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004); LListStrReturn.Add(LStrDBServer); LListStrReturn.Add(LStrDBPort); LListStrReturn.Add(LStrLoginID); LListStrReturn.Add(LStrLoginPwd); } catch { LListStrReturn.Clear(); } return(LListStrReturn); }
//验证输入的参数是否符合格式 private bool ConfirmConnectParameter(ref string AStrReturn) { bool LBoolReturn = false; string LStrServerName = string.Empty; string LStrServerPort = string.Empty; int LIntServerPort = 0; string LStrLoginName = string.Empty; string LStrLoginPassword = string.Empty; try { IListConnectArguments.Clear(); App.GStrCatchException = string.Empty; LStrServerName = TextBoxServerName.Text.Trim(); LStrServerPort = TextBoxServerPort.Text.Trim(); LStrLoginName = TextBoxLoginName.Text.Trim(); LStrLoginPassword = PasswordBoxLoginPassword.Password; if (string.IsNullOrEmpty(LStrServerName)) { AStrReturn = "E00001"; TextBoxServerName.Focus(); return(LBoolReturn); } if (!int.TryParse(LStrServerPort, out LIntServerPort)) { AStrReturn = "E00002"; TextBoxServerPort.Focus(); return(LBoolReturn); } if (LIntServerPort <= 1024 || LIntServerPort >= 65535) { AStrReturn = "E00002"; TextBoxServerPort.Focus(); return(LBoolReturn); } if (string.IsNullOrEmpty(LStrLoginName)) { AStrReturn = "E00003"; TextBoxLoginName.Focus(); return(LBoolReturn); } if (string.IsNullOrEmpty(LStrLoginPassword)) { AStrReturn = "E00004"; PasswordBoxLoginPassword.Focus(); return(LBoolReturn); } IListConnectArguments.Add(LStrServerName); IListConnectArguments.Add(LStrServerPort); IListConnectArguments.Add(LStrLoginName); IListConnectArguments.Add(LStrLoginPassword); LBoolReturn = true; } catch (Exception ex) { LBoolReturn = false; AStrReturn = "E00000"; App.GStrCatchException = ex.ToString(); } return(LBoolReturn); }
/// <summary> /// Park the input cursor at the server name text box. /// Note that the ASP attributes in the mark up page have the login button as the default recipient of the /// enter key for this form. /// </summary> protected void Page_Load(object sender, EventArgs e) { //if the user is redirected to the login page for invalid access or the like, an error message will be in //the session - check for it here. if (Session["ErrorNote"] != null) { LabelStatus.Text = Session["ErrorNote"].ToString(); Session.Remove("ErrorNote"); } TextBoxServerName.Focus(); }
private void DatabaseProfieEdit_Loaded(object sender, RoutedEventArgs e) { App.DrawWindowsBackGround(this); ButtonApplicationMenu.ContextMenu = App.InitApplicationMenu(); App.GSystemMainWindow.IOperationEvent += GSystemMainWindow_IOperationEvent; ImageDatabaseProfile.Source = new BitmapImage(new Uri(System.IO.Path.Combine(App.GStrApplicationDirectory, @"Images\00000029.ico"), UriKind.RelativeOrAbsolute)); DisplayElementCharacters(false); TextBoxServerName.Focus(); RadioButtonDBType2.Checked += RadioButtonDBTypeChecked; RadioButtonDBType3.Checked += RadioButtonDBTypeChecked; ShowSettedDatabaseProfile(); }
private void ConnectToServer_Loaded(object sender, RoutedEventArgs e) { App.DrawWindowsBackGround(this); ButtonApplicationMenu.ContextMenu = App.InitApplicationMenu(); App.GSystemMainWindow.IOperationEvent += GSystemMainWindow_IOperationEvent; ImageLinkToServer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(App.GStrApplicationDirectory, @"Images\00000008.ico"), UriKind.RelativeOrAbsolute)); DisplayElementCharacters(false); if (App.GBoolRunAtServer) { TextBoxServerName.Text = "127.0.0.1"; TextBoxServerPort.Text = "8081"; TextBoxLoginName.Text = "administrator"; } TextBoxServerName.Focus(); if (App.GStrAllowRemoteConnect == "0") { TextBoxServerName.IsReadOnly = true; TextBoxServerPort.IsReadOnly = true; PasswordBoxLoginPassword.Focus(); } }
private void UCConnect2SQLServer_Loaded(object sender, RoutedEventArgs e) { ShowElementLanguage(); TextBoxServerName.Focus(); }