我需要从高完整性(管理员)流程中调用IE8 IEGetProtectedModeCookie API。每当我从Azure webapp调用此API时,我都会收到 ERROR_INVALID_ACCESS 。我已经在很多地方看到高完整性进程无法调用此API,但在我的情况下,我需要以提升的权限运行Azure沙箱。
有没有办法从较低级别的完整性过程调用此API?对于Azure沙箱,我被迫以提升的权限运行我的webapp。
[DllImport("ieframe.dll", CharSet = CharSet.Unicode, EntryPoint = "IEGetProtectedModeCookie", SetLastError = true)]
public static extern int IEGetProtectedModeCookie(String url, String cookieName, StringBuilder cookieData, ref int size, int flag);
private static string GetProtectedModeIECookieValue(string cookieName)
{
String r = String.Empty;
int iSize = 4096;
StringBuilder sbValue = new StringBuilder(iSize);
Uri reqUri = HttpContext.Current.Request.Url;
string baseUrl = String.Format(@"{0}://{1}", reqUri.Scheme, reqUri.Authority);
int hResult = IEGetProtectedModeCookie(baseUrl, cookieName, sbValue, ref iSize, 0);
if (hResult == 0)
{
string[] parts = sbValue.ToString().Split('=');
r = parts[1];
HttpContext.Current.Response.Write(r);
}
else
{
//HttpContext.Current.Response.Write("Failed to get cookie. HRESULT=0x" + hResult.ToString("x") + "\nLast Win32Error=" + Marshal.GetLastWin32Error().ToString());
}
return r;
}