在Sharepoint 2013中实现列表菜单自定义操作时,我无法确定哪个用户实际执行了自定义操作。我想通过检查用户所属的AD组来检查用户是否有权这样做。当我尝试使用Tokenhelper类解析用户时,它只会返回将查询发送到Host Web的SharePoint系统帐户。你有没有办法在下面的UrlAction参数中附加userId?
<?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>
在Host Web上,以下代码应该获得SPUserId:
public partial class CustomActionTarget : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
string userId = this.Request.QueryString["SPUserId"];
}
}
_spPageContextInfo.userId是一个应包含当前用户的javascript变量,但我没有找到任何方法来实际解析并使用UrlAction将userId发送到SharePoint应用程序的主机Web。