C# Class Microsoft.SharePoint.Client.ExternalSharingExtensions

Show file Open project: OfficeDev/PnP-Sites-Core

Public Methods

Method Description
CreateAnonymousLinkForDocument ( this web, string urlToDocument, ExternalSharingDocumentOption shareOption ) : string

Creates anonymous link to given document. See MSDN

CreateAnonymousLinkWithExpirationForDocument ( this web, string urlToDocument, ExternalSharingDocumentOption shareOption, System.DateTime expireTime ) : string

Creates anonymous link to the given document with automatic expiration time. See MSDN

GetObjectSharingSettingsForDocument ( this web, string urlToDocument, bool useSimplifiedPolicies = true ) : ObjectSharingSettings

Get current sharing settings for document and load list of users it has been shared automatically.

GetObjectSharingSettingsForSite ( this web, bool useSimplifiedPolicies = true ) : ObjectSharingSettings

Get current sharing settings for site and load list of users it has been shared automatically.

InviteExternalUser ( this group, string email, bool sendEmail = true, string emailBody = "Site shared with you." ) : SharingResult

Invites an external user as a group member

ResolvePeoplePickerValueForEmail ( this web, string emailAddress ) : string

Can be used to get needed people picker search result value for given email account. See MSDN

ShareDocument ( this web, string urlToDocument, string targetEmailToShare, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared", bool useSimplifiedRoles = true ) : SharingResult

Abstracted methid for sharing documents just with given email address.

ShareDocumentWithPeoplePickerValue ( this web, string urlToDocument, string peoplePickerInput, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared for you.", bool useSimplifiedRoles = true ) : SharingResult

Share document with complex JSON string value.

ShareSite ( this web, string email, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true ) : SharingResult

Share site for a person using just email. Will resolve needed people picker JSON value automatically.

ShareSite ( this web, string email, Group group, bool sendEmail = true, string emailBody = "Site shared for you." ) : SharingResult

Share site for a person using just email. Will resolve needed people picker JSON value automatically.

ShareSiteWithPeoplePickerValue ( this web, string peoplePickerInput, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true ) : SharingResult

Share site for a person using complex JSON object for people picker value.

ShareSiteWithPeoplePickerValue ( this web, string peoplePickerInput, Group group, bool sendEmail = true, string emailBody = "Site shared for you." ) : SharingResult

Share site for a person using complex JSON object for people picker value.

UnshareDocument ( this web, string urlToDocument ) : SharingResult

Can be used to programatically to unshare any document with the document URL.

Private Methods

Method Description
SolveGroupIdToShare ( Web web, ExternalSharingSiteOption shareOption ) : int

Used to solve right group ID to assign user into - used for the site level sharing.

Method Details

CreateAnonymousLinkForDocument() public static method

Creates anonymous link to given document. See MSDN
public static CreateAnonymousLinkForDocument ( this web, string urlToDocument, ExternalSharingDocumentOption shareOption ) : string
web this Web for the context used for people picker search
urlToDocument string Full URL to the file which is shared
shareOption ExternalSharingDocumentOption Type of the link to be created - View or Edit
return string

CreateAnonymousLinkWithExpirationForDocument() public static method

Creates anonymous link to the given document with automatic expiration time. See MSDN
public static CreateAnonymousLinkWithExpirationForDocument ( this web, string urlToDocument, ExternalSharingDocumentOption shareOption, System.DateTime expireTime ) : string
web this Web for the context used for people picker search
urlToDocument string Full URL to the file which is shared
shareOption ExternalSharingDocumentOption Type of the link to be created - View or Edit
expireTime System.DateTime Date time for link expiration - will be converted to ISO 8601 format automatically
return string

GetObjectSharingSettingsForDocument() public static method

Get current sharing settings for document and load list of users it has been shared automatically.
public static GetObjectSharingSettingsForDocument ( this web, string urlToDocument, bool useSimplifiedPolicies = true ) : ObjectSharingSettings
web this Web for the context
urlToDocument string
useSimplifiedPolicies bool
return ObjectSharingSettings

GetObjectSharingSettingsForSite() public static method

Get current sharing settings for site and load list of users it has been shared automatically.
public static GetObjectSharingSettingsForSite ( this web, bool useSimplifiedPolicies = true ) : ObjectSharingSettings
web this Web for the context
useSimplifiedPolicies bool
return ObjectSharingSettings

InviteExternalUser() public static method

Invites an external user as a group member
public static InviteExternalUser ( this group, string email, bool sendEmail = true, string emailBody = "Site shared with you." ) : SharingResult
group this Group to add the user to
email string The email address of the external user
sendEmail bool Should we send an email to the given address
emailBody string Text to be added to the email
return SharingResult

ResolvePeoplePickerValueForEmail() public static method

Can be used to get needed people picker search result value for given email account. See MSDN
public static ResolvePeoplePickerValueForEmail ( this web, string emailAddress ) : string
web this Web for the context used for people picker search
emailAddress string Email address to be used as the query parameter. Should be pointing to unique person which is then searched using people picker capability programatically.
return string

ShareDocument() public static method

Abstracted methid for sharing documents just with given email address.
public static ShareDocument ( this web, string urlToDocument, string targetEmailToShare, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared", bool useSimplifiedRoles = true ) : SharingResult
web this Web for the context used for people picker search
urlToDocument string Full URL to the file which is shared
targetEmailToShare string Email address for the person to whom the document will be shared
shareOption ExternalSharingDocumentOption View or Edit option
sendEmail bool Send email or not
emailBody string Text attached to the email sent for the person to whom the document is shared
useSimplifiedRoles bool Boolean value indicating whether to use the SharePoint simplified roles (Edit, View)
return SharingResult

ShareDocumentWithPeoplePickerValue() public static method

Share document with complex JSON string value.
public static ShareDocumentWithPeoplePickerValue ( this web, string urlToDocument, string peoplePickerInput, ExternalSharingDocumentOption shareOption, bool sendEmail = true, string emailBody = "Document shared for you.", bool useSimplifiedRoles = true ) : SharingResult
web this Web for the context used for people picker search
urlToDocument string Full URL to the file which is shared
peoplePickerInput string People picker JSON string value containing the target person information
shareOption ExternalSharingDocumentOption View or Edit option
sendEmail bool Send email or not
emailBody string Text attached to the email sent for the person to whom the document is shared
useSimplifiedRoles bool Boolean value indicating whether to use the SharePoint simplified roles (Edit, View)
return SharingResult

ShareSite() public static method

Share site for a person using just email. Will resolve needed people picker JSON value automatically.
public static ShareSite ( this web, string email, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true ) : SharingResult
web this Web for the context of the site to be shared.
email string Email of the person to whom site should be shared.
shareOption ExternalSharingSiteOption Sharing style - View, Edit, Owner
sendEmail bool Should we send email for the given address.
emailBody string Text to be added on share email sent to receiver.
useSimplifiedRoles bool Boolean value indicating whether to use the SharePoint simplified roles (Edit, View)
return SharingResult

ShareSite() public static method

Share site for a person using just email. Will resolve needed people picker JSON value automatically.
public static ShareSite ( this web, string email, Group group, bool sendEmail = true, string emailBody = "Site shared for you." ) : SharingResult
web this Web for the context of the site to be shared.
email string Email of the person to whom site should be shared.
group Group Group to invite the external user to
sendEmail bool Should we send email for the given address.
emailBody string Text to be added on share email sent to receiver.
return SharingResult

ShareSiteWithPeoplePickerValue() public static method

Share site for a person using complex JSON object for people picker value.
public static ShareSiteWithPeoplePickerValue ( this web, string peoplePickerInput, ExternalSharingSiteOption shareOption, bool sendEmail = true, string emailBody = "Site shared for you.", bool useSimplifiedRoles = true ) : SharingResult
web this Web for the context of the site to be shared.
peoplePickerInput string JSON object with the people picker value
shareOption ExternalSharingSiteOption Sharing style - View, Edit, Owner
sendEmail bool Should we send email for the given address.
emailBody string Text to be added on share email sent to receiver.
useSimplifiedRoles bool Boolean value indicating whether to use the SharePoint simplified roles (Edit, View)
return SharingResult

ShareSiteWithPeoplePickerValue() public static method

Share site for a person using complex JSON object for people picker value.
public static ShareSiteWithPeoplePickerValue ( this web, string peoplePickerInput, Group group, bool sendEmail = true, string emailBody = "Site shared for you." ) : SharingResult
web this Web for the context of the site to be shared.
peoplePickerInput string JSON object with the people picker value
group Group The group to invite the user to
sendEmail bool Should we send email for the given address.
emailBody string Text to be added on share email sent to receiver.
return SharingResult

UnshareDocument() public static method

Can be used to programatically to unshare any document with the document URL.
public static UnshareDocument ( this web, string urlToDocument ) : SharingResult
web this Web for the context used for people picker search
urlToDocument string Full URL to the file which is shared
return SharingResult