Lets say I have a few users in a group called "Restricted" and I don't want them to be able to view or submit forms. Should I add some code in the Form_Loading event that checks what groups the current user is a member of? If so, how would I prevent the form from loading? So far the code I have doesn't seem to work.
SPGroupCollection grpCol = SPContext.Current.Web.CurrentUser.Groups;
try
{
SPGroup group = grpCol["Restricted"];
// if this doesn't throw an exception, they are not part of that group, so exit
return;
}
catch (Exception ex)
{
// if exception is thrown, they don't belong to that group, so continue
}