Vra

I'm trying reference a sharepoint list item in my aspx page using the Sharepoint Client Object Model. I have been granted 'Full Control' privileges on this list. The problem is that I can only complete the request when I set the ClientContext.Credentials explicitly with my password hard-coded into the page. Obviously I don't want visitors to my site to have the access to things based on my credentials.

This gets it to work but does not meet the project requirements:

ClientContext cc = new ClientContext("http://sharepoint.site.com/sitename");
cc.Credentials = new NetworkCredential("username", "password", "domain");

I have set in the web.config and seems to be working fine. When I check WindowsIdentity.GetCurrent().Name it shows my correct "domain\username" information, which I think should mean my credentials are valid. Why then, is SharePoint rejecting the cc.ExecuteQuery(); with a "System.Net.WebException The remote server returned an error: (401) Unauthorized."?

I can put a textbox on the screen that lets the user enter their password to used to create a NetworkCredential object, but I can tell you right now the customer (my Boss) is not going to be happy with this and is going tell me he wants me to find a work around.

Edit: The sharepoint site is hosted on a different site, but within the same company intranet.

Was dit nuttig?

Oplossing

Are you using kerberos, ntlm, forms or claims? My guess is you are using NTLM and running into the NTLM double hop "issue".

http://blogs.msdn.com/b/besidethepoint/archive/2010/05/09/double-hop-authentication-why-ntlm-fails-and-kerberos-works.aspx

The easiest next step is probably to change your site over to Kerberos. I have a blog article where I outlined some resources that help when setting up kerberos in SharePoint.

http://steve.thelineberrys.com/resources-for-setting-up-kerberos-authentication-in-sharepoint/

Ander wenke

Have you tried using DefaultCredentials instead, to pick up the identity of the current user?

Additionally: is this aspx running within your SharePoint site? If so, why are you using the Client Object Model? Just use the server OM. Far easier and much less hassle.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan sharepoint.stackexchange
scroll top