SharePoint 2007不存在判断用户组isExist的方法,因此只有自己写一个喽:
public static bool GroupExists(SPGroupCollection groups, string name)
{
if (string.IsNullOrEmpty(name) ||
(name.Length > 255) ||
(groups == null) ||
(groups.Count == 0))
return false;
else
return (groups.GetCollection(new String[] { name }).Count > 0);
}
public static bool GroupExists(SPGroupCollection groups, int id)
{
if ((id < 0) ||
(groups == null) ||
(groups.Count == 0))
return false;
else
return (groups.GetCollection(new Int32[] { id }).Count > 0);
}