Ken

Ken

  • NA
  • 1
  • 0

How to logout users from a windows service without knowing their name and password.

Apr 3 2007 3:34 AM
I've been beating my head against the wall over this, and am only able to find very little information pertaining to my problem.  I am writing a service in Visual Basic .net that will monitor an internet connection.  If the internet connection goes down I want it to logoff any user currently logged on.  My problem is this.  I have found out how to logoff the current user with the ExitWindowsEx API.  And from reading I think that the secret to logging off another user on the system is by impersonating that user and then running the ExitWindowsEx API call under that user context.  However, I can not figure out how to impersonate a user (as an administrator) without using the LogonUser API that requires a name and password.  How do I obtain user tokens for users that are currently logged in, or any user for that matter, without a name and password if I have administrator rights?

I know there has got to be a way to log out a user programmatically from a program or service that is running under the context of the administrator, or system, etc... Please help.