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