C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-26-2009, 12:33 PM   #1
Registered User
 
Join Date: Aug 2009
Posts: 2
Question How to programatically Logoff interactive user and Logon as another [C#]

Is there a way to force a logoff (knowing this is not recommended) of the current interactive (logged-on) user and then login with a new user account (interactive - not using stuff like LogonUser and other impersonation tricks) to simulate someone physically pressing LOGOFF and then selecting a new account to LOGON...?

The issue is that my service creates a new user account programatically - and I need to find a way to create its corresponding user profile. From what I can see the only way that works would be to physically logoff the current user, and then login as the new user (which will create the User Profile for HKCU, Documents & Settings, etc...). Sounds a little crazy but I can't find a better way...

So, I need to find a way to programmatically force the logoff & logon actions (from my running Windows Service under LocalSystem) - I have all the credentials and access rights needed ... Are there system function calls I can use?

For Logoff I think I can use WTSLogoffSession(...), still trying to get it to work but seems promising - however I have no clue what to do about logon...
Alternitively if there is a better approach to solve my problem I am all ears :)

Any help or hints would be much appreciated...
Thanks,
Shaitan00 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 10:46 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22