C# 如何从高完整性(admin)进程调用IEGetProtectedModeCookie API?
我需要从一个高完整性(admin)进程调用IE8IEGetProtectedModeCookieAPI。每当我从Azure webapp调用此API时,我都会收到错误\u无效\u访问。我在很多地方读到,高完整性进程无法调用此API,但就我而言,我需要以提升的权限运行Azure沙盒C# 如何从高完整性(admin)进程调用IEGetProtectedModeCookie API?,c#,internet-explorer,cookies,protected-mode,C#,Internet Explorer,Cookies,Protected Mode,我需要从一个高完整性(admin)进程调用IE8IEGetProtectedModeCookieAPI。每当我从Azure webapp调用此API时,我都会收到错误\u无效\u访问。我在很多地方读到,高完整性进程无法调用此API,但就我而言,我需要以提升的权限运行Azure沙盒 [DllImport("ieframe.dll", CharSet = CharSet.Unicode, EntryPoint = "IEGetProtectedModeCookie", SetLastError
[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;
}
有没有办法从较低级别的完整性过程调用此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;
}