Say that i have an active directory group called "Group1". I add this Group1 to a SharePoint site ( People and Group >> New User).
All the users that are part of Group1 can now access sharepoint site.
Now,for a specific custom webpart, i need to target to only users who belong to开发者_如何学编程 Group1. But when a user who belongs to Group1 logs into the sharepoint site, i am not finding a way to determine from within SharePoint context if this user belongs to Group1. Any thoughts?
Thanks, Faiz
Use the following code to check if the current user is in the given security group:
WindowsIdentity wi = WindowsIdentity.GetCurrent();
WindowsPrincipal wp = new WindowsPrincipal(wi);
wp.IsInRole("Group1");
精彩评论