问题
TL;DR:
How can I programatically share a SharePoint online folder with an external user such that the user only requires an access code and doesn't require a Microsoft account.
Full version: I'm using SharePoint online. I want to share folders within the SharedDocuments list with external users. This is simple from the SharePoint front end - select the folder, choose Share, enter external users email address and select Copy Link.
SharePoint will generate a url which I can send to the external user. The external user visits the url to request an access code to be sent via email. Entering the access code allows the user to access the folder. User doesn't need a Microsoft account. Perfect.
I want to implement this in code (c# and csom). Specifically I want to be able to specify a folder and external email address(s) and retrieve the sharing URL.
I've tried:
Microsoft.SharePoint.Client.Web.CreateOrganizationSharingLink()
clientContext.Web.ShareDocument()
DocumentSharingManager.UpdateDocumentSharingInfo()
WebSharingManager.UpdateWebSharingInformation()
These methods all generate a link - however the link requires a Microsoft account. It's different to the link generated in the UI (above).
Is it possible to generate the access-code only link?
回答1:
You can install this library from Nuget OfficeDevPnP.Core
. It includes an extension method for Web
object to create anonymous URL.
Usage:
string sharedUrl = web.CreateAnonymousLinkForDocument("directUrlToTheItem", ExternalSharingDocumentOption.View);
来源:https://stackoverflow.com/questions/56279481/how-to-share-a-sharepoint-folder-with-an-external-user-without-requiring-a-micro