我正在尝试登录使用 Windows 集成 (NTLM) 身份验证的 SharePoint 网站。有两种方法可以输入 SharePoint 网站的凭据:Windows 身份验证和表单例份验证。
但是,此特定网站上禁用了表单例份验证,我只能使用 Windows 身份验证。 有没有办法让我使用与登录 Windows 计算机时不同的凭据登录此网站?
请参阅此处的错误:Form authentication denied
String site = "http://sharepoint/";
ClientContext context = new ClientContext(site);
context.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
FormsAuthenticationLoginInfo formsAuthInfo = new FormsAuthenticationLoginInfo("MyUser", "MyPassword");
context.FormsAuthenticationLoginInfo = formsAuthInfo;
// The SharePoint web at the URL.
Web web = context.Web;
// We want to retrieve the web's properties.
context.Load(web);
// Execute the query to the server.
context.ExecuteQuery();
InitializeComponent();
我也尝试过使用: context.Credentials = new NetworkCredential("用户", "通行证", 站点);
ClientContext context = new ClientContext(site);
context.Credentials = new NetworkCredential("user", "pass", site);
// The SharePoint web at the URL.
Web web = context.Web;
// We want to retrieve the web's properties.
context.Load(web);
// Execute the query to the server.
context.ExecuteQuery();
InitializeComponent();
我收到以下 401(未经授权)error
最佳答案
不要将 ClientContext
对象的 AuthenticationMode
属性更改为 FormsAuthentication
,而是尝试设置该对象的 Credentials
属性到有效的网络凭据对象。
ClientContext context = new ClientContext("http://sharepointsite/");
context.Credentials = new NetworkCredential("username","password","domain");
关于c# - 使用客户端对象模型的 Sharepoint 2010 用户身份验证(Windows 凭据),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34773547/