sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Remote Event Receiver which are registered with the option 'LegacyAuthProtocolsEnabled' set to false are not triggered/fired

Open SanderSiep opened this issue 7 years ago • 8 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

When we attach one or more SharePoint Remote Event Receivers, RER, to a list or library we would expect that these RER`s are fired/triggered and the call can be handled by the RER service. No matter if the option 'LegacyAuthProtocolsEnabled' is set to true or false.

Observed Behavior

When the Office365 Tenant option 'LegacyAuthProtocolsEnabled' is set to false it is not possible to use any newly registered RER on a list or library. The RER is not triggered/fired at all, so we do not see any request come in within the RER service. Already existing RER which were registered before setting the option 'LegacyAuthProtocolsEnabled' to false are still working correctly. Also when the option 'LegacyAuthProtocolsEnabled' is set back to true and a new RER is registered it works fine, but the RER`s which are registered with the option 'LegacyAuthProtocolsEnabled' set to false are still NOT working.

All the above observations are done with multiple RER`s to make sure it is not due to a particullar RER. We also have seen this behaviour at 3 different tenants, so it is reproducable at our side. The only downside is that when setting the option 'LegacyAuthProtocolsEnabled' it takes about 2 to 3 hours before it is pushed to the entire tenant! So it is not possible to switch this option and do a quick test after that, first wait 3 hours before doing that test.

Steps to Reproduce

Correct Situation First check if the RER is working in the correct situation in which the option 'LegacyAuthProtocolsEnabled' is set to true. This can be done by registering a new RER by using the beneath PowerShell:

#Region #### Variables ####
#The RER url can be used for testing. This is a free website within Azure, so could be that is sleeping, so please call this in the browser before testing it in SP
$RERUrl = "http://ctbrerhelloworld.azurewebsites.net/service.svc"
#The url of the site in which the list or library exists at which the RER must be attached
$siteUrl = "https://{TenantName}.sharepoint.com/sites/MySite"
#The name of the list or library at which the RER will be attached
$listName = "Shared Documents"

#endregion

#Connect to SP (in this case using username/pwd, can also be using Appid/secret/certificate but this will make it a bit more difficult to explain)
$credentials = Get-Credential
Connect-PnPOnline -Url $siteUrl -Credentials $credentials
$connection = Get-PnPConnection

#Add event receivers
Add-PnPEventReceiver -List $listName -Name "RER-HelloWorld-ItemAdding" -Url $RERUrl -Connection $connection -SequenceNumber 10000 -EventReceiverType ItemAdding -Synchronization Synchronous
Add-PnPEventReceiver -List $listName -Name "RER-HelloWorld-ItemUpdating" -Url $RERUrl -Connection $connection -SequenceNumber 10000 -EventReceiverType ItemUpdating -Synchronization Synchronous

#Verify if the events are added (which is the case)
Get-PnPEventReceiver -List $listName -Connection $connection

When these RER`s are registered please add an item within the list or library, which should result in an error message with the text 'Hello World!!!' This means the RER is registered and working correctly.

Fail Situation Set the 'LegacyAuthProtocolsEnabled' tenant property to false by using the following PowerShell:

#Connect to Office365
Connect-SPOService -Url https://{TenantName}-admin.sharepoint.com
#Check the property LegacyAuthProtocolsEnabled which is currently set to true
Get-SPOTenant
#Set the property LegacyAuthProtocolsEnabled to false
Set-SPOTenant -LegacyAuthProtocolsEnabled $false

#Wait for at least 2 to 3 hours before continuing, while the setting of this property can take up-to 3 hours!

After a couple of hours the property LegacyAuthProtocolsEnabled is set correctly to false in the entire environment. At this time we can register a new RER by executing the same PowerShell as specified in the Correct Situation. Please make sure either or both the site and or list name differs from the first test, so this RER is attached to another site and/or list. When now adding an item to the list or library it succeeds which means the RER is not fired/triggered. When adding an item to the list or library of the previous correct siuation check it still gives an error which indicates that these RER`s are still working correctly, which also eliminates the question whether the RER is still running or is correct, yes it is ;-).

As specified above, we can reproduce this (with a lot of patience) at 3 different Office365 tenants. Hopefully someone can fix this problem so we can continue to use the RER`s while this is our main trigger for our solutions at our environments and our customer environments.

