Solved

c# SharePoint 2010

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Media Player 2 26
Set value of dynamically created checkboxlist 2 34
how to check to see if datatable has headers or not 2 29
VB.NET 2008 - SQL Timeout 9 24
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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