I have the following event receiver inside my sharepoint server 2013, the event recevier get fired when an item is updated and i am running it with Elevated Privileges :-
public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(properties.SiteId))
{
string currenweburl = properties.RelativeWebUrl;
using (SPWeb spCurrentSite = site.OpenWeb(currenweburl))
{
now i was reading this MSDN question link, which mentioned that for the After event receiver (as in the ItemUpdated case) i can not get the user who cause the event receiver to fire, here is one of the answers :-
'After' event such as Added, Updated, Deleted are run asynchronously under the system account, and so you won't have access to the user that triggered the event.
but in my case i am able to get the ID of the user who cause the event receiver to fire as follow:-
var currentusername = properties.CurrentUserId;
Also i am able to get the loginName as follow:-
var test = properties.Web.CurrentUser.LoginName.ToString();
Question 1) so can anyone advice why inside the MSDN link they mentioned that on the After event receivers i can not get the user who cause the event receiver to fire,, but based on my test i am able to do so !!
now one note i have is that the MSDN link is back to 2010,, which means that it is not talking about sharepoint 2013, where in my case i am using sharepoint 2013..
Final note here is my Element.xml file inside my event receiver project:-
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers>
<Receiver>
<Name>EventReceiver1ItemUpdated</Name>
<Type>ItemUpdated</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>CreateSubSiteforProjects.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
which does not explicitly define the <Synchronization>
.
Question 2) so i am not sure what is the defualt? could my event receiver execute synchronous ?
can anyone advice on my above 2 questions please?