private Credentials CollectDataForCredentials() { VSFramework.TripleDES tripleDes = new VSFramework.TripleDES(); try { Credentials CredentialsObject = new Credentials(); CredentialsObject.AliasName = "Exchange-" + LocComboBox.Text; CredentialsObject.UserID = Uid; string rawPass = Pwd; byte[] encryptedPass = tripleDes.Encrypt(rawPass); string encryptedPassAsString = string.Join(", ", encryptedPass.Select(s => s.ToString()).ToArray()); CredentialsObject.Password = encryptedPassAsString; return(CredentialsObject); } catch (Exception ex) { Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } finally { } }
// Credentials c = new Credentials(); // c.AliasName = CredentialsComboBox.Text; // DataTable Dt = VSWebBL.ConfiguratorBL.CredentialsBL.Ins.getCredentialsByName(c); // UserIdtextBox.Text = Dt.Rows[0]["UserID"].ToString(); // VSFramework.TripleDES tripleDes = new VSFramework.TripleDES(); // string MyObjPwd; // string[] MyObjPwdArr; // byte[] MyPass; // MyObjPwd = Dt.Rows[0]["Password"].ToString(); // if (MyObjPwd != "") // { // MyObjPwdArr = MyObjPwd.Split(','); // MyPass = new byte[MyObjPwdArr.Length]; // for (int i = 0; i < MyObjPwdArr.Length; i++) // { // MyPass[i] = Byte.Parse(MyObjPwdArr[i]); // } // PasswordTextbox.Text = tripleDes.Decrypt(MyPass); // //ViewState.Add("Pwd", PasswordTextbox.Text); // addPwd = tripleDes.Decrypt(MyPass); // } // //getCredentials(); //} private ArrayList getCredentials() { ArrayList Cred = new ArrayList(); Credentials c = new Credentials(); c.AliasName = CredentialsComboBox.Text; DataTable Dt = VSWebBL.ConfiguratorBL.CredentialsBL.Ins.getCredentialsById(c); Cred.Add(Dt.Rows[0]["UserID"].ToString()); //UserIdtextBox.Text = Dt.Rows[0]["UserID"].ToString(); VSFramework.TripleDES tripleDes = new VSFramework.TripleDES(); string MyObjPwd; string[] MyObjPwdArr; byte[] MyPass; MyObjPwd = Dt.Rows[0]["Password"].ToString(); if (MyObjPwd != "") { MyObjPwdArr = MyObjPwd.Split(','); MyPass = new byte[MyObjPwdArr.Length]; for (int i = 0; i < MyObjPwdArr.Length; i++) { MyPass[i] = Byte.Parse(MyObjPwdArr[i]); } //PasswordTextbox.Text = tripleDes.Decrypt(MyPass); Cred.Add(tripleDes.Decrypt(MyPass)); //PasswordTextbox.Text = tripleDes.Decrypt(MyPass); //ViewState.Add("Pwd", PasswordTextbox.Text); } return(Cred); }
protected void OK_Click(object sender, EventArgs e) { bool check = false; LicenseKey lic = new LicenseKey(); if (UnitsTextBox.Text != "0") { lic.Units = Convert.ToInt32(UnitsTextBox.Text); lic.InstallType = InstallTypeList1.SelectedItem.Text; lic.CompanyName = CompanyNameComboBox.Text; DataTable CompanysIDDataTable = BL.UsersBL.Ins.GetCompanyID(CompanyNameComboBox.Text); int CompanyID = int.Parse(CompanysIDDataTable.Rows[0]["ID"].ToString()); lic.LicenseType = LicenseType.SelectedItem.Text; if (ExpirationDate.Date != null) { if (LicenseType.SelectedItem.Text == "Perpetual") { lic.ExpirationDate = "12/31/9999"; } else { DateTime exp = ExpirationDate.Date; lic.ExpirationDate = ExpirationDate.Date.ToString("MM/dd/yyyy"); //lic.ExpirationDate = ExpirationDate.Date.ToShortTimeString(); } } else { lic.ExpirationDate = null; } VSFramework.TripleDES tripleDes = new VSFramework.TripleDES(); string rawPass = lic.Units + "#" + lic.InstallType + "#" + lic.CompanyName + "#" + LicenseType.SelectedItem.Text + "#" + lic.ExpirationDate; byte[] encryptedPass = tripleDes.Encrypt(rawPass); string encryptedPassAsString = string.Join(", ", encryptedPass.Select(s => s.ToString()).ToArray()); string encrypt = encryptedPassAsString; Session["Key"] = encrypt; string CreatedBy = Convert.ToString(Session["UserID"]); string CreatedOn = DateTime.Now.ToString(); //int CompanyID = Convert.ToInt32(CompanyNameComboBox.SelectedItem.Value); check = BL.LicenseKeyBL.Ins.insert(encrypt, lic.Units, lic.InstallType, lic.LicenseType, lic.ExpirationDate, CreatedBy, CreatedOn, CompanyID); Session["LicenseUpdateStatus"] = CompanyNameComboBox.Text; Response.Redirect("LicenseGrid.aspx", false); Context.ApplicationInstance.CompleteRequest(); } else { string script = "alert('Units should be Greater than 0');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", script, true); } }
public void UpdatePassword() { bool updated = false; byte[] MyPass; VSFramework.TripleDES mySecrets = new VSFramework.TripleDES(); try { if (Session["mypass"] != "" & Session["mypass"] != null) { MyPass = mySecrets.Encrypt(Session["mypass"].ToString()); System.Text.StringBuilder newstr = new System.Text.StringBuilder(); foreach (byte b in MyPass) { newstr.AppendFormat("{0}, ", b); } string bytepwd = newstr.ToString(); int n = bytepwd.LastIndexOf(", "); bytepwd = bytepwd.Substring(0, n); updated = VSWebBL.SettingBL.SettingsBL.Ins.UpdateSvalue("Sametime Password 1", bytepwd, VSWeb.Constants.Constants.SysByte); } } catch (Exception ex) { //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } try { if (Session["mypass2"] != "" & Session["mypass2"] != null) { MyPass = mySecrets.Encrypt(Session["mypass2"].ToString()); System.Text.StringBuilder newstr = new System.Text.StringBuilder(); foreach (byte b in MyPass) { newstr.AppendFormat("{0}, ", b); } string bytepwd = newstr.ToString(); int n = bytepwd.LastIndexOf(", "); bytepwd = bytepwd.Substring(0, n); updated = VSWebBL.SettingBL.SettingsBL.Ins.UpdateSvalue("Sametime Password 2", bytepwd, "System.Byte[]"); } } catch (Exception ex) { //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } }
public void LoadDominoServers() { Domino.NotesDbDirectory dir; Domino.NotesDatabase db; Domino.NotesView view; Domino.NotesDocument doc; Domino.NotesName sname; Domino.NotesItem item; Domino.NotesItem item2; byte[] MyPass; string MyDominoPassword; //should be string string MyObjPwd; string[] MyObjPwdArr; //1/8/2014 NS added DataTable importedDT; //12/24/2013 NS added - store the value of the Domino Server field in the Settings table Primary Server column bool updatedsrv = false; updatedsrv = VSWebBL.SettingBL.SettingsBL.Ins.UpdateSvalue("Primary Server", DomServerTextBox.Text, VSWeb.Constants.Constants.SysString); //object MyObjPwd; //12/20/2013 NS added errorDiv.Style.Value = "display: none;"; //8/12/2014 NS added for VSPLUS-861 errorinfoDiv.Style.Value = "display: none"; DataTable LocationsDataTable = new DataTable(); LocationsDataTable = VSWebBL.SecurityBL.LocationsBL.Ins.GetAllData(); if (LocationsDataTable.Rows.Count > 0) { LocComboBox.DataSource = LocationsDataTable; LocComboBox.TextField = "Location"; LocComboBox.ValueField = "Location"; LocComboBox.DataBind(); LocIDComboBox.DataSource = LocationsDataTable; LocIDComboBox.TextField = "ID"; LocIDComboBox.ValueField = "ID"; LocIDComboBox.DataBind(); VSFramework.TripleDES mySecrets = new VSFramework.TripleDES(); try { MyObjPwd = VSWebBL.SettingBL.SettingsBL.Ins.Getvalue("Password"); //3/25/2014 NS modified for VSPLUS-494 if (MyObjPwd != "") { MyObjPwdArr = MyObjPwd.Split(','); MyPass = new byte[MyObjPwdArr.Length]; for (int i = 0; i < MyObjPwdArr.Length; i++) { MyPass[i] = Byte.Parse(MyObjPwdArr[i]); } } else { //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "The following error has occurred: Notes password may not be empty. Please update the password under Stored Passwords & Options\\IBM Domino Settings." + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; MyPass = null; } } catch (Exception ex) { //12/20/2013 NS added //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "The following error has occurred: " + ex.Message + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; //8/12/2014 NS added for VSPLUS-861 errorinfoDiv.Style.Value = "display: block"; MyPass = null; //5/15/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } try { if (MyPass != null) { MyDominoPassword = mySecrets.Decrypt(MyPass); } else { MyDominoPassword = null; } } catch (Exception ex) { //12/20/2013 NS added //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "The following error has occurred: " + ex.Message + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; //8/12/2014 NS added for VSPLUS-861 errorinfoDiv.Style.Value = "display: block"; MyDominoPassword = ""; //5/15/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } //3/25/2014 NS modified for VSPLUS-494 if (MyDominoPassword != null) { try { Domino.NotesSession NotesSessionObject = new Domino.NotesSession(); NotesSessionObject.Initialize(MyDominoPassword); dir = NotesSessionObject.GetDbDirectory(DomServerTextBox.Text); //db = dir.GetFirstDatabase(Domino.DB_TYPES.NOTES_DATABASE); db = dir.OpenDatabase("names.nsf"); view = db.GetView("($Servers)"); doc = view.GetFirstDocument(); DataTable dt = new DataTable(); DataRow dr = dt.NewRow(); //1/8/2014 NS added DataRow[] foundRows; dt.Columns.Add("ServerName", typeof(string)); dt.Columns.Add("IPAddress", typeof(string)); //1/8/2014 NS added - get a list of all servers already imported. Display only the ones that have not yet been imported. importedDT = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetServer(); while (doc != null) { item = doc.GetFirstItem("ServerName"); sname = NotesSessionObject.CreateName(item.Text); dr["ServerName"] = sname.Abbreviated; //1/8/2014 NS added foundRows = importedDT.Select("ServerName = '" + sname.Abbreviated + "'"); if (foundRows.Length == 0) { //5/16/2013 NS modified //item = doc.GetFirstItem("NetAddresses"); item = doc.GetFirstItem("SMTPFullHostDomain"); dr["IPAddress"] = item.Text; //2/5/2016 NS modified for VSPLUS-2068 if (item == null || item.Text == null || item.Text == "") { //1/26/2016 NS modified for VSPLUS-2068 item2 = doc.GetFirstItem("NetAddresses"); dr["IPAddress"] = item2.Text; if (item2 == null || item2.Text == null || item2.Text == "") { dr["IPAddress"] = "dummyaddress.yourdomain.com"; } } dt.Rows.Add(dr); dr = dt.NewRow(); } doc = view.GetNextDocument(doc); } //1/8/2014 NS modified if (dt.Rows.Count > 0) { //1/8/2014 NS added infoDiv.Style.Value = "display: block"; SrvCheckBoxList.DataSource = dt; SrvCheckBoxList.TextField = "ServerName"; SrvCheckBoxList.ValueField = "ServerName"; SrvCheckBoxList.DataBind(); IPCheckBoxList.DataSource = dt; IPCheckBoxList.TextField = "IPAddress"; IPCheckBoxList.ValueField = "IPAddress"; IPCheckBoxList.DataBind(); //12/20/2013 NS added ASPxRoundPanel1.Visible = true; } else { //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "There are no new servers in the address book that have not already been imported into VitalSigns." + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; } } catch (Exception ex) { //12/20/2013 NS added //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "The following error has occurred: " + ex.Message + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; //8/12/2014 NS added for VSPLUS-861 errorinfoDiv.Style.Value = "display: block"; db = null; dir = null; view = null; doc = null; //5/15/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } } } //5/13/2014 NS added for VSPLUS-183 else { //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "All imported servers must be assigned to a location. There were no locations found. Please create at least one location entry using the 'Setup & Security - Maintain Server Locations' menu option." + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; } }
private DataTable GetNotesDatabases(string ServerName) { Domino.NotesDbDirectory dir; Domino.NotesDatabase db; //4/26/2013 NS modified //VSFramework.RegistryHandler myRegistry = new VSFramework.RegistryHandler(); byte[] MyPass; string MyDominoPassword; //should be string //object MyObjPwd; string MyObjPwd; string[] MyObjPwdArr; DataTable dt = new DataTable(); VSFramework.TripleDES mySecrets = new VSFramework.TripleDES(); try { //MyObjPwd = myRegistry.ReadFromRegistry("Password"); MyObjPwd = VSWebBL.SettingBL.SettingsBL.Ins.Getvalue("Password"); MyObjPwdArr = MyObjPwd.Split(','); MyPass = new byte[MyObjPwdArr.Length]; for (int i = 0; i < MyObjPwdArr.Length; i++) { MyPass[i] = Byte.Parse(MyObjPwdArr[i]); } } catch (Exception ex) { MyPass = null; //12/31/2013 NS modified /* * SelectNotesPopupControl.ShowOnPageLoad = false; * ErrorMessageLabel.Text = "The password specified in the Settings table is empty or invalid."; * ErrorMessagePopupControl.HeaderText = "Incorrect Domino Password"; * ValidationUpdatedButton.Visible = true; * ValidationOkButton.Visible = false; * ErrorMessagePopupControl.ShowOnPageLoad = true; */ //10/3/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "The password specified in the Settings table is empty or invalid. " + ex.Message + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } try { if (MyPass != null) { MyDominoPassword = mySecrets.Decrypt(MyPass); } else { MyDominoPassword = null; //12/31/2013 NS modified /* * SelectNotesPopupControl.ShowOnPageLoad = false; * ErrorMessageLabel.Text = "The password specified in the Settings table is empty or invalid."; * ErrorMessagePopupControl.HeaderText = "Incorrect Domino Password"; * ValidationUpdatedButton.Visible = true; * ValidationOkButton.Visible = false; * ErrorMessagePopupControl.ShowOnPageLoad = true; */ //10/3/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "The password specified in the Settings table is empty or invalid." + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; } } catch (Exception ex) { MyDominoPassword = ""; //12/31/2013 NS modified /* * SelectNotesPopupControl.ShowOnPageLoad = false; * ErrorMessageLabel.Text = "VitalSigns was unable to decrypt the password stored in the Settings table. Please ensure the password is correct."; * ErrorMessagePopupControl.HeaderText = "Domino Password Could Not Be Decrypted"; * ValidationUpdatedButton.Visible = true; * ValidationOkButton.Visible = false; * ErrorMessagePopupControl.ShowOnPageLoad = true; */ //10/3/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "VitalSigns was unable to decrypt the password stored in the Settings table. Please ensure the password is correct. " + ex.Message + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } try { NotesSessionObject.Initialize(MyDominoPassword); dir = NotesSessionObject.GetDbDirectory(ServerName); db = dir.GetFirstDatabase(Domino.DB_TYPES.NOTES_DATABASE); DataRow dr = dt.NewRow(); dt.Columns.Add("DBTitle", typeof(string)); dt.Columns.Add("DBFile", typeof(string)); dt.Columns.Add("ReplicaID", typeof(string)); while (db != null) { dr["DBTitle"] = db.Title; dr["DBFile"] = db.FilePath; dr["ReplicaID"] = db.ReplicaID; dt.Rows.Add(dr); dr = dt.NewRow(); db = dir.GetNextDatabase(); } db = null; dr = null; System.Runtime.InteropServices.Marshal.ReleaseComObject(NotesSessionObject); } catch (Exception ex) { using (System.IO.StreamWriter _testData = new System.IO.StreamWriter(System.Web.HttpContext.Current.Server.MapPath("~/Config_EditNotes_Log.txt"), true)) { _testData.WriteLine(ex.Message); // Write the file. } db = null; dir = null; //12/31/2013 NS modified /* * SelectNotesPopupControl.ShowOnPageLoad = false; * ErrorMessageLabel.Text = "Notes session could not be initialized due to an incorrect password value."; * ErrorMessagePopupControl.HeaderText = "Incorrect Domino Password"; * ValidationUpdatedButton.Visible = true; * ValidationOkButton.Visible = false; * ErrorMessagePopupControl.ShowOnPageLoad = true; */ //10/3/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "Notes session could not be initialized due to an incorrect password value. " + ex.Message + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } return(dt); }