Here's some more info.
When running the site using impersonation of my account through web.config <identity impersonate="true" username="domain\xyz" password="xyz"> my site works fine. However, when I use programmatic impersonation, as described in MSDN or http://west-wind.com/weblog/posts/1572.aspx it wont work right
using Web.Config Impersonation
WindowsIdentity.GetCurrent.Name: domain\xyz
Environment.UserName: xyz
User.Identity.Name : domain\bkimuser
everything works.
Using programmtic impersonation and setting web.config <identity impersonate="true>
page starts with
WindowsIdentity.GetCurrent.Name: domain\bkimuser
Environment.UserName: bkimuser
User.Identity.Name : domain\bkimuser
impersonates to
WindowsIdentity.GetCurrent.Name: domain\xyz
Environment.UserName: xyz
User.Identity.Name : domain\bkimuser
fails database connection
reverts to
WindowsIdentity.GetCurrent.Name: domain\bkimuser
Environment.UserName: bkimuser
User.Identity.Name : domain\bkimuser
it looks like I impersonate properly but I still can't connect to the database properly unless I impersonate the user from the beginning???
Is there any difference between impersonating through web.config or using temporary impersonation on the page that requires it?