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 + "
"
);
}

No comments:

 
Sell my car, Used car for sale, Free Automotive Classifieds