Showing posts with label Security. Show all posts
Showing posts with label Security. Show all posts

Monday, August 18, 2008

SPSite.RootWeb.AllUsers | SiteUsers | Users - Difference

We can get list of users (SPUserCollection) based on the following objects.

SPSite.RootWeb.AllUsers
SPSite.RootWeb.SiteUsers
SPSite.RootWeb.Users

"AllUsers" - Gets the collection of users from either member of the site or or who have browsed to the site as authenticated members of a domain group in the site.

"SiteUsers - Gets the collection of all users that belong to the site collection.

"Users" - Gets the collection of user objects that are explicitly assigned permissions on the Web site.

SPPrincipal - SPUser - SPWeb.EnsureUser() - SPUtility.ResolvePrincipal()

SPUtility.ResolvePrincipal() method to fetch details about the user by passing "first, last name" or "user email id" or "user login id".

SPPrincipalInfo object is used to hold user details like, first name, last name, email id, login id with domain name.

SPPrincipalInfo userInfo = SPUtility.ResolvePrincipal(objWeb, "loginID", SPPrincipalType.All, SPPrincipalSource.All, null, false);

------------------------------------------------------------------------------------------------

SPWeb.EnsuerUser() will add ther user to site, if the user does not exist and return SPUser object. We can use SPUser object to update "SPUser" field type
Example:
SPUser objUser = objWeb.EnsureUser("domain\\loginname");
item["user"] = objUser;

-----------------------------------------------------------------------------------------------

Friday, July 11, 2008

Limited Access Permission

The Limited Access permission level is designed to be combined with fine-grained permissions to give users access to a specific list, document library, item, or document, without giving them access to the entire site. However, to access a list or library, for example, a user must have permission to open the parent Web site and read shared data such as the theme and navigation bars of the Web site. The Limited Access permission level cannot be customized or deleted.

NOTE You cannot assign this permission level to users or SharePoint groups. Instead, Windows SharePoint Services 3.0 automatically assigns this permission level to users and SharePoint groups when you grant them access to an object on your site that requires that they have access to a higher level object on which they do not have permissions. For example, if you grant users access to an item in a list and they do not have access to the list itself, Windows SharePoint Services 3.0 automatically grants them Limited Access on the list, and also the site, if needed.

Tuesday, May 27, 2008

SPSecurity.RunWithElevatedPrivileges Method

Executes set of code with Full Privilege even if the user does not having Full Privilege.

Define an anonymous method to implement. Example,

SPSecurity.RunWithElevatedPrivileges(delegate()
{
// Your Code
});