C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Programmatically Check whether Current Logged in User is a Member of SharePoint User Group or Not
WhatsApp
Abhay Shanker
11y
42.7
k
0
1
25
Blog
SharePoint Custom development requires to check whether the current logged in user is a member of any particular SharePoint User Group or not. We can solve this issue by using the code block given below.
bool
isMember =
false
;
SPSecurity.RunWithElevatedPrivileges(
delegate
{
using
(SPSite site =
new
SPSite(
"http://siteurl"
))
{
SPWeb web = site.RootWeb;
string
groupName =
"Site Group Name"
;
var spGroup = web.Groups[groupName];
isMember = web.IsCurrentUserMemberOfGroup(spGroup.ID);
}
});
People also reading
Membership not found