Click here to Skip to main content
15,909,205 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# session Pin
dan!sh 9-Apr-11 5:34
professional dan!sh 9-Apr-11 5:34 
If it is a web application, take a look at ASP.Net Role provider and Session management.

If this is a windows based application, you will have to do it on your own.

1. Set up the Role table in the database or configuration file (not recommended) as desired.
2. Then set up a Rights table. This table should essentially have the list of operations that can be performed.
3. Now, create a Role_Right_Map table. This will be 1 to many relation table between Role and Rights. This will define which Role can do what.
4. Now set up a user table. This table will have your user credentials and other details.
5. Next, make a Role_User_map. This can be a one to may relation based table between user and role.

Now, you have your setup ready. Next, when the user logs in, check for the role and corresponding rights. Based on that the available functionality will be decided.

As far as session goes, keep track of the login time in some static variable. You will also need one more static variable say activity tracker. If there is no activity done for certain amount of time, log the user out.

Possible problems in doing this:

1. If it is a desktop application with database on the client computer, anyone can make changes to the Roles and Rights. Suggested resolution can be to encrypt data in those tables.
2. User can change the system datetime which will negate all the session management rules you put in. Suggested resolution can be like this: When the user logs in, start a timer in a different thread. Now, reset the timer on every activity. If the timer has ticked for your session value (say 10 mins), log out the user.
"Your code will never work, Luc's always will.", Richard MacCutchan[^]

AnswerRe: C# session Pin
Ganesh Kumar Kaki13-Apr-11 1:21
Ganesh Kumar Kaki13-Apr-11 1:21 
QuestionWebserver only sending text occasionally? [modified] Pin
venomation8-Apr-11 16:38
venomation8-Apr-11 16:38 
AnswerRe: Webserver only sending text occasionally? Pin
Richard Andrew x649-Apr-11 3:27
professionalRichard Andrew x649-Apr-11 3:27 
GeneralRe: Webserver only sending text occasionally? Pin
venomation9-Apr-11 4:59
venomation9-Apr-11 4:59 
AnswerRe: Webserver only sending text occasionally? Pin
BobJanova11-Apr-11 5:10
BobJanova11-Apr-11 5:10 
QuestionHow to get a value to return in a textbox Pin
Justiin12658-Apr-11 12:15
Justiin12658-Apr-11 12:15 
AnswerRe: How to get a value to return in a textbox Pin
Colin Angus Mackay8-Apr-11 14:15
Colin Angus Mackay8-Apr-11 14:15 
GeneralRe: How to get a value to return in a textbox Pin
Justiin12658-Apr-11 16:28
Justiin12658-Apr-11 16:28 
AnswerRe: How to get a value to return in a textbox Pin
Luc Pattyn8-Apr-11 15:01
sitebuilderLuc Pattyn8-Apr-11 15:01 
GeneralRe: How to get a value to return in a textbox Pin
Justiin12658-Apr-11 16:39
Justiin12658-Apr-11 16:39 
AnswerRe: How to get a value to return in a textbox Pin
Luc Pattyn8-Apr-11 17:10
sitebuilderLuc Pattyn8-Apr-11 17:10 
AnswerRe: How to get a value to return in a textbox Pin
davidnz8-Apr-11 15:32
davidnz8-Apr-11 15:32 
GeneralRe: How to get a value to return in a textbox Pin
Justiin12658-Apr-11 16:44
Justiin12658-Apr-11 16:44 
GeneralRe: How to get a value to return in a textbox Pin
Rotted Frog8-Apr-11 22:29
Rotted Frog8-Apr-11 22:29 
Questionthread.interrupt only working once Pin
Member 74021668-Apr-11 10:40
Member 74021668-Apr-11 10:40 
AnswerRe: thread.interrupt only working once Pin
davidnz8-Apr-11 12:13
davidnz8-Apr-11 12:13 
AnswerRe: thread.interrupt only working once Pin
Ganesh Kumar Kaki13-Apr-11 1:27
Ganesh Kumar Kaki13-Apr-11 1:27 
QuestionGlobal Hook : need help with SysMsgProc Pin
moums8-Apr-11 8:12
moums8-Apr-11 8:12 
QuestionQuerying LDAP from an application: get a search result when one attribute of a multiple attribute matches Pin
Bernhard Hiller8-Apr-11 1:28
Bernhard Hiller8-Apr-11 1:28 
AnswerRe: Querying LDAP from an application: get a search result when one attribute of a multiple attribute matches Pin
Ravi Bhavnani8-Apr-11 9:10
professionalRavi Bhavnani8-Apr-11 9:10 
QuestionWindow 7 and WebClient Class Pin
Wolfram Steinke7-Apr-11 17:32
Wolfram Steinke7-Apr-11 17:32 
AnswerRe: Window 7 and WebClient Class Pin
Bernhard Hiller7-Apr-11 21:58
Bernhard Hiller7-Apr-11 21:58 
GeneralRe: Window 7 and WebClient Class Pin
Wolfram Steinke9-Apr-11 0:20
Wolfram Steinke9-Apr-11 0:20 
AnswerRe: Window 7 and WebClient Class Pin
#realJSOP8-Apr-11 8:07
professional#realJSOP8-Apr-11 8:07 

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.