A recent MSDN forums question prompted this posting.  Since SharePoint has all these built in web services it is extremely easy to integrate SharePoint with other systems, LOTS of other systems.  Typically people use the NTLM SharePoint site and thus typically don’t worry all too much about authentication of their code when it comes to the SharePoint web services.  Sometimes though, for whatever reason, perhaps you don’t own the SharePoint environment, etc. but your SharePoint site ONLY uses FBA, and thus your stuck with trying to call the SharePoint web services using FBA.  At first this might seem like a daunting task but in reality its really no different/harder than the typical way you would call a SharePoint web service.  The difference is mainly that you need to first call an authentication web service, and then use the cookie result you get back in all your subsequent web service calls.  Enough Rambling…BRING ON THE CODE!!!

Pre Reqs:

Code:

I created a simple console program project and added 2 web references to it:

//authenticate to the web services of a SharePoint FBA site
using (AuthenticationSvc.Authentication authSvc = new AuthenticationSvc.Authentication())
{
    authSvc.Url = @"http://winsvr2003base:14059/_vti_bin/authentication.asmx";
    authSvc.CookieContainer = new System.Net.CookieContainer();     //create a new cookie container
    authSvc.AllowAutoRedirect = true;
 
    //set the FBA login information
    AuthenticationSvc.LoginResult result = authSvc.Login("triplet", "P@ssw0rd");
 
    //check our loginresult to make sure that we don't have any errors
    //if we don't have any errors, then consider us authenticated and we can then call our
    //other SharePoint web services by passing in our authentication cookie
    if (result.ErrorCode == AuthenticationSvc.LoginErrorCode.NoError)
    {
        try
        {
            //now that we're authenticated through FBA try and call the lists web service
            using (ListsSvc.Lists listSvc = new SharePointFBAWebSvcTester.ListsSvc.Lists())
            {
                listSvc.Url = @"http://winsvr2003base:14059/_vti_bin/lists.asmx";
                
                //set our authentication cookie that we got above
                listSvc.CookieContainer = authSvc.CookieContainer;  
                
                //get the lists from the site
                XmlNode listCol = listSvc.GetListCollection();
 
                //dump all the lists in our site
                Console.WriteLine(listCol.InnerXml);
            }
        }
        catch (Exception ex)
        {
           Console.WriteLine("Exception occured while calling lists.asmx" + ex.Message);
        }
    }
    else
        Console.WriteLine("Error authentication to web service.");
}

*** AuthenticationSvc is the name of the web service reference I added to Authentication.asmx

*** ListsSvc is the name of the web service reference I added to Lists.asmx


Pretty simple, huh?  With the basic code above, you should be able to authenticate to the FBA site, and then call whatever SharePoint web service you want.


Posted in:   Tags:

Comments


January 17. 2010 18:09
Model
Using it an FBA sharepoint site is easy. This is a bit of tech that we may use on a model site we are coming up with.

http://www.modelstardom.com/http://www.modelstardom.com/


January 21. 2010 13:40
bathroom light fixtures
Great.
Best cobination for blogging with BlogEngine.Net platform.
Happy blogging

Regards,
Dave

http://www.bathroomlightfixtures.biz/bathroom-light-fixtures.htmlhttp://www.bathroomlightfixtures.biz/bathroom-light-fixtures.html


January 24. 2010 23:47
domy warszawa
I’m impressed, you know what you’re talking about

http://www.mieszkaniewarszawa.net/http://www.mieszkaniewarszawa.net/


January 25. 2010 07:19
cash loans
One that would have the fruit must climb the tree.

http://cashusloans.com/http://cashusloans.com/


January 27. 2010 15:35
Life insurance
Really appreciate this post. It’s hard to sort the good from the bad sometimes, but I think you’ve nailed it!

http://www.ratedetective.com.au/insurance/life-insurancehttp://www.ratedetective.com.au/insurance/life-insurance


January 27. 2010 17:11
adult sex toy
Cheers to the author for giving me some solid ideas ...

http://www.diamonddooronline.com.au/http://www.diamonddooronline.com.au/


January 27. 2010 18:28
car finance melbourne
Hi,

Excellent blog post, I look forward to reading more.

http://www.quantumfinancesolutions.com.au/http://www.quantumfinancesolutions.com.au/


January 27. 2010 19:37
Life insurance
Hi,

Interesting read, thanks for helping keep me busy at work ;)

http://www.ratedetective.com.au/insurance/life-insurancehttp://www.ratedetective.com.au/insurance/life-insurance


January 27. 2010 20:56
hardwood floors
Hi,

Don’t stop blogging! It’s nice to read a sane commentary for once....

http://www.ifloor.com/http://www.ifloor.com/


