Impersonation Problem on Windows XP

Posted on 2007-07-30
Last Modified: 2013-12-04
I have a program that uses impersonation. On one clients pc, it doesn't work. The operating system is Windows XP, SP2.
I thought the issue was with report viewer, but it seems more to do with impersonation.
I ran some test programs, and this is what happens:
1) Reports without impersonation work fine

2) Programs with impersonation generate temp dll files, and then reports won't launch as I get a message about
'C:\Documents and Settings\theusername\Local Settings\Temp\expression_host_abc12324334435435435.dll in use by another process'

3) And now the freaky one. I wrote a simple program that just prints the contents of a folder to a report. Added a tick box, so that Impersonation can be turned on/off. With Impersonation off, everything ok. Turn impersonation off, and I get the '....dll in use by another process' message above.
However, once that message is generated, the program will never run again! Even if I reboot the pc. Or remove and re install the program. Once impersontation has been used, it won't run again, even if don't use impersonation again.

This one is really baffling me. I know that on Win 2000 pcs, local security settings had to be changed to get impersonation to work. But I haven't read anything similiar for Windows XP.
Any help appreciated!

Question by:jdhackett
    LVL 16

    Expert Comment

    Are you using the WindowsIdentity.Impersonate method in the .net or something else?

    I know you must stop the impersonation of the user.  If i'm not mistaking weird things can happen if you don't.

    Is it just this one pc that is not working?  Also are the other pc's windows xp also and do they work fine on those?
    LVL 1

    Author Comment

    My code is at

    Just one pc, works fine on the other pcs, most of which are xp.
    I do stop the impersonation after I fill my datasets. As you say, otherwise flaky things happen.
    What I really don't get is how using impersonation once stops that program from ever working again.
    LVL 16

    Accepted Solution

    Since it's working fine on other pc's then I would almost bet you could rule out it being your code.  It doesn't really make sense that once you impersonate and release it that the program stops working even after you reboot.

    I would probably try and compare the settings of the working pc to this one you are having trouble with.  gpedit.msc or local security policy for starters, all updates to windows and the .net framework as well.

    I've fiddled with impersonation some, but i've never had the problem you are experiencing right now though.
    LVL 1

    Author Comment

    I've checked that all the windows updates are installed. As far as I know, windows updater pulls down all the latest dotnet updates anyway.
    I've also checked the security policy, looks the same as the others. Not sure what else I can do.
    LVL 1

    Author Comment

    I still don't have a solution to this issue. However, I do appreciate kshays suggestions, the gpedit.msc was new to me, and very useful. In fact, it helped me solve a different issue. In this case, it has at least ruled out what the problem this could be.
    To reflect this, I've now given kshays a C grade. I'll update here if I ever find a solution.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Many of us in IT utilize a combination of roaming profiles and folder redirection to ensure user information carries over from one workstation to another; in my environment, it was to enable virtualization without needing a separate desktop for each…
    This is a short article about OS X KeRanger, and what people can do to get rid of it.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now