In the mean time, does anyone have idea's how to work around this issue? We are thinking in using WebHooks or Flow, but any other idea's are more than welcome!

Beneath the code of our Hello World RER which is very complicated ;-)

public class Service : IRemoteEventService
{
    SPRemoteEventResult IRemoteEventService.ProcessEvent(SPRemoteEventProperties properties)
    {
        SPRemoteEventResult result = new SPRemoteEventResult();

        result.Status = SPRemoteEventServiceStatus.CancelWithError;
        result.ErrorMessage = "Hello World!!!";

        return result;
    }

    void IRemoteEventService.ProcessOneWayEvent(SPRemoteEventProperties properties)
    {
        throw new NotImplementedException();
    }
}

I hope someone can help us while this is blocking the main of our solutions at all of our customers which have disabled the LegacyAuthProtocolsEnabled Office365 option...

Thanks in advance for looking into this!

SanderSiep avatar Jul 29 '19 08:07 SanderSiep

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Jul 29 '19 08:07 msft-github-bot

Hello you all,

I have an update regarding this issue. We have started a Microsoft Premier support call and found out some interesting stuff. It turns out that the tenant option 'LegacyAuthProtocolsEnabled' is not the real problem but the actual problem is the usage of App-Only when registering the RER`s on a list.

Let me explain the reason behind this which Microsoft told us. When registering a RER it is not only saving the name, url, order, etc but also the context of the user or in this case the app which added the RER is saved as owner. So registering the RER works fine, expect in our case the user context which is normally saved is now using the app only context as owner of the RER.

When adding or updating a list item the first thing which is done is to check which RER`s should be executed. In our case also our RER. The second thing which is done is to check if the owner of the RER has the correct permissions to execute the RER. In normal situations a user has added the RER and that user is available in SharePoint and therefor can execute the RER. But in our case the owner is the App, which only exists within Azure AD as an App and not within SP, so in this case the permission check fails while SharePoint is only checking the internal permissions and not the Azure AD App permissions....

The workaround is to also give the App permissions within SharePoint by using the appinv.aspx page within the tenant admin. When doing so (after some delay >30min) it started to work and the added RER`s are now working correctly. This is offcourse not the perfect solution while in this case you have to specify permissions within the Azure AD App (which is OK) and you have to specify also permissions within SP (which is not OK). This SP permissions are not hard to monitor which app has which permissions and you have to give full control to the whole SP tenant. So in the end it would be very nice if Microsoft can fix this issue and the RER is also working with App Only in which the app is not even known in SP itself!

I guess at least the documentation should be updated so everyone knows that if using App-Only the App should have enough permissions within SP to let the RER work.

SanderSiep avatar Aug 06 '19 11:08 SanderSiep

We face the same problem, as we switch from SharePoint App Only to AzureAd App Only authentication. So we would like to avoid appinv.aspx as well.

Any progress in using RERs created from AzureAd App Only authenticated code?

EinmalIM avatar Feb 07 '21 15:02 EinmalIM

Hi @EinmalIM. No change unfortunately. As Microsoft stated they will not fix this issue so I guess we are stuck with this behaviour

SanderSiep avatar Feb 07 '21 15:02 SanderSiep

Too bad. Do you have a link where Microsoft stated that they won't fix it?

EinmalIM avatar Feb 07 '21 21:02 EinmalIM

Hi @EinmalIM, I do not have a link for you. Microsoft has stated this within the Premium Support ticket we had opened. After long testing and jumping from one team to another they came to the conclusion that the 'old school' Remote Event Receiver is not working when used in this scenario and they will not update this while this would have too much impact :-(

SanderSiep avatar Feb 08 '21 08:02 SanderSiep

This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open or submit a new issue.

ghost avatar Dec 30 '21 14:12 ghost

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

ghost avatar Jan 06 '22 18:01 ghost