private static void setPerrmissionToListItem(SPListItem listItem, PermissionAssigment pa) { List<string> members = new List<string>(); if (pa.Members != null && pa.Members.Count > 0) { members.AddRange(pa.Members); } if (pa.FieldIds != null && pa.FieldIds.Count > 0) { foreach (string fieldId in pa.FieldIds) { if (listItem.Fields.ContainFieldId(new Guid(fieldId)) && listItem[new Guid(fieldId)] != null) { SPFieldUserValueCollection users = new SPFieldUserValueCollection(listItem.Web, listItem[new Guid(fieldId)].ToString()); foreach (SPFieldUserValue user in users) { if (user.User != null) members.Add(user.LookupId + ";#" + user.User.LoginName); else members.Add(user.ToString()); } } } } listItem.SetPermissions(pa.PermissionLevel, members); }