SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a SharePoint 2010 web application and site collection with Forms Based Authentication. I am trying to develop a Windows Forms Application to connect to this site but so far the connection portion is not working when I run the application as a Windows user (I have no method for assigning credentials at the moment). Is there something special I need to do? I can easily log in to the site using the browser with this user, and I am running it in Debug mode in Visual Studio as an Administrator.


  • Matt
share|improve this question
up vote 5 down vote accepted

You need to authenticate the connection to SharePoint using the FBA user's credentials.


ClientContext clientContext = new ClientContext("http://YourUrlHere");
clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
clientContext.FormsAuthenticationLoginInfo = 
    new FormsAuthenticationLoginInfo("username", "password");


Dim clientContext As ClientContext = New ClientContext("http://YourUrlHere")
clientContext.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication
clientContext.FormsAuthenticationLoginInfo = 
    New FormsAuthenticationLoginInfo("username", "password")
share|improve this answer
Thanks, but this is not working out for me, either. there seems to be some piece missing between me having this client context object and having usable SPSite and SPWeb objects. – Matt Oct 15 '12 at 15:16
Did you load the ClientContext? It works. – RJ Cuthbertson Oct 15 '12 at 15:49
Yes, I just didn't realize at first the true involvement of the clientcontext when used alongside other SharePoint things like List, Web, and Site, etc. I did some more digging and found examples of ClientContext in action and everything started falling into place – Matt Oct 15 '12 at 17:03
Yep, ClientContext is your central object to access your SharePoint environment via the CSOM. Very similar to SPContext in the server-side model. – RJ Cuthbertson Oct 15 '12 at 18:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.