Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: NT
Expertise: Beginner
Jan 11, 1999

VB & NT

Question:
How do I change the current user logged in the NT box programatically from the client without rebooting it?

Answer:
The short answer is that you can't. If you want to change the current logged-on user, you must logoff of NT (not necessarily reboot) and logon as the new user. The code below will do that. If what you want to do is change the user for a specific proces*, then there are other options. The API option is good, but goes fairly deeply into actively VB-unfriendly calls, involving logging on to the server or local machine programmatically via LogonUser, then programmatically set each process to this new set of user credentials. If you only want to run one or two programs with enhanced security, you can use the SU.EXE program (available with the NT Resource Kit). This creates some security holes, but it is a possible solution.


Private Const EWX_LOGOFF As Long = 0&
Declare Function ExitWindowsEx _
   Lib "user32" _
   (ByVal uFlags As Long, _
    ByVal dwReserved As Long) As Long

Public Sub LogOff()
   Dim p_lngRtn            As Long
   Dim p_lngFlags          As Long
   
   p_lngFlags = EWX_LOGOFF
   p_lngRtn = ExitWindowsEx(p_lngFlags, 0&)

End Sub
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap