Get tasks by User’s Name

string assignedToName = assignedTo.Substring(assignedTo.IndexOf(“#”) + 1);

if (assignedToName.ToUpper().Contains(userDisplayName.ToUpper()))
{
isForCurrentUser = true;
}
else
{

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite siteCollection = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb myWeb = siteCollection.OpenWeb(“Departments”))
{
SPWebCollection mWebs = myWeb.Webs;
SPWeb currentWeb2 = mWebs[“Admin”];
SPGroupCollection spGroupCollection = currentWeb2.SiteGroups;
foreach (SPGroup group in spGroupCollection)
{
if (group.Name.ToUpper() == assignedToName.ToUpper())
{
foreach (SPUser user in group.Users)
{
if (user.Name.ToUpper() == userDisplayName.ToUpper())
{
isForCurrentUser = true;
break;
}
}
break;
}
}
}
}

});

}

Advertisements
This entry was posted in SharePoint 2010, Visual Studio 2010. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s