Re: WinForm user authentication



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





.



Relevant Pages

  • Re: Clearing of the current GenericPrinciple/httpcontext
    ... Adam, ... I am not an expert in ASP.NET, so don't take my words too seriously if they don't match the picture you are seeing:) ... > GenericPrincipal Objects with Forms Authentication" ...
    (microsoft.public.dotnet.security)
  • RE: Forms Authentication using SQL Server - problem
    ... "thebison" wrote: ... an authentication ticket is normally created ... // GenericPrincipal objects ... once I have redirected the verified user to the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Clearing of the current GenericPrinciple/httpcontext
    ... security I followed an MSDN article "How To: ... GenericPrincipal Objects with Forms Authentication" ... I was sucessful in integrating it into my project my ...
    (microsoft.public.dotnet.security)
  • Forms Authentication using SQL Server - problem
    ... followed the MSDN libraries guide to creating forms based ... an authentication ticket is normally created ... // GenericPrincipal objects ... once I have redirected the verified user to the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Forms Authentication with SQL Server
    ... followed the MSDN libraries guide to creating forms based ... an authentication ticket is normally created ... // GenericPrincipal objects ... once I have redirected the verified user to the ...
    (microsoft.public.dotnet.framework.adonet)