When implementing a List Menu Custom Action in Sharepoint 2013 I have problem getting which user has actually executed the custom action. I would like to do that to check that the user has permission to do this by checking which AD-groups the user is a member of. When I try to resolve the user with the Tokenhelper class it will only return the SharePoint system account sending the query to the Host Web. Is there any way you could attach the userId in the UrlAction parameters like below?
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="77cb35d9-1bf3-4d81-91cf-8a92473a6092.MenuItemCustomAction1"
RegistrationType="List"
RegistrationId="101"
Location="EditControlBlock"
Sequence="10001"
Title="$Resources:TogglePublic"
HostWebDialog="TRUE"
HostWebDialogHeight="250"
HostWebDialogWidth="700">
<UrlAction Url="~remoteAppUrl/CustomActionTarget.aspx?StandardTokens}&SPListItemId={ItemId}&SPListId={ListId}&SPSource={Source}&SPListURLDir={ListUrlDir}&SPItemURL={ItemUrl}&SPUserId={_spPageContextInfo.userId}" />
</CustomAction>
</Elements>
On the Host Web the following code should get the SPUserId:
public partial class CustomActionTarget : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
string userId = this.Request.QueryString["SPUserId"];
}
}
The _spPageContextInfo.userId is a javascript variable that should contain the current user, but I have not found any way to actually resolve and send the userId to the SharePoint App's Host Web using the UrlAction.