Hi there,
I am trying to check the loggged in user is exsist in AD group(TestMF) or not in sharepoint online.But on rest api does not gives any sign of users.Pls suggest me any idea to find logged users exsist in AD group.
regards
Gowtham.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ronika JencyRank #770 · 3K reputationPosted Nov 17, 2019, 6:47 PM EST
Dinesh GabhaneRank #265 · 9.5K reputationPosted Nov 17, 2019, 6:50 PM EST
First you can get the identity of the user which you want to know, then use the user’s token to log into the SharePoint, finally call SPGroup.ContainsCurrentUser for that user. The code is as follows:
using(SPWeb web=site.OpenWeb())
{
user=web.EnsureUser("domain\\username");
}
using (SPSite site1 = new SPSite("http://site/",user.UserToken))
In addition to that, you can also use SPWeb.IsCurrentUserMemberOfGroup to know whether the current user is a member of the specified group.
For more information about SPWeb.IsCurrentUserMemberOfGroup Method, please refer to the following articles:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.iscurrentusermemberofgroup.aspx
http://fabioscagliola.spaces.live.com/blog/cns!919F8FCDE3DC9AC4!195.entry