2

I am trying to setup my client context for usage in a SharePoint 2013 site.

This new site appears to have mixed authentication, and because of that, I had to add the X-FORMS_BASED_AUTH_ACCEPTED header as indicated here, and that managed to help me overcome the 401 error, but now I am having an access denied error for one of my accounts (the internal account).

There are typically 2 types of users: external and internal.

User 1 i:0#.w|dmz\me is working fine using ("me", "pwd", "dmz") parameters

User 2 i:0e.t|custom provider|user@domain.com throws

Unhandled Exception: Microsoft.SharePoint.Client.ServerUnauthorizedAccessException: Access denied. You do not have permission to perform this action or access this resource.

I'm kind of confused about how the authentication is setup to be honest.

If I could guess, I would say that the second user is using some sort of claims token to relate the user with his AD internal account, and perhaps there is an additional step I need to take in my code to do something in the ADFS for this kind of user.

The code is straight-forward:

Microsoft.SharePoint.Client.ClientContext ctx = new Microsoft.SharePoint.Client.ClientContext(url);
ctx.Credentials = new System.Net.NetworkCredential(username, password, domain);
ctx.ExecutingWebRequest += clientContext_ExecutingWebRequest;
...
void clientContext_ExecutingWebRequest(object sender, Microsoft.SharePoint.Client.WebRequestEventArgs e)
        {
            try
            {
                e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
            }
            catch
            {
                throw;
            }
        }

So my question is, how can I login using username, password and domain using both types of accounts, and is there an additional authentication step (e.g. get saml token or something) to make this work on the custom provider users, or am I just not using the right username and domain in the parameters?

Similar questions:

Connect to On-premise ADFS (https) authenticated site using CSOM

Client object model connect to site with different authentication enabled?

Update:

  • both users are site collection administrators
  • trying to use a typical claims setup will throw

Unhandled Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Site is not configured for Claims Forms Authentication.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.