United States SEO
January 27. 2010 21:00
SEO
Hi,

Cheers to the author for giving me some solid ideas....

http://www.webmarketingexperts.com.au/http://www.webmarketingexperts.com.au/


January 28. 2010 18:16
Accounting Software
Pretty Interesting post. Couldnt be written any better. Thanks for sharing!

http://www.southeastcomputers.com/http://www.southeastcomputers.com/


January 28. 2010 18:16
Web Design India
Thanks for sharing info. Keep up the good work...We hope you will visit our blog often as we discuss topics of interest to you

http://www.neswebdesign.com/http://www.neswebdesign.com/


January 28. 2010 18:17
Web Design New Jersey
Wow, what a great resource! Thanks for sharing this...

http://www.shiningstarws.com/http://www.shiningstarws.com/


January 28. 2010 18:17
leaflet distribution kent
Glad to visit your blog. Thanks for great post that you share to us...

http://www.kentleaflets.com/http://www.kentleaflets.com/


January 28. 2010 18:17
Zoekmachine optimalisatie
I really love the way infomration presented in your post. I have added to you in my social bookmark…and i am w8ing ur next post

http://www.profitbysearch.nl/http://www.profitbysearch.nl/


January 28. 2010 18:18
SEO Virginia
Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful

http://www.myrevsource.com/http://www.myrevsource.com/


January 28. 2010 19:20
internet dating
Hi,
  Excellent blog post, I look forward to reading more.

http://www.spiceoflife.com.au/http://www.spiceoflife.com.au/


January 29. 2010 16:46
attract women
   Thanks heaps to the author!

http://www.daygamedating.com.au/http://www.daygamedating.com.au/


January 31. 2010 15:36
casino gambling collection
Share Point service accounts to the DotNetNuke database. If you installed the Share Point site using one account then that account will have to be given explicit ‘db_owner’ role membership into the DNN-DB database.

http://www.gambling-collection.com/http://www.gambling-collection.com/


January 31. 2010 15:50
auction online
Hi,



It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks

http://www.eaauctions.com.au/http://www.eaauctions.com.au/


February 1. 2010 08:09
Loans in HI
Whoever wants to reach a distant goal must take small steps.

http://superpaydayloan.com/state/Hawaiihttp://superpaydayloan.com/state/Hawaii


February 1. 2010 18:49
cordless electric kettle
it really compensated for my time. Nice blog. I just bookmarked it for later reference. Good job.

http://www.cordless-electric-kettle.com/http://www.cordless-electric-kettle.com/


February 2. 2010 19:25
flash programming
Looking back, about two years ago, I couldn’t get any proper info on the topic but now I am just so happy to see all stuff revealed.

http://www.flashdevs.com/http://www.flashdevs.com/


February 3. 2010 18:20
best condom
How long have you been in this field? You seem to know a lot more than I do, I’d love to know your sources!


http://www.maxprocondom.com/http://www.maxprocondom.com/


February 4. 2010 15:18
business opportunity
Awesome tips. I’ll be passing this post on for sure

http://www.mapofsuccess.com/http://www.mapofsuccess.com/


February 7. 2010 14:41
Miami website design
SharePoint is a collection of products and software elements that includes, among a growing selection of components, web browser based collaboration functions, process management modules, search modules and a document-management platform. SharePoint can be used to host web sites that access shared workspaces, information stores and documents, as well as host defined applications such as wikis and blogs. All users can manipulate proprietary controls called "web parts" or interact with pieces of content such as lists and document libraries.

http://www.evokedesign.com/http://www.evokedesign.com/


February 7. 2010 15:28
business opportunities from home
Cheers for the info. It was a good read.

http://www.mapofsuccess.com/http://www.mapofsuccess.com/


February 8. 2010 05:29
faxless loans
You will never find time for anything. If you want the time, you must make it.

http://cashusloans.com/http://cashusloans.com/


February 9. 2010 02:55
payday loans
Nothing great in the world has ever been accomplished without passion.

http://fastloansus.com/http://fastloansus.com/


February 10. 2010 21:43
web design Dubai
It was good to see your post. It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues. Great stuff as usual...

http://www.wewanttraffic.com/services/website.shtmlhttp://www.wewanttraffic.com/services/website.shtml


February 15. 2010 21:36
dissertation
Wonderful article,thanks for putting this together! "This is obviously one great post. Thanks for the valuable information and insights you have so provided here. Keep it up!"

http://www.dissertation-help.co.uk/http://www.dissertation-help.co.uk/

Search Blog

Blog Roll

    OPMLDownload OPML file

    Recent Comments

    Banners

    Theme Grabber
    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010 Tony Testa's World