Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从高完整性(admin)进程调用IEGetProtectedModeCookie API?_C#_Internet Explorer_Cookies_Protected Mode - Fatal编程技术网

C# 如何从高完整性(admin)进程调用IEGetProtectedModeCookie API?

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

我需要从一个高完整性(admin)进程调用IE8IEGetProtectedModeCookieAPI。每当我从Azure webapp调用此API时,我都会收到错误\u无效\u访问。我在很多地方读到,高完整性进程无法调用此API,但就我而言,我需要以提升的权限运行Azure沙盒

  [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;
  }