发送HTTP头使用HTTP的Web请求NTLM验证 [英] Sending HTTP Headers with HTTP Web Request for NTLM Authentication

查看:744
本文介绍了发送HTTP头使用HTTP的Web请求NTLM验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要登录到一个SharePoint门户,它会弹出一个登录对话框,但使用NTLM身份验证。如何修改HTTP头在C#中做一个成功的登录请求?我想我需要做的HttpWebRequest到页面内的登录门户网站的部分和后期的HTTP标头集合一起的?

I want to login to a Sharepoint portal which brings up a login dialog but is using NTLM authentication. How can I modify the HTTP headers in C# to make a successful login request? I assume I would need to make a HTTPWebRequest to a page within the logged in section of the portal and post the HTTP headers collection alongside this?

推荐答案

您可以使用WebRequest类做到这一点。

You can do this using the WebRequest class.

WebRequest req = WebRequest.Create(tokenUri);
req.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
req.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
WebResponse resp = req.GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream());
var token = reader.ReadToEnd().Trim();

这code读取整个反应到一个名为变量标记

This code reads the whole response into a variable called token.

这篇关于发送HTTP头使用HTTP的Web请求NTLM验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