Ah, now it works in IIS on Windows 7 but not on Windows Server 2008, it throws the following exception:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
If I switch the application pool identity to Local Service it works again ... which is the difference between windows 7 and windows 2008?
.Net has a WindowsIdentity feature that can be used in a WindowsImpersonationContext but I can't get the local service login.
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
If I switch the application pool identity to Local Service it works again ... which is the difference between windows 7 and windows 2008?
.Net has a WindowsIdentity feature that can be used in a WindowsImpersonationContext but I can't get the local service login.
//this doesn't work, there isn't a local service login
using (var context = new WindowsIdentity(@"NT AUTHORITY\LOCAL SERVICE").Impersonate()) { }