The thing that is not so trivial about this is how you perform the
authentication. Quite frankly, it's not something that people should
re-implement if we are talking about applications on local machines.
There is a reason for single-sign on in Windows: there is ^already^
someone logged in and authorized on the machine
If this is a web-based app then that is different, because the domain
you are working in is larger than the machine.
But generally, passwords for local applications are a bad idea, IMO.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Marc Gravell said:
There is nothing special about a password form; I think you need to
find a book or whatever about the fundamentals of showing a form; the
only minor change is you might want to hide the user input (TextBox
has "PasswordChar").
Show the login form; if successful, show the next...? Small example
below, but note that in a non-trivial system you might choose to hold
"am I logged in? as who? with what acces?" by a "Principal", which
means you don't have to track it separately.
bool loggedIn;
using (MyLoginForm loginForm = new MyLoginForm())
{
loggedIn = loginForm.ShowDialog() == DialogResult.OK;
}
if (loggedIn)
{
using (MyMainForm mainForm = new MyMainForm())
{
// maybe "Application.Run(mainForm)" instead
mainForm.ShowDialog();
}
}