Solved

c# SharePoint 2010

Posted on 2014-12-17
4
166 Views
Last Modified: 2014-12-18
The code below works when I point it to two of my three SharePoint servers.  My third server I get 401 error.  Any ideas anyone ?

    private void button3_Click(object sender, EventArgs e)
      {
        label3.Text = "";
        try
        {
          treeview1.Nodes.Clear();
          ClientContext clientContext = new ClientContext(comboBox1.Text);
          Web oWebsite = clientContext.Web;
          ListCollection collList = oWebsite.Lists;
          clientContext.Load(collList);
          clientContext.ExecuteQuery();
          foreach (SP.List oList in collList)
          {
            TreeNode listnode = new TreeNode();
            listnode.Text = oList.Title;
            treeview1.Nodes.Add(listnode);
          }
        }
        catch (Exception ex)
        { label3.Text = ex.Message; }
      }  

Open in new window

0
Comment
Question by:Demosthenes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 40505501
Are you using Kerberos?
0
 

Author Comment

by:Demosthenes
ID: 40505537
Yes
0
 
LVL 31

Accepted Solution

by:
Jamie McAllister MVP earned 500 total points
ID: 40505606
I've heard of this one but happily not experienced it myself. Incorrect Kerberos config causing custom code to fail authentication on one WFE but not others.

These are the closest resources I can find to addressing this;

http://www.bryansgeekspeak.com/2010/11/sharepoint-2010-on-windows-server-2008.html

http://sharepoint.aspcode.net/view/63539928672422258266802/why-does-kerberos-authentication-fail

http://technet.microsoft.com/en-us/library/gg502602(v=office.14).aspx
0
 

Author Closing Comment

by:Demosthenes
ID: 40507956
Through reading these articles I installed Fiddler, and watched my transaction.  Something about the hostname looked odd to me so I used IP address instead.  Code now works.  The hostname of course works when you put it in a browser, but not in my code.  

"http://sp1" is a browsable sharepoint server, but this line doesn't like it:
ClientContext clientContext = new ClientContext(comboBox1.Text);

I am having my server team put in a nice DNS entry for the server.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question