programmatically log on / log off users
- From: "Stephan Steiner" <stephan.steiner@xxxxxxxxxxxxx>
- Date: Mon, 19 Feb 2007 15:55:41 +0100
Hi
I have service running under the service account. I'd like it to perform the
following functions:
1) Check if a certain user (based on his username and domain) has an active
session, be it on the local console or via terminal service.
2) If the user has a session, I'd like to terminate that session (no
questions asked, regardless of whether the user still has a document open)
3) Then I'd like to make sure that another user is logged in via local
console, so when you get to the machine, no login and password has to be
provided.
I know that ExitWindowEx can be used to log out the current user, but so far
I only have experience in doing this from the system console (so the app
executing the code is running on the logged on user's permission set) -
would it work from a service as well and if there are multiple active
sessions (suppose an admin logged on via console, then another user tried
via remote desktop and the admin allowed access resulting in two sessions on
the machine with the user's session being the active one) which session
would be logged out?
As far as logging in goes, I found LogonUser. I've written a small
commandline app which calls LogonUser with valid credentials, and
dwLogonType set to LOGON32_LOGON_INTERACTIVE. I get a positive response, yet
besides that nothing happens. When launched from the local console,
shouldn't that result in the current user being logged out and the new user
being logged in?
Last but not least I'm rather clueless as to listing active sessions so I'd
appreciate any tips.
Regards
Stephan
.
- Prev by Date: Re: HELP !!! User cannot log into the Terminal Server
- Next by Date: Disable The Plug-and-play for new USB storage devises
- Previous by thread: Re: HELP !!! User cannot log into the Terminal Server
- Next by thread: Disable The Plug-and-play for new USB storage devises
- Index(es):
Relevant Pages
|