using (SPSite oSite = new SPSite(SPContext.Current.Site.Url))
{
foreach (SPWeb oWeb in oSite.RootWeb.GetSubwebsForCurrentUser())
{
permission = string.Empty;
foreach (SPGroup group in oWeb.Groups)
{
foreach (SPUser u in group.Users)
{
if (u.Name == (userName))
{
foreach (SPRole role in u.Roles)
{
permission += role.Name.ToString() + ", ";
}
}
} // Taking All Permission details of user
}
permission = " [" + permission.TrimEnd(", ".ToCharArray()) + "]";
}
}
我的最终字符串变量将具有类似[Read, Visitor]
或[Read]
或的值[visitor, Read]
我想拥有所有权限名称,实际上我在 u.Roles [Roles is absolute now] 上收到错误/警告,
SPRoleDefination
通过使用等
帮助我获得许可SPRoleDefinitionCollectionroleDefinitions = oWeb.RoleDefinitions;
SPRoleDefinitionroleDefinition
谢谢普拉文