Solved

c# SharePoint 2010

Posted on 2014-12-17
4
170 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 32

Expert Comment

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

Author Comment

by:Demosthenes
ID: 40505537
Yes
0
 
LVL 32

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

719 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