Thursday, 13 October 2011

At My Wit's End

I cannot get an event handler to fire at all for a non-admin user.

I have error tracking enabled  and on. It writes to a file. I have enabled permissions on the file folder. I have instructed it to throw an error and write back. When I log in as myself, it does all these things. I am a member of the owner group of the site.

The event handler copies the document library entry, including the document, to another document library on a different site, in a different site collection. It does various other things as well, but that's later on. When I log in as myself, all this works fine. When I log in as the test user, nothing happens. When I instrument the code, nothing happens. I have tried elevated privilege blocks in the code, paying attention to the declaration of the site instances within the block as required, but given that the event handling mechanism steadfastly refuses to even CALL the code for that user, I'm inclined to believe I could put "rhubarb rhubarb rhubarb" in there and it wouldn't make any difference. There should be no reason why I cannot manipulate the properties object.

I made the test user King of Everything. Full control on the source document library, full control on the site - I even made the blasted thing a site collection administrator! (this on the test machine, of course) Test user had more privileges than I did. Plus I removed my login from the site collection admin list.

Didn't make a lick of difference. And then when an actual user tried to log in and nothing happened, I knew this was going to be trouble. I have to confess to being utterly stumped as to why it doesn't call the code AT ALL. I would understand if it gave an error due to privilege - I even managed to get past one of those in one of the other issues I had with the EnsureUser method - but it's not even bothering to invoke the component. Works fine when I log in as myself, or log in as super user.

Any ideas? Losing the will to live over here! :)



  1. You could run that section of code with elevated privileges:

    // Your code to execute goes here

  2. Hi John! Thanks for dropping in and commenting. I got it working in the end - I think I just "debugged" it line by line by line - I had Elevated Privileges, I had a SPUserToken, tried everything. My conclusion was that it was falling over at the point where it was trying to copy a file to a different doc library. I think I moved the privilege block or something and it worked!