Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit number of users in c# application

I am developing a Client-Server application using C#. Basically the server is a SQL server and the clients are developed in C#. What I would like to know is the best way (if any) to limit the number of users using the application at any one time - say I wish to limit to two users. Would I limit their access to SQLserver?

like image 532
Vinit Avatar asked Dec 21 '12 12:12

Vinit


People also ask

How do I limit the length of a string in C?

You need to specify a precision (number after the dot '. ') in the %s format parameter to limit the size of the string printed. A precision field is a non-negative number that specifies the number of characters to print. Using this format string, the string passed by str will be truncated after five characters.

How do you limit inputs in CPP?

Simply replace 1, and 10 with your min and max desired input. This will loop and ask for input to T for as long as the input is less than the minimum or greater than the maximum desired value. Should probably put the whole input-operation in a loop condition as well.


2 Answers

You will potentially need the concept of a "session" to identify the concurrent number of users.

If want this to be done in a fail-safe manner, you will have to introduce an application layer between your DB server and the client. You can then provide methods to login and logoff for users.

At every login you will need to increment a count of "concurrent users" and at every logoff you will need to decrement.

You may need to introduce the concept of session time-out as the some of the clients may shutdown without invoking the logff method.

The number of concurrent users allowed can be associated with a license.

like image 65
coder_bro Avatar answered Sep 29 '22 09:09

coder_bro


Use "currentUser" table to store current users logging into the system concurrently.

When the user login, check the row count if the max no. of rows has reached.

Remove the respective row when the user leaves the system. In that way, you may also restrict using the same user ID to login from different computers as well.

like image 28
Nyi Nyi Avatar answered Sep 29 '22 11:09

Nyi Nyi