【发布时间】:2016-04-18 19:58:18
【问题描述】:
我正在尝试登录到使用 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("user", "pass", site);
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
【问题讨论】:
-
到目前为止,您还没有提供任何您尝试过的代码。您在寻找非代码解决方案吗?在 Windows 7 中,您可以使用与登录时不同的 Windows 凭据运行应用程序,方法是按住 Shift 并右键单击可执行文件,然后选择“以不同用户身份运行”
-
您好,感谢您的评论。我已经包含了我的代码。另外,我运行的是 windows server 2008 R2 Standard,而不是 windows 7。
标签: c# authentication sharepoint ntlm sharepoint-clientobject