4

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.

Thanks,

  • Matt

1 Answer 1

5

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

C#:

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

VB.Net:

Dim clientContext As ClientContext = New ClientContext("http://YourUrlHere") clientContext.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication clientContext.FormsAuthenticationLoginInfo = New FormsAuthenticationLoginInfo("username", "password") 
4
  • 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. Commented Oct 15, 2012 at 15:16
  • Did you load the ClientContext? It works. Commented Oct 15, 2012 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 Commented Oct 15, 2012 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. Commented Oct 15, 2012 at 18:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.