I have a .NET Windows Form application that users run as admin since it requires specific access to files.
The app has been working fine for years but we need to add a feature where users can generate email from inside the application using Microsoft.Office.Interop.Outlook.
As soon as we call "new" on the Outlook object, it blows up with the following error:
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
This is because MS Outlook is running without elevated privileges by default and the Windows Form app is running with elevated privileges but COM+ can't handle this setting.
So I need a way to call the .NET Outlook code as the current user but with less elevated privileges.
I have looked at the WindowsIdentity Class but it does not seem to work. I need someway to run a method or block of code as the current user but with less elevated privileges.