I've been working on a interface to add list alerts for the current user on Sharepoint 2010. With high privilege users I can add and remove the alerts from lists and documents, but when I'm using a low level user "Visitor" with Read permissions on the site and list/document I can't add multiple alerts or remove them. It's one by one, and I get a "Access Denied".
If you want I can show you my code. TIA.
Assuming you're not sandboxed, can you use a delegate to run with elevated permissions? eg
string employeeIdToRemove = "1337";
Guid siteGuid = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPermissions(delegate
{
using (SPSite mySite = new SPSite(siteGuid))
{
SPListItemCollection listItems = mySite.Lists["SuperSecretList"].Items;
int itemCount = listItems.Count;
for (int k=0; k<itemCount; k++)
{
SPListItem item = listItems[k];
if (employeeIdToRemove.Equals(item["Employee"].ToString()))
{
listItems.Delete(k);
}
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.