I have a code that is doing role assignment in Sharepoint 2010. This assigment occurs at 2 different times. 1. In the ItemUpdated event in the class that implement SPEventItemReceiver, everything is workin开发者_StackOverflow社区g fine here. 2. In a function that is executed when we want to update permissions.
Code in function 1, and function 2 are identical, however in function 2 we are getting User not found error. Is the event handler running under a different context/user ? I don't know how to approach this problem. Any suggestions ?
You did not provide any code samples.
Do you call SPWeb.EnsureUser() before assigning rights?
This method will ensure that the user exists (it wont "exist" inside SharePoints user list if the user havent logged in).
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.ensureuser.aspx
精彩评论