check user access in the site using object model in sharepoint 2010
-
16 เมษายน 2555 7:29
I want to Get User Permissions(whether view/Contribute) for a particular site.
sree
- แก้ไขโดย sree_23 16 เมษายน 2555 7:47
ตอบทั้งหมด
-
16 เมษายน 2555 8:14ผู้ดูแล
Hi,
Instead of using VS, you can use sharepoint manager codeplex tool to view the sharepoint permission manager codeplex tool.
http://permissionsmanager.codeplex.com/
Let us know if it is helpful
Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
- ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 27 เมษายน 2555 8:22
-
16 เมษายน 2555 8:49ผู้ตอบ
Hello
For this, you need to check the role of the current user with something like this
SPWeb web = SPContext.Current.Web; SPRoleAssignment assignment = web.RoleAssignments.GetAssignmentByPrincipal((SPPrincipal) web.CurrentUser); foreach (SPRoleDefinition role in assignment.RoleDefinitionBindings) { //Check the role you are looking for and do your stuff }
Hope this help
- ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 27 เมษายน 2555 8:21
-
16 เมษายน 2555 18:28
You can use the oob SharePoint User Group web service to retrieve this data:
http://YourSite/_vti_bin/usergroup.asmx
List<string> userGorups = new List<string(); using (SharePoint_UserGroup.UserGroup proxy = new SharePoint_UserGroup.UserGroup()) { proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; proxy.Url = System.IO.Path.Combine(siteUrl, "_vti_bin/usergroup.asmx").Replace("\\", "/"); System.Xml.XmlNode ndGroups = proxy.GetGroupCollectionFromUser(userId); foreach (System.Xml.XmlNode xmlGroup in ndGroups.ChildNodes[0].ChildNodes) { string groupName =sharepointGroup, xmlGroup.Attributes["Name"].Value; userGorups.Add(groupName); } }K. http://www.sharepointwithattitude.com
- ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 27 เมษายน 2555 8:21
-
17 เมษายน 2555 6:22
check this blog which talks about getting base permissions for current user -
http://spdailytips.blogspot.in/2011/09/check-current-user-permission.html
ArchaHim
-
17 เมษายน 2555 7:51
Hi!
In what context are you searching for the user credentials? Is it in a webpart, page, timer job, code behind?
Sebastian | MCTS | MCPD | MCC