Can't get impersonation to work

From: ECrawford (ECrawford_at_discussions.microsoft.com)
Date: 06/23/04


Date: Wed, 23 Jun 2004 10:42:01 -0700

I have a .Net application and one of my ASP pages exports a Crystal Reports file to a network drive. The problem is that when Crystal exports the file, it uses the ASPNET user account, which doesn't have access rights to the network drive.

I want to impersonate the authenticated user when I do the export, but it doesn't seem to work. When I run the app, FileMon shows that it is still using ASPNET.

I have tried adding the <identity impersonate="true" userName="validuser" password="validpass"/> to my web.config file, but that doesn't work either. I did think I had this working yesterday, but today it doesn't seem to be ?!?!

I have also tried the following code:

currentWindowsIdentity = CType(User.Identity,System.Security.Principal.WindowsIdentity)
        impersonationcontext = currentWindowsIdentity.Impersonate()

        ReportName.Export()

impersonationcontext.Undo()

This shows the impersonation elements to be the same as the authenticated user, but the app still blows up and FileMon still shows ASPNET as the user.

What am I doing wrong?!?!?!

THanks,
Ed