I posted this question on SharePoint exchange but it did not get any attention. Any help will be appreciated.
I have implemented a site and have added a SharePoint group called "SG_Uploader".
In this group, I ONLY have one Active Directory group called "AD_L6" and there are many users in AD_L6.
If a user comes to site and I want to check if he can upload a document, I use below code which is very simple:
SPWeb web = // ...
SPGroup group = web.SiteGroups["SG_Uploader"];
if (group.ContainsCurrentUser)
{
// allow user to upload
}
Now, I want to do the same thing, not for current user but for a specific user that I have his username. By that mean I want to write a code like
SPWeb web = // ...
SPGroup group = web.SiteGroups["SG_Uploader"];
if (group.ContainsUser(username))
{
// allow user to upload
}
I could not figure out who I can do that. Please advise.
You can do that.
Visit https://social.msdn.microsoft.com/Forums/office/en-US/65066c08-9924-4935-9bba-f715b75d3fac/how-to-check-if-user-exists-in-a-particular-sharepoint-group-or-not-programatically?forum=sharepointdevelopmentprevious