Limit number of users in c# application
Asked Answered
A

3

7

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?

Arty answered 21/12, 2012 at 12:46 Comment(3)
Are you doing this for licensing issues? And, dont you have any other app server in between ?Dysuria
Yes sir, I am doing this for licencing as well as i want to give access of my application to limited clients. I don't have any other app server in between. My Sql Server database is on one machine(called database server) and my application code is on client machine. I doesnot know how to give access to limited clients.Sorry for my English.Thanks for replyArty
"want to give access of my application to limited clients" Can you explain this in your question further. This goes beyond licensing, which would have been easier to manage with a simple count.Dysuria
S
2

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.

Spinnaker answered 21/12, 2012 at 12:59 Comment(1)
Note that with this kind of counting you should only create a single connection from each client. This can easily make the building of the application quite hard.Azole
C
1

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.

Coleencolella answered 21/2, 2013 at 18:56 Comment(0)
A
0

You could simply sell individual licences.

Create the application in a way that it checks its licence on a trusted server (could be the SQL Server).

Sell a licence per computer/user.

This way you could easily scale to more than 2 users if needed.

It is also possible to implement floating licences: everytime a user tries to obtain a licence it is only given when available. Of course the licence will have to be 'freed' after a disconnect or time-out. In this scenario you need a server that contains a number of licences and a trusted service that hands them out.

In the Winforms application you would simply check for the licence on startup and you could extend the timeout everytime the user does something significant (such as querying the database or clicking a menu item)

Azole answered 21/12, 2012 at 12:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.