如何将凭据传递给 httpwebrequest 以访问 SharePoint 库 [英] How to pass credentials to httpwebrequest for accessing SharePoint Library

查看:26
本文介绍了如何将凭据传递给 httpwebrequest 以访问 SharePoint 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 HttpWebRequest 从 SharePoint 文档库读取文件.为了做到这一点,我必须通过一些凭据.我正在使用以下请求:

I'm trying to read files from a SharePoint document library using HttpWebRequest. In order to do that I have to pass some credentials. I'm using the below request:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/msexcel";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";
request.Credentials = new NetworkCredential(UserName, PassWord);

这是传递凭据的正确方法吗?

Is this the correct way to pass credentials?

推荐答案

您也可以使用:

request.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; 

这篇关于如何将凭据传递给 httpwebrequest 以访问 SharePoint 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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