Well I have achieved this by using SPRoles, but as all knows SPRoles has been deprecated from September 2012, giving warning user SPRoleAssignment and SPRoleDefinition class.
Its a bit confusing so lets understand about SPRoleDefinition and SPRoleAssignment.
SPRoleDefinition represents the SharePoint OOB permission levels like "Full Control", "Contribute", "Read"while a Role Assignment contains a collection of Role Definitions ItemAdd, ItemView, UpdateItem, EditPage etc....
Here is a simple code snippet to get current user's / give user's permissions
It will return users permission from all sites on which user has permission in format of [Read, Contribute] / [Read] / [Full Control]
oUser is SPUser object that has user details you can pass Currentuser also by using below lines:
SPUser ouser = SPContext.Current.Web.CurrentUser;
Its a bit confusing so lets understand about SPRoleDefinition and SPRoleAssignment.
SPRoleDefinition represents the SharePoint OOB permission levels like "Full Control", "Contribute", "Read"while a Role Assignment contains a collection of Role Definitions ItemAdd, ItemView, UpdateItem, EditPage etc....
Here is a simple code snippet to get current user's / give user's permissions
Code:
It will return users permission from all sites on which user has permission in format of [Read, Contribute] / [Read] / [Full Control]
oUser is SPUser object that has user details you can pass Currentuser also by using below lines:
SPUser ouser = SPContext.Current.Web.CurrentUser;
Please share any issue or findings on this.
--
Regards,
Praveen Pandit
No comments:
Post a Comment