all groups > dotnet security > october 2006 >
You're in the

dotnet security

group:

WinForm user authentication


WinForm user authentication Diane Yocom
10/25/2006 10:57:23 AM
dotnet security:
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

RE: WinForm user authentication Claus Konrad
10/25/2006 11:16:02 AM
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

[quoted text, click to view]
Re: WinForm user authentication Diane Yocom
10/25/2006 11:19:48 AM
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

[quoted text, click to view]

Re: WinForm user authentication Hadi Hariri
10/25/2006 4:11:32 PM
[quoted text, click to view]

Maybe you want to have custom authentication and not rely on external
factors?

--
http://www.hadihariri.com
RE: WinForm user authentication Dominick Baier
10/25/2006 9:59:27 PM
maybe first of all you should ask yourself why you are building your own
auth/authZ system - Windows provides this for you already...

---
Dominick Baier, DevelopMentor
http://www.leastprivilege.com

[quoted text, click to view]

AddThis Social Bookmark Button