[SharePoint] Gets the user's permissions based on the user name

Source: Internet
Author: User

Write in front

In such a scenario, the client requests the rest API of SharePoint, but does not allow the transfer of the user's password, using the method of certificate authentication, but so that all users use the same certificate, so that the result is not to identify whether the user has operations, and query permissions. Here is an issue that is encountered in the actual project. Make a note of the solution.

Solution Solutions
 Try{clientcontext SpContext=NewClientContext ("http://xxxx/xxx/xxx"); Spcontext.executingwebrequest+=spcontext_executingwebrequest; varList = SpContext.Web.Lists.GetByTitle ("Test");                Spcontext.load (list);                Spcontext.executequery (); varpermissions = list. Getusereffectivepermissions (@"i:0#.w|domain\test15");                Spcontext.executequery (); foreach(varPermissioninchEnum.getvalues (typeof(Permissionkind)). Cast<permissionkind>())                {                    varPermissionname = Enum.getname (typeof(permissionkind), permission); varHaspermission =permissions.                    Value.has (permission); Debug.WriteLine ("Permission: {0}, Haspermission: {1}", Permissionname, haspermission); }            }            Catch(Exception) {Throw; }

In the callback method, with certificate authentication

 voidSpcontext_executingwebrequest (Objectsender, Webrequesteventargs e) {HttpWebRequest Webreq=e.webrequestexecutor.webrequest; varAccesstoken = Tokenhelper.gets2saccesstokenwithwindowsidentity (NewUri ("http://xxx/xxx/xxxxx"),NULL); Webreq.method="Post"; Webreq.accept="Application/json;odata=verbose"; WEBREQ.HEADERS.ADD ("Authorization","Bearer"+Accesstoken); }

Then, depending on the permissions returned, refer to the
Spbasepermissions Enumeration

Determines whether the user has permissions, based on the value provided by the enumeration.

[SharePoint] Gets the user's permissions based on the user name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.