Authentifizierung Netzwerk-Anmeldeinformationen für den Zugriff auf SharePoint-Website auf der client-Objekt-Modell

Ich arbeite an der kleinen app, die erforderlich ist, um alle Benutzer in allen Gruppen bestimmten Ort. Ich habe zwei Seiten; SharePoint 2010 läuft auf premisses und SharePoint 2013 online. Ich bin immer Anmeldeinformationen Fehler...

{"The remote server returned an error: (401) Unauthorized."}

code.

 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();

    }

InformationsquelleAutor Toxic | 2014-07-24

Schreibe einen Kommentar