NOTE: This is only applicable to on premise.
You might have a need to access the SharePoint Web Services (in my case it was the UserProfileService.asmx) from an anonymous site. The issue is authentication - through both CSOM and Server Side code, there are problems with authentication.
A test with elevated, impersonation using a token and impersonation in .NET failed to produce results. In all cases, the permissions were blocked (user not part of the site, etc.). The actual fix was from a post I stumbled on wherein you can add a section to the Web.config to make it work.
Look for the end tag </system.web.extensions> and add the following just below it:
This effectively blocks anon-users from accessing _vti_bin (a good thing anyway) but permits the web services to work (you still need to set network credentials).
FYI: You should be using SPWebConfigModification to make the change - while I've documented this myself, here's another quick guide: https://blogs.technet.microsoft.com/heyscriptingguy/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file/
Kudos to: http://www.sharepointdiary.com/2012/06/sharepoint-web-services-exposed-to-anonymous-users.html#ixzz551Cj8h3j
You might have a need to access the SharePoint Web Services (in my case it was the UserProfileService.asmx) from an anonymous site. The issue is authentication - through both CSOM and Server Side code, there are problems with authentication.
A test with elevated, impersonation using a token and impersonation in .NET failed to produce results. In all cases, the permissions were blocked (user not part of the site, etc.). The actual fix was from a post I stumbled on wherein you can add a section to the Web.config to make it work.
Look for the end tag </system.web.extensions> and add the following just below it:
<!-- Disable anonymous access to _vti_bin -->
<
location
path
=
"_vti_bin"
>
<
system.web
>
<
authorization
>
<
deny
users
=
"?"
/>
</
authorization
>
</
system.web
>
</
location
>
FYI: You should be using SPWebConfigModification to make the change - while I've documented this myself, here's another quick guide: https://blogs.technet.microsoft.com/heyscriptingguy/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file/
Kudos to: http://www.sharepointdiary.com/2012/06/sharepoint-web-services-exposed-to-anonymous-users.html#ixzz551Cj8h3j