2012-04-11 67 views

回答

3

需要AD安全组成员资格和SharePoint组成员区分。

为了检查AD安全会员,您可以使用System.Security.Principal.WindowsPrincipal.IsInRole。你不需要使用SharePoint API:

using(WindowsIdentity identity = WindowsIdentity.GetCurrent()) 
{ 
    WindowsPrincipal p = new WindowsPrincipal(identity); 
    if (p.IsInRole("DOMAIN\\GroupName")) // Alternative overloads with SecurityIdentifier available 
    { 
    // ... 
    } 
} 

要检查当前用户是SharePoint组的成员可以使用SharePoint API:

SPWeb web = // ... 
SPGroup group = web.SiteGroups["GroupName"]; 
if (group.ContainsCurrentUser) 
{ 
    // ... 
} 
相关问题