3

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..

  • Hmmm... where are you using the web services? This is plain 'ol server side OM code!? Do you run this in a console app, in a web part...? Which line do you get the null ref exception? Please provide us with more details... – Wictor Wilen MCA MCM MVP May 15 '12 at 17:06
3

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.