このコードは適切ではありません:
web.IsCurrentUserMemberOfGroup(web.Groups["Namegruop"].ID);
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)
{
// ...
}