TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Check User Exist in SharePoint User Group
Ramakrishna Basagalla
Dec 02
2015
Code
6.5
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
How to check User exist in SharePoint User Group
// Function to check user exist in SharePoint Group
public
bool
CheckUserGroup(
string
groupName,
string
userName)
{
bool
userFound =
false
;
SPFieldUserValueCollection userCols =
new
SPFieldUserValueCollection();
SPSecurity.RunWithElevatedPrivileges(
delegate
()
{
SPSite objSite =
new
SPSite(SPContext.Current.Web.Url);
SPWeb objWeb = objSite.OpenWeb();
SPGroup spGroup = objWeb.SiteGroups[groupName];
foreach
(SPUser groupUser
in
spGroup.Users)
{
if
(groupUser.Name == userName)
{
userFound =
true
;
break
;
}
}
});
return
userFound;
}
// Calling function
bool
isUserAdmin = CheckUserGroup(
"Administrator"
,
"Ramakrishna Basagalla"
);
check User exist
SharePoint
User Group