/*
Copyright (c) Microsoft Corporation
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License
at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions and
limitations under the License.
*/
using System.Windows.Forms;
namespace Microsoft.Research.UsefulForms
{
///
/// Prompt user for password.
///
public partial class PasswordDialog : Form
{
///
/// User name.
///
public string Domain
{
get
{
int indexOfBackslash = this.textBox_username.Text.IndexOf('\\');
if (indexOfBackslash >= 0)
return this.textBox_username.Text.Substring(0, indexOfBackslash);
else
return this.textBox_username.Text;
}
}
///
/// Domain name.
///
public string User
{
get
{
int indexOfBackslash = this.textBox_username.Text.IndexOf('\\');
if (indexOfBackslash >= 0)
return this.textBox_username.Text.Substring(indexOfBackslash+1);
else
return "";
}
}
///
/// User password.
///
public string Password
{
get
{
return this.textBox_password.Text;
}
}
///
/// Show a dialog asking for a password.
///
/// Cluster to authenticate to.
/// Domain to authenticate to.
/// User to authenticate as.
public PasswordDialog(string cluster, string domain, string user)
{
InitializeComponent();
this.Text = "Please authenticate to " + cluster;
this.textBox_username.Text = domain + "\\" + user;
}
///
/// User pressed key in text box.
///
/// Unused.
/// Unused.
private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
this.DialogResult = DialogResult.OK;
}
}
}
}