Core 2.0 mvc impersonation do not work when deploy to IIS

  • Thread starter Thread starter Alejandro DeParisVip
  • Start date Start date
A

Alejandro DeParisVip

Guest
Hi all!

I built an mvc core 2.0 web application. I need to store file in shared folder, and only current windows user has rights to save. So i need impersonate default appPool user to current domain user in internet explorer.

I try this:


var user = (System.Security.Principal.WindowsIdentity)HttpContext.User.Identity;
log.Append($"WindowsIdentity.GetCurrent(): " + System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() + "\r\n");
System.Security.Principal.WindowsIdentity.RunImpersonated(user.AccessToken, () =>
{
log.Append($"Impersonated as: " + System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() + "\r\n");
new DiaDoc.Bll.Process(fileData, log);
});

Local all works ok, but when i publish application to IIS 7 and run my app i get an error: user can't access to folder. But by other hand seems that impersonation works, because
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() after impersonation change to current user name. I think in IIS level impersonation don't realy work.

Help me please! )) I just don't know what to do.

Continue reading...
 
Back
Top