SharePoint 2010 C# 获取People Or Group
public override void ItemDeleting(SPItemEventProperties properties) { base.ItemDeleting(properties); bool judge = false; SPListItem item = properties.ListItem; SPFieldUserValueCollection FieldUserValueCollection = (SPFieldUserValueCollection)item["Users"]; SPFieldUserValueCollection fieldUserValues = new SPFieldUserValueCollection(); if (FieldUserValueCollection != null) { foreach (SPFieldUserValue FieldUserValue in FieldUserValueCollection) { if (FieldUserValue.User != null) { if (FieldUserValue.User.ID == SPContext.Current.Web.CurrentUser.ID) { judge = true; break; } } //if the field contain group else { SPGroup group = SPContext.Current.Web.SiteGroups.GetByID(FieldUserValue.LookupId); SPUser currentUser = SPContext.Current.Web.CurrentUser; SPGroupCollection userGroups = currentUser.Groups; foreach (SPGroup mygroup in userGroups) { if (group.Name == mygroup.Name) judge = true; break; } } } if (judge == true) { properties.Cancel = true; properties.ErrorMessage = "You cannot delete the file."; } } }