Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Simple Authentication Pin
mil_an23-Mar-04 3:08
mil_an23-Mar-04 3:08 
GeneralRe: Simple Authentication Pin
Mazdak23-Mar-04 3:14
Mazdak23-Mar-04 3:14 
GeneralRe: Simple Authentication Pin
Heath Stewart23-Mar-04 3:27
protectorHeath Stewart23-Mar-04 3:27 
GeneralRe: Simple Authentication Pin
Mazdak23-Mar-04 3:34
Mazdak23-Mar-04 3:34 
GeneralRe: Simple Authentication Pin
Dave Kreskowiak23-Mar-04 2:31
mveDave Kreskowiak23-Mar-04 2:31 
GeneralRe: Simple Authentication Pin
Mazdak23-Mar-04 2:36
Mazdak23-Mar-04 2:36 
GeneralRe: Simple Authentication Pin
Dave Kreskowiak23-Mar-04 3:56
mveDave Kreskowiak23-Mar-04 3:56 
GeneralRe: Simple Authentication Pin
Heath Stewart23-Mar-04 3:39
protectorHeath Stewart23-Mar-04 3:39 
This is a very inflexible solution. Why not just use forms authentication? It's really easy to use. You simply put an authentication[^] section in your application's root Web.config file. You can add the credentials - even using plain-text passwords - right there in the file and forego having to implement a database or other data source for credentials. Then add an authorization[^] section for each location (either in your root's Web.config or in sub-directories' Web.config files) for directories you want to protect.

Then just read about the FormsAuthentication[^] class for a simple example of a page to gather credentials and the code to create the authentication token, which is an encrypted token (read: secure - much more than sessions).

This gives you the flexibility to support different data sources for credentials. And even if one day you change the username and/or password, with your approach you'd have to recompile for something so trivial. Even which putting this in the Web.config file you can change it easily without having to do anything else (the change would case the web application to restart but that's transparent).

If you want to add role-based authorization, see my article, Role-Based Security with Forms Authentication[^].

 

Microsoft MVP, Visual C#
My Articles
GeneralMultiple combos on one DataAdapter Pin
Pete Burgess23-Mar-04 0:53
Pete Burgess23-Mar-04 0:53 
GeneralRe: Multiple combos on one DataAdapter Pin
Heath Stewart23-Mar-04 3:50
protectorHeath Stewart23-Mar-04 3:50 
GeneralRe: Multiple combos on one DataAdapter Pin
Pete Burgess25-Mar-04 9:54
Pete Burgess25-Mar-04 9:54 
GeneralRe: Multiple combos on one DataAdapter Pin
Heath Stewart25-Mar-04 9:55
protectorHeath Stewart25-Mar-04 9:55 
GeneralUser who started the app Pin
nilhz23-Mar-04 0:36
nilhz23-Mar-04 0:36 
GeneralRe: User who started the app Pin
Mazdak23-Mar-04 1:20
Mazdak23-Mar-04 1:20 
GeneralRe: User who started the app Pin
nilhz23-Mar-04 3:03
nilhz23-Mar-04 3:03 
GeneralRequest for DB selection Pin
Utku KAYA22-Mar-04 22:35
Utku KAYA22-Mar-04 22:35 
GeneralRe: Request for DB selection Pin
Mazdak22-Mar-04 23:59
Mazdak22-Mar-04 23:59 
GeneralRe: Request for DB selection Pin
Heath Stewart23-Mar-04 3:51
protectorHeath Stewart23-Mar-04 3:51 
GeneralRe: Request for DB selection Pin
Heath Stewart23-Mar-04 3:56
protectorHeath Stewart23-Mar-04 3:56 
Generaldelete temp files Pin
hazzem elrefai22-Mar-04 21:12
hazzem elrefai22-Mar-04 21:12 
GeneralRe: delete temp files Pin
Corinna John22-Mar-04 23:47
Corinna John22-Mar-04 23:47 
GeneralRe: delete temp files Pin
hazzem elrefai23-Mar-04 0:25
hazzem elrefai23-Mar-04 0:25 
GeneralRe: delete temp files Pin
Dave Kreskowiak23-Mar-04 1:50
mveDave Kreskowiak23-Mar-04 1:50 
GeneralRe: delete temp files Pin
Heath Stewart23-Mar-04 3:57
protectorHeath Stewart23-Mar-04 3:57 
GeneralRe: delete temp files Pin
Dave Kreskowiak23-Mar-04 4:29
mveDave Kreskowiak23-Mar-04 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.