Click here to Skip to main content
Licence CPOL
First Posted 10 Mar 2008
Views 50,738
Downloads 492
Bookmarked 17 times

Access a Forms Based SharePoint Site's Web Service

By Sohel_Rana | 10 Mar 2008
This article describes how to access the Web Services of a Forms baed authenticated SharePoint site.
1 vote, 14.3%
1

2
1 vote, 14.3%
3

4
5 votes, 71.4%
5
4.20/5 - 7 votes
μ 4.20, σa 2.93 [?]

Introduction

SharePoint site provides built-in Web Services with which we can access the SharePoint Object Model. To access those Web Services, we need to provide credentials to the Web Service. But if the SharePoint site uses Form based authentication, you may get the error: “The request failed with HTTP status 403: Forbidden”. It’s because Form based authentication works in a different way than others. To work this problem out, you need to use another authentication mechanism in SharePoint which is cookie based.

Concept

To get the list of available Web Services, go to IIS and expand the SharePoint web application. Then, under the node _vti_bin:

In a Form based SharePoint site, to invoke a Web Service, the user must be authenticated with the Authentication.asmx Web Service. The Web Service will return the LoginResult object which specifies the authentication status. The Web Service will not generate any exception if the authentication fails; rather the return object LoginResult will contain the login status. If authentication is successful, then the Web Service will put the credential key in the Web Services’ cookie. But to put the credential to the Web Service’s cookie, we need to initialize the cookie container of the Web Service as:

AuthenticationWSObject.CookieContainer = new CookieContainer();

You can get the cookie as follows:

Cookie cookie = cookies[loginResult.CookieName];

If the Web Service is invoked after initializing the cookie container property, the cookie will be filled with the credential token. Now, we can set the cookie in another Web Service’s cookie to access the site.

The process is shown in the following figure:

Picture2.JPG

Using the code

The given example is a desktop application with two web references to the SharePoint Web Services Authnectincation.asmx and Lists.asmx. So, put the two Web Service addresses in the textbox:

Picture3.JPG

Thanks

I faced a problem in accessing a SharePoint site with Forms based authentication. My ex-team lead Moim Hossain helped me to figure out the solution. So I personally thank him. I have taken for granted that someone will face the same problem and they may get help form this article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sohel_Rana

Web Developer

Bangladesh Bangladesh

Member
Sohel Rana is currently working as Software Engineer in a software firm in Dhaka, Bangladesh. He has years of expertise in working with products like SharePoint, Ektron, DotNetNuke. He's main expertise is in the area of SharePoint.
 
He likes to learn new technologies. He likes to listen music in his spare time.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionSite in Windows Authentication PinmemberUdayaraju5:02 8 Feb '12  
GeneralMy vote of 5 PinmemberIlka Guigova12:24 13 Jan '12  
Questionsoap webservice refernce PinmemberAmit990921:02 7 Aug '11  
Questionhttps problem Pinmemberfleschgordon4:48 17 Apr '09  
AnswerRe: https problem PinmemberSohel_Rana6:46 17 Apr '09  
GeneralRe: https problem Pinmemberfleschgordon21:10 19 Apr '09  
GeneralRe: https problem Pinmemberfleschgordon4:40 24 Apr '09  
QuestionProblems while authenticating other web services PinmemberMember 30575613:30 4 Jun '08  
AnswerRe: Problems while authenticating other web services PinmemberSohel_Rana18:34 4 Jun '08  
GeneralRe: Problems while authenticating other web services PinmemberMember 305756120:05 4 Jun '08  
GeneralRe: Problems while authenticating other web services PinmemberSohel_Rana1:42 5 Jun '08  
GeneralRe: Problems while authenticating other web services Pinmembervenukata1:13 11 May '10  
GeneralRe: Problems while authenticating other web services PinmemberSohel_Rana1:26 11 May '10  
GeneralThanks PinmemberPrabs17:47 29 Apr '08  
GeneralGood Job!!! PinmemberMember 437329319:39 11 Apr '08  
GeneralNot able to redirect to login or any specified page Pinmembersonashish17:19 26 Mar '08  
GeneralRe: Not able to redirect to login or any specified page Pinmembersonashish20:22 27 Mar '08  
GeneralRe: Not able to redirect to login or any specified page PinmemberSohel_Rana22:30 30 Mar '08  
GeneralConnection Error PinmemberJohn Dooner7:28 10 Mar '08  
GeneralRe: Connection Error PinmemberSohel_Rana5:54 12 Mar '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 10 Mar 2008
Article Copyright 2008 by Sohel_Rana
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid