项添加获取Currentuser登录用户 [英] Itemadded get Currentuser logged in user

查看:76
本文介绍了项添加获取Currentuser登录用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public override void ItemAdded(SPItemEventProperties properties)
        {
         
try
            {
                EventFiringEnabled = false;
                SPListItem listItem = properties.ListItem;
string currentuser = properties.UserLoginName;
                CloneForOtherAssignees(listItem, groupMapping,currentuser);
            }
            catch (Exception e)
            {
}
}

我有上面的代码,其中currentuser始终是SharePoint \\ System,即Systemaccount.但是我想获得当前登录的用户?.如何在Itemadded Event Receiver中获取当前登录的用户.

I have the above code where currentuser is always SharePoint\\System that is Systemaccount. But i want to get the current loggedin user ?. How to get the current loggedin user in Itemadded Event Receiver.

推荐答案


如果发生诸如添加,更新之类的异步事件,您将获得系统帐户,因为这些事件是在系统帐户下异步运行的,但您可以通过调用item.modifiedby来触发该事件的用户.领域


in case of asynchronous events such as added,updated,.., you will get system account because these events are run asynchronously under system account BUT you can get the user who triggered the event by calling item.modifiedby field 

public override void ItemAdded(SPItemEventProperties properties)
        {
         
try
            {
                EventFiringEnabled = false;
                SPListItem listItem = properties.ListItem;
string currentuser = listItem["Editor"].tostring();
                CloneForOtherAssignees(listItem, groupMapping,currentuser);
            }
            catch (Exception e)
            {
}
}


您可以调试以检查项目属性的值.

you can debug to check the values of the item properties.

我希望这会对您有所帮助

i hope this will help you


这篇关于项添加获取Currentuser登录用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