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.String
urlToDocument
Full URL to the file which is shared |
|
ExternalSharingDocumentOption
shareOption
Type of the link to be created - View or Edit |
Returns
|
System.String
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.String
urlToDocument
Full URL to the file which is shared |
|
ExternalSharingDocumentOption
shareOption
Type of the link to be created - View or Edit |
Returns
|
Task<System.String>
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.String
urlToDocument
Full URL to the file which is shared |
|
ExternalSharingDocumentOption
shareOption
Type of the link to be created - View or Edit |
|
DateTime
expireTime
Date time for link expiration - will be converted to ISO 8601 format automatically |
Returns
|
System.String
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.String
urlToDocument
Full URL to the file which is shared |
|
ExternalSharingDocumentOption
shareOption
Type of the link to be created - View or Edit |
|
DateTime
expireTime
Date time for link expiration - will be converted to ISO 8601 format automatically |
Returns
|
Task<System.String>
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.String
urlToDocument
Full URL to the file which is shared |
|
System.Boolean
useSimplifiedPolicies
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View). |
Returns
|
ObjectSharingSettings
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.String
urlToDocument
Full URL to the file which is shared |
|
System.Boolean
useSimplifiedPolicies
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View). |
Returns
|
Task<ObjectSharingSettings>
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.Boolean
useSimplifiedPolicies
|
Returns
|
ObjectSharingSettings
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.Boolean
useSimplifiedPolicies
|
Returns
|
Task<ObjectSharingSettings>
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.String
email
The email address of the external user |
|
System.Boolean
sendEmail
Should we send an email to the given address |
|
System.String
emailBody
Text to be added to the email |
Returns
|
SharingResult
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.String
email
The email address of the external user |
|
System.Boolean
sendEmail
Should we send an email to the given address |
|
System.String
emailBody
Text to be added to the email |
Returns
|
Task<SharingResult>
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.String
emailAddress
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.String
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.String
emailAddress
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.String>
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.String
urlToDocument
Full URL to the file which is shared |
|
System.String
targetEmailToShare
Email address for the person to whom the document will be shared |
|
ExternalSharingDocumentOption
shareOption
View or Edit option |
|
System.Boolean
sendEmail
Send email or not |
|
System.String
emailBody
Text attached to the email sent for the person to whom the document is shared |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
SharingResult
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.String
urlToDocument
Full URL to the file which is shared |
|
System.String
targetEmailToShare
Email address for the person to whom the document will be shared |
|
ExternalSharingDocumentOption
shareOption
View or Edit option |
|
System.Boolean
sendEmail
Send email or not |
|
System.String
emailBody
Text attached to the email sent for the person to whom the document is shared |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
Task<SharingResult>
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.String
urlToDocument
Full URL to the file which is shared |
|
System.String
peoplePickerInput
People picker JSON string value containing the target person information |
|
ExternalSharingDocumentOption
shareOption
View or Edit option |
|
System.Boolean
sendEmail
Send email or not |
|
System.String
emailBody
Text attached to the email sent for the person to whom the document is shared |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
SharingResult
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.String
urlToDocument
Full URL to the file which is shared |
|
System.String
peoplePickerInput
People picker JSON string value containing the target person information |
|
ExternalSharingDocumentOption
shareOption
View or Edit option |
|
System.Boolean
sendEmail
Send email or not |
|
System.String
emailBody
Text attached to the email sent for the person to whom the document is shared |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
Task<SharingResult>
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.String
email
Email of the person to whom site should be shared. |
|
Group
group
Group to invite the external user to |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
Returns
|
SharingResult
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.String
email
Email of the person to whom site should be shared. |
|
ExternalSharingSiteOption
shareOption
Sharing style - View, Edit, Owner |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
SharingResult
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.String
email
Email of the person to whom site should be shared. |
|
Group
group
Group to invite the external user to |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
Returns
|
Task<SharingResult>
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.String
email
Email of the person to whom site should be shared. |
|
ExternalSharingSiteOption
shareOption
Sharing style - View, Edit, Owner |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
Task<SharingResult>
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.String
peoplePickerInput
JSON object with the people picker value |
|
Group
group
The group to invite the user to |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
Returns
|
SharingResult
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.String
peoplePickerInput
JSON object with the people picker value |
|
ExternalSharingSiteOption
shareOption
Sharing style - View, Edit, Owner |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
SharingResult
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.String
peoplePickerInput
JSON object with the people picker value |
|
Group
group
The group to invite the user to |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
Returns
|
Task<SharingResult>
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.String
peoplePickerInput
JSON object with the people picker value |
|
ExternalSharingSiteOption
shareOption
Sharing style - View, Edit, Owner |
|
System.Boolean
sendEmail
Should we send email for the given address. |
|
System.String
emailBody
Text to be added on share email sent to receiver. |
|
System.Boolean
useSimplifiedRoles
Boolean value indicating whether to use the SharePoint simplified roles (Edit, View) |
Returns
|
Task<SharingResult>
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.String
urlToDocument
Full URL to the file which is shared |
Returns
|
SharingResult
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.String
urlToDocument
Full URL to the file which is shared |
Returns
|
Task<SharingResult>
A SharingResult object |