// SharePoint Groups that are Security Principals on this website
SPGroupCollection groups = web.Groups;
Response.Write("All SharePoint groups in this site: "+"
");
foreach (SPGroup group in groups)
{
Response.Write(group.Name + "
");
}
// All SharePoint Groups in this site collection
groups = web.SiteGroups;
Response.Write("All SharePoint groups in this site collection: " + "
"); foreach (SPGroup group in groups)
{
Response.Write(group.Name + "
");
}
Tuesday, January 13, 2009
Domain User and Group Security Principals
// All domain users and groups
// that are Security Principals for the website
// This is the list you see in /_layouts/user.aspx
SPUserCollection users = web.Users;
Response.Write("All domain user principals in this site: " + "
");
foreach (SPUser user in users)
{
Response.Write(user.Name + "
");
}
// All domain users and groups within the site collection
users = web.SiteUsers;
Response.Write("All users in this site collection: " + "
");
foreach (SPUser user in users)
{
Response.Write(user.Name + "
" );
}
// that are Security Principals for the website
// This is the list you see in /_layouts/user.aspx
SPUserCollection users = web.Users;
Response.Write("All domain user principals in this site: " + "
");
foreach (SPUser user in users)
{
Response.Write(user.Name + "
");
}
// All domain users and groups within the site collection
users = web.SiteUsers;
Response.Write("All users in this site collection: " + "
");
foreach (SPUser user in users)
{
Response.Write(user.Name + "
" );
}
Security Permission Inheritance
SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
// Test to see if the site has unique permissions
if (web.HasUniqueRoleAssignments)
{
Response.Write(web.Title + " does not inherit permissions
" );
}
else
{
Response.Write(web.Title + " inherits permissions
" );
}
SPWeb web = SPContext.Current.Web;
// Test to see if the site has unique permissions
if (web.HasUniqueRoleAssignments)
{
Response.Write(web.Title + " does not inherit permissions
" );
}
else
{
Response.Write(web.Title + " inherits permissions
" );
}
Subscribe to:
Posts (Atom)