user1422348
user1422348

Reputation: 355

Impersonate remote user in vb.net to access MS SQL Server

I'm trying to impersonate a domain user over vpn. I am able to run management studio from the command prompt using the RUNAS command. However, I can't do the same with my vb application (.net 4.5, winforms, using VS 2012 Express) in either debug mode or published app. Here is what I tried:

Does anyone have any explanation for these errors and/or how I might solve this. I'm assuming that if I can impersonate and run ssms, I should be able to do it within my vb app.

Thanks in advance!

Upvotes: 1

Views: 1100

Answers (1)

user1806955
user1806955

Reputation: 36

This is a bit of a leap but - particular parts of Windows can only run once and are not allowed to have multiple instances from different users. I wonder if this is the issue here. I'm thinking particularly of explorer.exe. If this sounds like it might be what's tripping up the RUNAS method, try:

  1. start a new cmd window as the user by running: runas /noprofile /user:domain\user cmd
  2. open taskmanager and kill the explorer.exe process (you'll loose your start bar when you do this)
  3. in the cmd window type: explorer.exe
  4. The start bar and windows will come back and be running as the other user

Now try your application. When you're done be sure to switch back by:

  1. open taskmanager (this will be running as the other user)
  2. Kill the explorer.exe process
  3. press ctrl alt del and then click task manager (this should make it run as you)
  4. in taskmanger, click file - new task
  5. type: explorer.exe
  6. Everything should now be back to normal.

Upvotes: 2

Related Questions