0

I'm looking to disable the Anonymous links created on my OneDrive for Business site through the REST API I used to delete the Roleassignments for Sharepoint\Reader... or Sharepoint\Writer... which used to disable those VIEW/EDIT links, but that's not anymore. I am now getting special groups

SharingLinks.sdasda-dq70-4310-b700-94e86e86ec9b.AnonymousView.ce5d848e-165d-463e-a240-f7ec53d1e58

and I am using them to identify that my File's Edit/View link was created.

For disabling the link through REST API I did a POST with X-Http-Method as Delete and it removed the group as well. But the link stayed as is. Only when I disabled it through the UI then I noticed that a special user was unshared

c:0u.c|tenant|00468b2d8e1f4d4255875c0ddb5ebab20f7561e62968d7e3e936180b219cb036

this strange looking Title/LoginName has RoleTypeKind as 255. What exactly does 255 mean? I tried to rely on these special users for the identification of a Public exposure but they don't indicate anything about the type of Public Link they refer to. Any help would be appreciated.

2

You need to use the Web.DeleteAnonymousLinkForObject method to remove/unshare the link for anon users.

Code would be somewhat as below:

var url = _spPageContextInfo.webAbsoluteUrl + "/_api/SP.Web.DeleteAnonymousLinkForObject";
      console.log(url);
      $.ajax(
      {
          'url': url,
          'method': 'POST',
          'data': JSON.stringify({
             'url': _spPageContextInfo.webAbsoluteUrl + '/Shared Documents/test.txt',
             'isEditLink': true,
             'removeAssociatedSharingLinkGroup':true
          }),
          'headers': {
          'accept': 'application/json;odata=verbose',
          'content-type': 'application/json;odata=verbose',
          'X-RequestDigest': $('#__REQUESTDIGEST').val()
          },
          'success': function (data) {
                console.log(data);
                console.log("Success");
                //console.log(data.d.DeleteAnonymousLinkForObject);
          },
          'error': function (err) {
                console.log(JSON.stringify(err));
           }
      }
      );
     }
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.