Windows SharePoint Services 3.0 implements new types in its object model to support the new security model.
Old model is obsolete but keep beeing usable.
In Windows SharePoint Services 3.0 or MOSS 2007 sites, you have sometimes to check user, Permissions, Rights, Roles, when loading a page, doing an action, and decide what to do depending on these Permissions.
all these Classes are obosolete :
Code Sample :
-
SPPermission
SPRole
SPRights
-
SPSite.CheckPermissions
SPSite.DoesUserHavePermissions
SPWeb.CheckPermissions
SPWeb.DoesUserHavePermissions
SPList.CheckPermissions
SPList.DoesUserHavePermissions
SPListItem.CheckPermissions
SPListItem.DoesUserHavePermissions
...
SPWeb myWeb = SPContext.Current.Site.OpenWeb();
if (myWeb.DoesUserHavePermissions("DomainName\\user1", SPBasePermissions.EditListItems))
{
System.Diagnostics.Debug.WriteLine("user1 can edit lisItems");
}
else
{
System.Diagnostics.Debug.WriteLine("user1 cannot edit lisItems");
}
if you are puzzled by "System.Diagnostics.Debug.." and want to know more about DebugView, see...
Use DebugView in Windows SharePoint Services 3.0 programming.
Use DebugView in Windows SharePoint Services 3.0 programming.
4 comments:
Our company developed a small web part for determining effective permissions for the users around SharePoint sites. You can read more about it at http://bit.ly/cOe6oT or download it free from our company site http://www.myitechnology.com
Hope it will be helpful for most of you!
Can we findout the permission on a web application using code? Every blog mentions the permission check from site collection to item level. I want whether user has permission on a SPWebapplication.
It has taken me ages to discover your site. Finally. This is just the information I was looking for.
Thanks for the nice article, Have a look at the article "Check User Permissions Programmatically in SharePoint 2010"
at http://tad.co.in/?p=748
Post a Comment