Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

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")
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
add comment

Your Answer

 
discard

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.