Problem:
I was getting error Permission denied while Adding Binding in IIS. After spending long time come to know that its using
NTAuthority\IUSR as a identity that's I am getting that error. To reolve that I have used below solution
Solution:
using (WindowsIdentity newId = new WindowsIdentity(safeTokenHandle.DangerousGetHandle()))
{
using (WindowsImpersonationContext impersonatedUser = newId.Impersonate())
{
// Check the identity.
Console.WriteLine("After impersonation: "
+ WindowsIdentity.GetCurrent().Name);
}
}
For More detail refer this: https://msdn.microsoft.com/en-us/library/w070t6ka%28v=vs.110%29.aspx