Web.ShareObject - Méthode (ClientRuntimeContext, String, String, String, Int32, Boolean, Boolean, Boolean, String, String)
Shares an object in SharePoint such as a document or site with external users.
Espace de noms : Microsoft.SharePoint.Client
Assemblys : Microsoft.SharePoint.Client.Silverlight (dans Microsoft.SharePoint.Client.Silverlight.dll); Microsoft.SharePoint.Client.Phone (dans Microsoft.SharePoint.Client.Phone.dll)
Syntaxe
'Déclaration
Public Shared Function ShareObject ( _
context As ClientRuntimeContext, _
url As String, _
peoplePickerInput As String, _
roleValue As String, _
groupId As Integer, _
propagateAcl As Boolean, _
sendEmail As Boolean, _
includeAnonymousLinkInEmail As Boolean, _
emailSubject As String, _
emailBody As String _
) As SharingResult
'Utilisation
Dim context As ClientRuntimeContext
Dim url As String
Dim peoplePickerInput As String
Dim roleValue As String
Dim groupId As Integer
Dim propagateAcl As Boolean
Dim sendEmail As Boolean
Dim includeAnonymousLinkInEmail As Boolean
Dim emailSubject As String
Dim emailBody As String
Dim returnValue As SharingResult
returnValue = Web.ShareObject(context, _
url, peoplePickerInput, roleValue, _
groupId, propagateAcl, sendEmail, _
includeAnonymousLinkInEmail, emailSubject, _
emailBody)
public static SharingResult ShareObject(
ClientRuntimeContext context,
string url,
string peoplePickerInput,
string roleValue,
int groupId,
bool propagateAcl,
bool sendEmail,
bool includeAnonymousLinkInEmail,
string emailSubject,
string emailBody
)
Paramètres
context
Type : Microsoft.SharePoint.Client.ClientRuntimeContext
url
Type : System.StringThe full URL of the website or document that is being shared. Examples:
// for sharing a website http://contoso.sharepoint.com/sites/extranet1 // for sharing a document https://contoso.sharepoint.com/sites/extranet1/shared%20documents/mydoc.xlsx
peoplePickerInput
Type : System.StringA string of JSON formatted data representing users in people picker format. The following is an example, but we recommend that you follow the guidance at External sharing API for SharePoint and OneDrive for Business and the code samples linked to it to learn how to generated this object.
[{ "Key" : "i:0#.f|membership|somebody.onmicrosoft.com#ext#@somedomain.com", "Description" : "myDomain.onmicrosoft.com#EXT#@somedomain.com", "DisplayText" : "Some Body", "EntityType" : "User", "ProviderDisplayName" : "Tenant", "ProviderName" : "Tenant", "IsResolved" : true, "EntityData" : { "MobilePhone" : "", "Email" : "somebody@myDomain.onmicrosoft.com", "Department" : "", "Title" : "somebody@myDomain.onmicrosoft.com", "PrincipalType" : "GUEST_USER" }, "MultipleMatches" : [] }]
roleValue
Type : System.StringThe sharing role value for the type of permission to grant on the object.
If you share a document you will need to use either of following values:
"role:1073741827"
”role:1073741826”
When you share a site, use following format. Replace the placeholder {groupId} with the unique group id from the site where external user will be assigned.
”group:{groupId}”
groupId
Type : System.Int32The ID of the group to be added to. Use zero if not adding to a permissions group. (Currently, this value is ignored.)
propagateAcl
Type : System.BooleanA flag to determine if permissions should be pushed to items with unique permissions.
sendEmail
Type : System.BooleanFlag to determine if an e-mail notification should to sent, if e-mail is configured.
includeAnonymousLinkInEmail
Type : System.BooleanIf an e-mail is being sent, this determines if an anonymous link should be added to the message.
emailSubject
Type : System.StringText for the subject line of the e-mail. (Currently, this value is ignored.)
emailBody
Type : System.StringText for the body of the e-mail.
Valeur renvoyée
Type : Microsoft.SharePoint.Client.SharingResult
A SharingResult object which contains completion script and an optional page to redirect to.
Remarques
For more information and a code sample, see External sharing API for SharePoint and OneDrive for Business the samples it links to.