我正在使用 DPAPIProtectData
如下:
var temp = new byte[32]
{
1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,3,
3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4
};
ProtectedData.Protect(temp, null, DataProtectionScope.CurrentUser);
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
让我们假设现在 temp 看起来像:
temp = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,....31 };
我想从 .exe 文件以及我的 WebService (IIS) 执行此代码。
问题是,如果我从 exe 运行代码,则当前用户是MyDomain/Administrator
,如果我从 WebService 运行代码,则当前用户是IIS APPPOOL/MyApp
.
我该如何解决这个问题?我正在尝试从WebService
.exe 文件运行,如下所示:
Process.Start(@"C:\myexe.exe");
但是由于某种原因它不起作用(我可以完全访问我的 iis 应用程序),无论如何我认为这不是这种情况下的正确解决方案。
注意:出于安全原因,我无法从更改DataProtectionScope.LocalMachine
为DataProtectionScope.CurrentUser