public bool AddTacticalAccountToWinlink(string strTacticalAddress, string strPassword) { // // Registers a tactical address and password if the address is not // already in use. Returns True if successful, false if the address is // already in use. // // Test for existence of the tactical address in the CMS database. // if (WinlinkWebServices.AccountExists(strTacticalAddress)) { // // This account is already registered. Check the password. // if (!WinlinkWebServices.ValidatePassword(strTacticalAddress, strPassword)) { MessageBox.Show( "The address/account has been previously used and the entered password " + "does not match the password for '" + strTacticalAddress + "' in the Winlink database" + Globals.CR + Globals.CR + "To use this address/account " + "name you must have the previously assigned password.", "Validating Password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } if (MessageBox.Show( "The account name '" + strTacticalAddress + "' is already in use or otherwise " + "not available." + Globals.CRLF + "Do you want to add this account to this Paclink site anyway?", "Existing Tactical Address Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MessageBox.Show( "Using the same Tactical address from different Paclink sites must be done carefully." + Globals.CR + "Once mail is retrieved by a Paclink site it is considered delivered by the WL2K system " + Globals.CR + "and will not longer be accessable to other sites.", "Caution!", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } } // // Add the new tactical address to the CMS database. // try { WinlinkWebServices.AddTacticalAddress(strTacticalAddress, strPassword); } catch (Exception ex) { MessageBox.Show( "Error adding tactical account " + strTacticalAddress + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } return true; }
} // btnAdd_Click private void btnPassword_Click(object s, EventArgs e) { // // Changes the password for the tactical address. // // Prompt for the old and new passwords. // string strOldPassword = txtPassword.Text.Trim(); var objDialogChangePassword = new DialogChangePassword(strOldPassword); var enmResult = objDialogChangePassword.ShowDialog(); if (enmResult == DialogResult.Cancel) return; // // They confirmed that they want to make the change. // try { Cursor = Cursors.WaitCursor; strOldPassword = objDialogChangePassword.GetOldPassword(); string strNewPassword = objDialogChangePassword.GetNewPassword(); string strAccount = cmbAccount.Text.Trim(); // // Test for existence of the tactical address in the CMS database. // if (WinlinkWebServices.AccountExists(strAccount)) { // // This account is already registered. Check the old password. // if (!WinlinkWebServices.ValidatePassword(strAccount, strOldPassword)) { MessageBox.Show( "The address/account has been previously used and the entered old password" + " does not match the password for '" + strAccount + "' in the Winlink database" + Globals.CR + Globals.CR + "To use this address/account " + "name you must have the previously assigned password.", "Validating Password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // // Set the new password // try { WinlinkWebServices.ChangePassword(strAccount, strOldPassword, strNewPassword); } catch (Exception ex) { MessageBox.Show("Error while setting password: "******"Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { // // This account is not know by the system. // MessageBox.Show( "The tactical address " + strAccount + " has not been registered with the Winlink system.", "Checking address", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // // Update the password in the .ini file. // Globals.Settings.Save(strAccount, "EMail Password", strNewPassword); // // Finished // Accounts.RefreshAccountsList(); FillAccountSelection(); MessageBox.Show( "The password for " + strAccount + " has been changed to " + strNewPassword, "Password Changed", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { Cursor = Cursors.Default; } }