Hello All,
I am trying to post to a newsfeed in C# for an FBA user (hooked up via SQL aspnetmemberships) and if I have a brand new fba user that has never logged into SharePoint before then I get the "internal error code 83" error. SharePoint 2013 is configured for mixed mode authentication.
If I then login into SharePoint 2013 for that FBA user, then run the C# code again to post to a newsfeed it works just fine.
So the first time login for an fba user is setting something up that is needed by the "GetFeedFor" method of the "SocialFeedManager" class. But what is it that's setup on first time login for an FBA user? Could it be mysite or something else?
Whatever it is, I would like to know if I can do this programmatically so the problem goes away.
Here is the code:
private void PostReply_Click(object sender, EventArgs e) { try { using (SP.ClientContext clientContext = new SP.ClientContext(URI.Text)) { //Configure the handler to set FBA mode clientContext.ExecutingWebRequest += new EventHandler<SP.WebRequestEventArgs>(ctx_MixedAuthRequest); //set authentication mode to use FBA clientContext.AuthenticationMode = SP.ClientAuthenticationMode.FormsAuthentication; // Set credentials to a specific FBA user SP.FormsAuthenticationLoginInfo formsAuthInfo = new SP.FormsAuthenticationLoginInfo(FbaUser.Text, FbaPassword.Text); clientContext.FormsAuthenticationLoginInfo = formsAuthInfo; // Create an instance of the socialfeedmanager to interact with the newsfeed SocialFeedManager feedManager = new SocialFeedManager(clientContext); // Get the target URI newsfeed. SP.ClientResult<SocialFeed> feed = feedManager.GetFeedFor(URI.Text + "/newsfeed.aspx", null); clientContext.ExecuteQuery(); // Find the selected thread and save the thread Id SocialThread thread = feed.Value.Threads[Convert.ToInt32(ThreadNo.Value)]; string selThreadId = thread.Id.ToString(); // Define the reply SocialPostCreationData postCreationData = new SocialPostCreationData(); postCreationData.ContentText = Reply.Text; // Publish the reply to the newsfeed. // If you pass null as thread Id this will create a new thread (i.e. a new root post) feedManager.CreatePost(selThreadId, postCreationData); clientContext.ExecuteQuery(); MessageBox.Show("Posted!"); } } catch (Exception x) { MessageBox.Show(x.Message); } }
It fails on the ExecuteQuery() method just after the GetFeedFor() method with the "internal error code 83" error.
As I said above, once I login to SharePoint 2013 for a new fba user the above code works fine.
Any ideas appreciated.
I have tried to login via C# using httpwebresquest but I haven't had much luck getting this work.
Is there a C# way I can login to SharePoint for an FBA user?
Are there any other c# solutions that would overcome an fba user that has never loggin in?