EventReceiver and anonymous access

Mar 14, 2012 at 1:23 PM

when the anonymous access enabled for list EventReceiver is not work

In log file:

03/14/2012 17:21:23.87  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Monitoring                     nasq Medium   Entering monitored scope (Request (POST:http://srv-spp:80/_vti_bin/client.svc/ProcessQuery)) 
03/14/2012 17:21:23.87  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Logging Correlation Data       xmnv Medium   Name=Request (POST:http://srv-spp:80/_vti_bin/client.svc/ProcessQuery) 5ffbf4c0-f631-481f-804b-fca66a09c631
03/14/2012 17:21:23.87  w3wp.exe (0x072C)                        0x16EC SharePoint Foundation          Logging Correlation Data       xmnv Medium   Site=/ 5ffbf4c0-f631-481f-804b-fca66a09c631
03/14/2012 17:21:23.90  w3wp.exe (0x072C)                        0x16EC SharePoint Foundation          Monitoring                     b4ly High     Leaving Monitored Scope (EnsureListItemsData). Execution Time=12.3484968061583 5ffbf4c0-f631-481f-804b-fca66a09c631
03/14/2012 17:21:24.07  w3wp.exe (0x072C)                        0x16EC SharePoint Foundation          General                        8e2s Medium   Unknown SPRequest error occurred. More information: 0x80070005 5ffbf4c0-f631-481f-804b-fca66a09c631
03/14/2012 17:21:24.08  w3wp.exe (0x072C)                        0x16EC SharePoint Foundation          General                        6875 Critical Error loading and running event receiver iLoveSharePoint.EventReceivers.PowerItemEventReceiver in iLoveSharePoint.EventReceivers.PowerEventReceivers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ff9e624534d2fa48. Additional information is below.  : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) 5ffbf4c0-f631-481f-804b-fca66a09c631
03/14/2012 17:21:24.12  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Monitoring                     b4ly Medium   Leaving Monitored Scope (Request (POST:http://srv-spp:80/_vti_bin/client.svc/ProcessQuery)). Execution Time=252,158305035975 5ffbf4c0-f631-481f-804b-fca66a09c631
03/14/2012 17:21:24.13  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Monitoring                     nasq Medium   Entering monitored scope (Request (POST:http://srv-spp:80/Lists/Custom/AllItems.aspx?InitialTabId=Ribbon%2EListItem&VisibilityContext=WSSTabPersistence)) 
03/14/2012 17:21:24.13  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Logging Correlation Data       xmnv Medium   Name=Request (POST:http://srv-spp:80/Lists/Custom/AllItems.aspx?InitialTabId=Ribbon%2EListItem&VisibilityContext=WSSTabPersistence) b28e026e-cbb4-46ca-801e-ab16e319b245
03/14/2012 17:21:24.15  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Logging Correlation Data       xmnv Medium   Site=/ b28e026e-cbb4-46ca-801e-ab16e319b245
03/14/2012 17:21:24.15  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Monitoring                     b4ly High     Leaving Monitored Scope (PostResolveRequestCacheHandler). Execution Time=13.4514302795467 b28e026e-cbb4-46ca-801e-ab16e319b245
03/14/2012 17:21:24.16  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Monitoring                     b4ly High     Leaving Monitored Scope (Custom). Execution Time=3.4174734498379 b28e026e-cbb4-46ca-801e-ab16e319b245
03/14/2012 17:21:24.18  w3wp.exe (0x072C)                        0x0EA0 SharePoint Foundation          Monitoring                     b4ly Medium   Leaving Monitored Scope (Request (POST:http://srv-spp:80/Lists/Custom/AllItems.aspx?InitialTabId=Ribbon%2EListItem&VisibilityContext=WSSTabPersistence)). Execution Time=49.3258221366123 b28e026e-cbb4-46ca-801e-ab16e319b245

Coordinator
Mar 16, 2012 at 7:41 AM

I've never tested with anonymous access enabled.  Can you determine if an empty event receiver fails or if the script within fails.

Mar 16, 2012 at 8:56 AM

How can I do it?

In my environment (SharePoint Server 2010 sp1 + <label for="ctl00_PlaceHolderMain_AuthenticationSection_RadUseClaimAuth">Claims Based Authentication </label>+ anonymous access enabled) I create the custom list with one standard column (“Title”)

Add PowerEventReceivers solution, and set easy code from code examples:

function ItemDeleting{

     $properties.Cancel = $true

     $properties.ErrorMessage = "Deleting is Wrong"

 

     $newitem = $list.items.Add()

     $newitem["Title"] = ("NEW Add_" + $item["Title"]);

     $newitem.update()

}

If I “authorization user” with managed access (Read, Write, Delete items) on list, this code is work - item is not deleting and new item is adding. But when I anonymous user with managed item access (or user without access, probably as anonymous user) – item is deleting, and new item is not adding. In UI not error or warning message, but log file contains error (from a first message).

 

Regards. And Sorry for my bad English

Mar 16, 2012 at 11:12 AM
Edited Mar 16, 2012 at 11:30 AM
cglessner wrote:

I've never tested with anonymous access enabled.  Can you determine if an empty event receiver fails or if the script within fails.


Ok, i test my custom list when all string in "Power Item Event Receiver" commented, and I don't get error in log file.

Coordinator
Mar 27, 2012 at 7:23 AM

Sorry, I'm really late. You could try to create a new SPSite object:

$site2 = new-object Microsoft.SharePoint.SPSite($web.Url); $web2 = $site2.OpenWeb()  

$web2 should run with the credentials of the system account.

Bye, Christian

 

Mar 29, 2012 at 6:29 PM

Hello Christian

I don’t understand how this solution helps me for my trouble.

My problem is –Anonymous users don’t initiate EventReceivers action.

Please speak me in detail.

In my case: When Anonymous user create new item in CustomList – The EventReceivers is create copy of this item in list for no accessible list (for anonymous), and delete first item.

Thanks.

Coordinator
Apr 2, 2012 at 3:47 PM

Hi,

now I'm confused too. I'm not sure if I undestand the problem.

Explanation:

$site2 = new-object Microsoft.SharePoint.SPSite($web.Url); $web2 = $site2.OpenWeb()

# work with the objects; create list item....

$web2.Dispose()

$site2.Dispose()

By default the PowerShell code runs under current user. If the current user has no write permission on the second list the code will fail. If you instantiate a new SPSite as mentioned above. The code will run as system and you should be able to create the list item event if the current user hasn't the permission.

 

Apr 5, 2012 at 1:51 PM


Sorry, but this way is no work for Anonymous users.

As I understand, Event is not accessible for Anonymous users. If this Authorization user – all ok, but Anonymous – no work and in log file detect this:

04/05/2012 15:25:07.42  w3wp.exe (0x18AC)                        0x1984 SharePoint Foundation          General                        6875 Critical Error loading and running event receiver iLoveSharePoint.EventReceivers.PowerItemEventReceiver in iLoveSharePoint.EventReceivers.PowerEventReceivers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ff9e624534d2fa48. Additional information is below.  : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) 559514de-6800-4685-a2f8-38c5895f1052.

I'm sad, probably SharePoint bad intended for Anonymous users.

Thank you, Christian, this is good project

Dec 12, 2013 at 6:08 AM
I have this problem too