Question

I'm facing some problems accessing by Claim Based to my web service.

On my App there's only Claim Based: windows auth is disabled and NTLM also. If I access to Sharepoint by web based interface, this recognise me as UserX and everything goes.

If I access by WS there are 2 scenarios:

  • Call by UserY (System Account) -> Everything goes well
  • Call by UserX (NO SA but SCAdmin) -> Object reference not set to an instance of an object

The code is very simple, gets only current user Login Name:

using (SPSite sito = new SPSite("https://to0wss2k10rey03:50000/sites/Test1"))
            {
                using (SPWeb web = sito.OpenWeb())
                {
                    string Username =  web.CurrentUser.LoginName;
                }
            }

The exception is raised when i try to get the CurrentUser, wich appears to be null..

Was it helpful?

Solution

I'm quiet mystified by how it works with UserY, it should always fail.

When running with Claims without NTLM the only way to pass credentials is through a FedAuth cookie with your SharePoint STS SAML token. To get that token you have to call the SharePoint STS with a SAML token from your identityprovider (ADFS?). To get that token you have to call the identity provider with login info.

See Claims Proxy – A C# Library for Calling Claims Protected Web Services Connecting to SharePoint with Claims Authentication or the main blog about SharePoint with claims Share-n-dipity

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top