saw-lau
saw-lau

Reputation: 415

Can I Change the Logged-In (Windows) User While an Application is Running?

Let's say we have an application that has a number of features and each feature as a permission set of users that are allowed to use that feature. The application is designed to be always-on, but at different times during the day we want different users to log on and use it.

Rather than reinvent the wheel and create yet another user account and password system, we'd like to use built-in Windows user accounts (for authentication) and Windows groups (for feature access).

Is it possible to leave the application running but have different users come along and log in and log out of the application without logging out of the Windows session?

Upvotes: 0

Views: 361

Answers (2)

Dirk
Dirk

Reputation: 31053

There is a mechanism called Impersonation (link points to .NET documentation, but the core Windows APIs provide similar features). It allows you to programmatically run code in a context of a different user than the one currently being logged in. There are, however, other security implications to the model you describe. In particular: how do you protect the rest of the workstation your program is running on?

Upvotes: 2

EBGreen
EBGreen

Reputation: 37730

Well, you could certainly have the application get the user's windows credentials. You could also simply query for group membership without requesting any credentials. More specific information will help with a more specific answer. For instance, what language are you working in?

Upvotes: 0

Related Questions