使用 Microsoft Windows 身份验证进行连接
以下示例示出了在 .NET 控制台应用程序中使用 Microsoft Windows 身份验证连接至 Qlik NPrinting Server 的一种方式。请记住将 server.name.com 替换为您的实际 Qlik NPrinting Server 名称。
static void Main(string[] args) { //Create the HTTP Request (authenticate) and add required headersServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@ "https://server.name.com:4993/api/v1/login/ntlm"); request.Method = "GET"; request.UserAgent = "Windows"; request.Accept = "application/json"; // specify to run as the current Microsoft Windows user request.UseDefaultCredentials = true; try { // make the web request and return the content HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader responseReader = new StreamReader(response.GetResponseStream()); string sResponseHTML = responseReader.ReadToEnd(); Console.WriteLine(sResponseHTML); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }