validation网络凭据以访问客户端对象模型上的SharePoint站点
我正在使用小应用程序,这需要将所有用户都带到给定站点的所有组中。 我有两个网站; SharePoint 2010在线运行和SharePoint 2013在线运行。 我收到凭据错误…
{"The remote server returned an error: (401) Unauthorized."}
码。
public class Program { static void Main(string[] args) { string _siteURL = "https://intranet.co.uk"; NetworkCredential _myCredentials = new NetworkCredential("user", "password", "https://intranet"); ClientContext _clientContext = new ClientContext(_siteURL); _clientContext.Credentials = _myCredentials; Web _MyWebSite = _clientContext.Web; GroupCollection _GroupCollection = _MyWebSite.SiteGroups; _clientContext.Load(_GroupCollection); _clientContext.Load(_GroupCollection, groups => groups.Include(group => group.Users) ); _clientContext.ExecuteQuery(); foreach (Group _group in _GroupCollection) { Console.WriteLine("Group Id " + _group.Id + " Group Title " + _group.Title); UserCollection _userCollection = _group.Users; foreach (User _user in _userCollection) { Console.WriteLine("Group ID: {0} Group Title: {1} User: {2} Login Name: {3}", _user.Title, _user.LoginName); } Console.WriteLine("n......................................."); } Console.Read(); }
您的凭据是错误的,特别是您的域名。
NetworkCredential _myCredentials = new NetworkCredential("user", "password", "https://intranet");
您的useraccount被指定为domainusername
,我怀疑您的域名将是https://intranet
,而不是companyname
。 如果您不确定,请询问您的Exchange管理员。
您正在寻找的是类似于此的东西:
上述就是C#学习教程:validation网络凭据以访问客户端对象模型上的SharePoint站点分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
NetworkCredential _myCredentials = new NetworkCredential("user", "password", "companydomain"); //OR NetworkCredential _myCredentials = new NetworkCredential(@"companydomainuser", "password");
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1010601.html