Class ExternalSharingExtensions
This class holds the methods for sharing and unsharing of the document and the site.
Inheritance
Namespace: Microsoft.SharePoint.Client
Assembly: PnP.Framework.dll
Syntax
public static class ExternalSharingExtensions : object
Methods
CreateAnonymousLinkForDocument(Web, String, ExternalSharingDocumentOption)
Creates anonymous link to given document. See MSDN
Declaration
public static string CreateAnonymousLinkForDocument(this Web web, string urlToDocument, ExternalSharingDocumentOption shareOption)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
External Type of the link to be created - View or Edit |
Returns
System. Anonymous URL to the file as string |
CreateAnonymousLinkForDocumentAsync(Web, String, ExternalSharingDocumentOption)
Creates anonymous link to given document. See MSDN
Declaration
public static async Task<string> CreateAnonymousLinkForDocumentAsync(this Web web, string urlToDocument, ExternalSharingDocumentOption shareOption)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
External Type of the link to be created - View or Edit |
Returns
Task<System. Anonymous URL to the file as string |
CreateAnonymousLinkWithExpirationForDocument(Web, String, ExternalSharingDocumentOption, DateTime)
Creates anonymous link to the given document with automatic expiration time. See MSDN
Declaration
public static string CreateAnonymousLinkWithExpirationForDocument(this Web web, string urlToDocument, ExternalSharingDocumentOption shareOption, DateTime expireTime)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
External Type of the link to be created - View or Edit |
Date Date time for link expiration - will be converted to ISO 8601 format automatically |
Returns
System. Anonymous URL to the file as string |
CreateAnonymousLinkWithExpirationForDocumentAsync(Web, String, ExternalSharingDocumentOption, DateTime)
Creates anonymous link to the given document with automatic expiration time. See MSDN
Declaration
public static async Task<string> CreateAnonymousLinkWithExpirationForDocumentAsync(this Web web, string urlToDocument, ExternalSharingDocumentOption shareOption, DateTime expireTime)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
External Type of the link to be created - View or Edit |
Date Date time for link expiration - will be converted to ISO 8601 format automatically |
Returns
Task<System. Anonymous URL to the file as string |
GetObjectSharingSettingsForDocument(Web, String, Boolean)
Get current sharing settings for document and load list of users it has been shared automatically.
Declaration
public static ObjectSharingSettings GetObjectSharingSettingsForDocument(this Web web, string urlToDocument, bool useSimplifiedPolicies = true)
Parameters
Web
web
Web for the context |
System. Full URL to the file which is shared |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View). |
Returns
Object A ObjectSharingSettings object |
GetObjectSharingSettingsForDocumentAsync(Web, String, Boolean)
Get current sharing settings for document and load list of users it has been shared automatically.
Declaration
public static async Task<ObjectSharingSettings> GetObjectSharingSettingsForDocumentAsync(this Web web, string urlToDocument, bool useSimplifiedPolicies = true)
Parameters
Web
web
Web for the context |
System. Full URL to the file which is shared |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View). |
Returns
Task<Object A ObjectSharingSettings object |
GetObjectSharingSettingsForSite(Web, Boolean)
Get current sharing settings for site and load list of users it has been shared automatically.
Declaration
public static ObjectSharingSettings GetObjectSharingSettingsForSite(this Web web, bool useSimplifiedPolicies = true)
Parameters
Web
web
Web for the context |
System.
|
Returns
Object A ObjectSharingSettings object |
GetObjectSharingSettingsForSiteAsync(Web, Boolean)
Get current sharing settings for site and load list of users it has been shared automatically.
Declaration
public static async Task<ObjectSharingSettings> GetObjectSharingSettingsForSiteAsync(this Web web, bool useSimplifiedPolicies = true)
Parameters
Web
web
Web for the context |
System.
|
Returns
Task<Object A ObjectSharingSettings object |
InviteExternalUser(Group, String, Boolean, String)
Invites an external user as a group member
Declaration
public static SharingResult InviteExternalUser(this Group group, string email, bool sendEmail = true, string emailBody = "Site shared with you.")
Parameters
Group
group
Group to add the user to |
System. The email address of the external user |
System. Should we send an email to the given address |
System. Text to be added to the email |
Returns
Sharing A SharingResult object |
InviteExternalUserAsync(Group, String, Boolean, String)
Invites an external user as a group member
Declaration
public static async Task<SharingResult> InviteExternalUserAsync(this Group group, string email, bool sendEmail = true, string emailBody = "Site shared with you.")
Parameters
Group
group
Group to add the user to |
System. The email address of the external user |
System. Should we send an email to the given address |
System. Text to be added to the email |
Returns
Task<Sharing A SharingResult object |
ResolvePeoplePickerValueForEmail(Web, String)
Can be used to get needed people picker search result value for given email account. See MSDN
Declaration
public static string ResolvePeoplePickerValueForEmail(this Web web, string emailAddress)
Parameters
Web
web
Web for the context used for people picker search |
System. Email address to be used as the query parameter. Should be pointing to unique person which is then searched using people picker capability programatically. |
Returns
System. Resolves people picker value which can be used for sharing objects in the SharePoint site |
ResolvePeoplePickerValueForEmailAsync(Web, String)
Can be used to get needed people picker search result value for given email account. See MSDN
Declaration
public static async Task<string> ResolvePeoplePickerValueForEmailAsync(this Web web, string emailAddress)
Parameters
Web
web
Web for the context used for people picker search |
System. Email address to be used as the query parameter. Should be pointing to unique person which is then searched using people picker capability programatically. |
Returns
Task<System. Resolves people picker value which can be used for sharing objects in the SharePoint site |
ShareDocument(Web, String, String, ExternalSharingDocumentOption, Boolean, String, Boolean)
Abstracted method for sharing documents just with given email address.
Declaration
public static SharingResult ShareDocument(this Web web, string urlToDocument, string targetEmailToShare, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
System. Email address for the person to whom the document will be shared |
External View or Edit option |
System. Send email or not |
System. Text attached to the email sent for the person to whom the document is shared |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Sharing A SharingResult object |
ShareDocumentAsync(Web, String, String, ExternalSharingDocumentOption, Boolean, String, Boolean)
Abstracted method for sharing documents just with given email address.
Declaration
public static async Task<SharingResult> ShareDocumentAsync(this Web web, string urlToDocument, string targetEmailToShare, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
System. Email address for the person to whom the document will be shared |
External View or Edit option |
System. Send email or not |
System. Text attached to the email sent for the person to whom the document is shared |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Task<Sharing A SharingResult object |
ShareDocumentWithPeoplePickerValue(Web, String, String, ExternalSharingDocumentOption, Boolean, String, Boolean)
Share document with complex JSON string value.
Declaration
public static SharingResult ShareDocumentWithPeoplePickerValue(this Web web, string urlToDocument, string peoplePickerInput, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared for you.", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
System. People picker JSON string value containing the target person information |
External View or Edit option |
System. Send email or not |
System. Text attached to the email sent for the person to whom the document is shared |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Sharing A SharingResult object |
ShareDocumentWithPeoplePickerValueAsync(Web, String, String, ExternalSharingDocumentOption, Boolean, String, Boolean)
Share document with complex JSON string value.
Declaration
public static async Task<SharingResult> ShareDocumentWithPeoplePickerValueAsync(this Web web, string urlToDocument, string peoplePickerInput, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared for you.", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
System. People picker JSON string value containing the target person information |
External View or Edit option |
System. Send email or not |
System. Text attached to the email sent for the person to whom the document is shared |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Task<Sharing A SharingResult object |
ShareSite(Web, String, Group, Boolean, String)
Share site for a person using just email. Will resolve needed people picker JSON value automatically.
Declaration
public static SharingResult ShareSite(this Web web, string email, Group group, bool sendEmail = true, string emailBody = "Site shared for you.")
Parameters
Web
web
Web for the context of the site to be shared. |
System. Email of the person to whom site should be shared. |
Group
group
Group to invite the external user to |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
Returns
Sharing A SharingResult object |
ShareSite(Web, String, ExternalSharingSiteOption, Boolean, String, Boolean)
Share site for a person using just email. Will resolve needed people picker JSON value automatically.
Declaration
public static SharingResult ShareSite(this Web web, string email, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context of the site to be shared. |
System. Email of the person to whom site should be shared. |
External Sharing style - View, Edit, Owner |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Sharing A SharingResult object |
ShareSiteAsync(Web, String, Group, Boolean, String)
Share site for a person using just email. Will resolve needed people picker JSON value automatically.
Declaration
public static async Task<SharingResult> ShareSiteAsync(this Web web, string email, Group group, bool sendEmail = true, string emailBody = "Site shared for you.")
Parameters
Web
web
Web for the context of the site to be shared. |
System. Email of the person to whom site should be shared. |
Group
group
Group to invite the external user to |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
Returns
Task<Sharing A SharingResult object |
ShareSiteAsync(Web, String, ExternalSharingSiteOption, Boolean, String, Boolean)
Share site for a person using just email. Will resolve needed people picker JSON value automatically.
Declaration
public static async Task<SharingResult> ShareSiteAsync(this Web web, string email, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context of the site to be shared. |
System. Email of the person to whom site should be shared. |
External Sharing style - View, Edit, Owner |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Task<Sharing A SharingResult object |
ShareSiteWithPeoplePickerValue(Web, String, Group, Boolean, String)
Share site for a person using complex JSON object for people picker value.
Declaration
public static SharingResult ShareSiteWithPeoplePickerValue(this Web web, string peoplePickerInput, Group group, bool sendEmail = true, string emailBody = "Site shared for you.")
Parameters
Web
web
Web for the context of the site to be shared. |
System. JSON object with the people picker value |
Group
group
The group to invite the user to |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
Returns
Sharing A SharingResult object |
ShareSiteWithPeoplePickerValue(Web, String, ExternalSharingSiteOption, Boolean, String, Boolean)
Share site for a person using complex JSON object for people picker value.
Declaration
public static SharingResult ShareSiteWithPeoplePickerValue(this Web web, string peoplePickerInput, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context of the site to be shared. |
System. JSON object with the people picker value |
External Sharing style - View, Edit, Owner |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Sharing A SharingResult object |
ShareSiteWithPeoplePickerValueAsync(Web, String, Group, Boolean, String)
Share site for a person using complex JSON object for people picker value.
Declaration
public static async Task<SharingResult> ShareSiteWithPeoplePickerValueAsync(this Web web, string peoplePickerInput, Group group, bool sendEmail = true, string emailBody = "Site shared for you.")
Parameters
Web
web
Web for the context of the site to be shared. |
System. JSON object with the people picker value |
Group
group
The group to invite the user to |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
Returns
Task<Sharing A SharingResult object |
ShareSiteWithPeoplePickerValueAsync(Web, String, ExternalSharingSiteOption, Boolean, String, Boolean)
Share site for a person using complex JSON object for people picker value.
Declaration
public static async Task<SharingResult> ShareSiteWithPeoplePickerValueAsync(this Web web, string peoplePickerInput, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true)
Parameters
Web
web
Web for the context of the site to be shared. |
System. JSON object with the people picker value |
External Sharing style - View, Edit, Owner |
System. Should we send email for the given address. |
System. Text to be added on share email sent to receiver. |
System. Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
Task<Sharing A SharingResult object |
UnshareDocument(Web, String)
Can be used to programatically to unshare any document with the document URL.
Declaration
public static SharingResult UnshareDocument(this Web web, string urlToDocument)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
Returns
Sharing A SharingResult object |
UnshareDocumentAsync(Web, String)
Can be used to programatically to unshare any document with the document URL.
Declaration
public static async Task<SharingResult> UnshareDocumentAsync(this Web web, string urlToDocument)
Parameters
Web
web
Web for the context used for people picker search |
System. Full URL to the file which is shared |
Returns
Task<Sharing A SharingResult object |