Solved

c# SharePoint 2010

Posted on 2014-12-17
4
161 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
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
Comment Utility
Are you using Kerberos?
0
 

Author Comment

by:Demosthenes
Comment Utility
Yes
0
 
LVL 31

Accepted Solution

by:
Jamie McAllister MVP earned 500 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
System.InvalidCastException: Specified cast is not valid 10 46
Check my code out(2) 1 23
Create XML 5 30
Sharepoint KB 1 15
Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now