Saturday 18 June 2011

How to check if User is Present in a Group

You can add extension method to SPUser class to achieve this requirement.

Add the below namespace.

using System.Linq;


public static bool UserExist(this SPUser user, string groupName)
{
return user.Groups.Cast().Any(gn => gn.Name == groupName);
}

No comments:

Query List/Document Library in Specific Folder

To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...