Hi,
We have one requirement, When user selects any value from the Drop down we need to compare that value to the SharePoint Group.
If that User is there in the group then only user allow to add new item to the list otherwise we need to display message(i.e. U r not a correct person).
We used below code:
public static bool IsUserMemberOfGroup(SPUser user, string grpname) { bool result = false; if (!String.IsNullOrEmpty(grpname) && user != null) { foreach (SPGroup group in user.Groups) { if (group.Name == grpname) { // found it result = true; break; } } } return result; } IsUserMemberOfGroup(ddlusers.selected value,"GrpName")
But it's showing error.