Re: WinForm user authentication
- From: "Diane Yocom" <diane.yocom@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Oct 2006 11:19:48 -0700
Thanks, Claus.
I also found this in the help (finally - was just staring me in the face):
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vbcn/html/c47b8c08-3ca9-46c4-b4b0-b06dd2b956f8.htm
"Claus Konrad" <ClausKonrad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2A628733-A2AA-40CF-9FE8-E35A957C31BE@xxxxxxxxxxxxxxxx
Hi
You should use the GenericIdentity and GenericPrincipal objects for that.
And do associate the current identity to the current thread to be allowed
to
detect who is calling your methods.
Example:
class Program
{
static void Main(string[] args)
{
IIdentity iden = new GenericIdentity("Claus");
string[] roles = new string[]{"Admin", "Power"};
IPrincipal prin = new GenericPrincipal(iden, roles);
System.Threading.Thread.CurrentPrincipal = prin;
//call method
MyMethod();
Console.WriteLine("Done");
Console.Read();
}
static void MyMethod()
{
//assert caller
IIdentity caller = System.Threading.Thread.CurrentPrincipal.Identity;
Console.WriteLine("Caller = {0}", caller.Name);
}
}
--
rgds.
/Claus Konrad
www.clauskonrad.net
"Diane Yocom" wrote:
Can someone point me in the right direction for finding out how to do
custom
authentication in a WinForm application?
I have a WinForm (VB.Net) application with a login screen. I want my
users
to input their username and password, then I will authenticate them
against
my database. That's fine, I can do that. What I can't figure out is how
to
now tell dotnet that My.User has been authenticated and what roles they
are
in.
I'm converting this from an ASP.Net application, so I've created my own
CustomPrincipal class, I'm just missing how to say, "Yes, this user is
authenticated" and I can't figure out what to search on to give me any
useful information.
Help!
Diane
.
- References:
- WinForm user authentication
- From: Diane Yocom
- WinForm user authentication
- Prev by Date: WinForm user authentication
- Next by Date: RE: WinForm user authentication
- Previous by thread: WinForm user authentication
- Next by thread: RE: WinForm user authentication
- Index(es):
Relevant Pages
|
|