none
Impersonation not working on Windows 7? RRS feed

  • Question

  • Hi,

    I'm using Visual Basic 2008 and I've written a very handy little app that takes care of serveral  admistrative tasks when our company gets a new project. I won't get into all the features but one of the tasks that it performs is setting up a new project folder structure on our file server with a predefined set of subfolders and it also sets user permisions on the subfolders.

    Under Windows XP it worked great and saved me tons of time. It made me giggle everytime I used it in the past becuase it would save me so much time doing these simple but time consuming tasks.

    Now my computer is a Windows 7 Pro machine and the only way I can get the exe to run is to right-click the .exe and choose RUNAS administrator. I'm already a domain administrator so why I would need to do this is silly and annoying. In my code I already included a RunAs_Impersonator class so that anyone could use the app which worked great until windows 7.

    The RunAs_Impersonator class that I use can be found here:

    http://www.tek-tips.com/viewthread.cfm?qid=1235871

    I recently needed to make some additions to the program's but when I try to debug it, when it gets to the portion of trying to create the folders on the server, the program breaks and makes claims that I don't have the rights to do so. BUT I DO WINDOWS 7!! I DO! and my RUNAS class uses our domain's Administrator credentials anyway which of course has permissions to make new folders at that location.

     Question1 - What do I need to do so I can run my app on Win7 (Sp1) without having to right-click and choose RUNAS Admin?

    Question2 - how can I debug my app? I haven't tried right clicking on Visual Studio and selected the RUNAS thing so I'll try that next but this is just silly when I'm already King of my Domain!

    Thanks in advance for any advice you can spare.

     

    Friday, February 25, 2011 5:50 PM

Answers

  • Deleted
    • Marked as answer by Chigrboy Friday, February 25, 2011 7:40 PM
    Friday, February 25, 2011 7:20 PM
  • Dear ChigrBoy, 

    Ad 1.  What do I need to do so I can run my app on Win7 (Sp1) without having to right-click and choose RUNAS Admin?

    I'm not a big fan of the UAC either. Here is a good tutorial on how to always run your .Net app as an administrator.

    Ad 2. how can I debug my app?

    Make use of "Try / Catch " and nest them if needed. Then log the exceptions thrown to a logfile.

    Cheers,

    John

    • Marked as answer by Chigrboy Friday, February 25, 2011 7:40 PM
    Friday, February 25, 2011 7:21 PM

All replies

  • Jordan,

    Thanks so much for quick and in-depth reply.

    My appologies for the vagueries of question 2. By debug, I mean that I need to get the code to execute during a debug session without throwing an exception. The exception in this case is that I don't have the proper access rights to the directory in which my app is generating the folder structure, which I, of course have rights to that directory and so does the impersonated Adminstrator account. I belive this exception is due to the fact that I'm using a Win7 computer and mirrors the same problem I have when trying to run the apps .exe file without doing the right-click > RUNAS > ADMINISTRATOR first.

    hopefully that helps to clarify.

    Is there a way to turn off this "feature" globally in Windows 7. Tell Microsoft that I promise not to let my buddy joe (or anyone else for that matter) use my computer. :)

    Friday, February 25, 2011 6:49 PM
  • Dear ChigrBoy, 

    Ad 1.  What do I need to do so I can run my app on Win7 (Sp1) without having to right-click and choose RUNAS Admin?

    I'm not a big fan of the UAC either. Here is a good tutorial on how to always run your .Net app as an administrator.

    Ad 2. how can I debug my app?

    Make use of "Try / Catch " and nest them if needed. Then log the exceptions thrown to a logfile.

    Cheers,

    John

    • Marked as answer by Chigrboy Friday, February 25, 2011 7:40 PM
    Friday, February 25, 2011 7:21 PM
  • Thanks Jordan and a firm Hi-YA! to you Mr. Bravo~!

    UAC...I understand why it's good in general but it was the thorn in my proverbial programmers posterior this time.

    I disabled it and my program runs / and debugs they way it should now. The event that I needed to debug did have try/catches which were catching the UAC caused "Access denied error" but then wasn't getting to my new coding so I couldn't see if it was/wasn't working so I commented out the try/catches...anyway, you don't care to hear all this...It just works now.

    John, I will read the link that you sent. Thank you for that.

    Jordan, I promise I'll be careful while UAC is disabled. I'll reenable it when I'm done with my programming tasks (probably...).

    Chigrboy

    Friday, February 25, 2011 7:53 PM