Imposta richiesta Accesso indirizzo email tramite CSOM
-
10-12-2019 - |
Domanda
Nel modello dell'oggetto lato server è possibile impostare l'indirizzo email di richiesta di accesso tramite la proprietà SPWeb.RequestAccessEmail
( MSDN ).
Dal momento che stiamo spostando il nostro tenant di SharePoint per Office365 Sto cercando un modo per impostare questo valore.So che è possibile farlo manualmente nell'interfaccia utente (impostazioni del sito> Autorizzazioni del sito> Impostazioni di richiesta di accesso) Ma poiché abbiamo una creazione di siti self-service, non è possibile cambiarlo manualmente ogni volta che un Web è stato creato.
. Sfortunatamente non ci sono proprietà Web.RequestAccessEmail
nel modello dell'oggetto laterale client.
C'è un modo per impostare questo indirizzo email attraverso la borsa della proprietà (AKA Web.AllProperties["__SecretKey"]
), un servizio Web (_vti_bin
, ecc.) O qualsiasi altra soluzione alternativa?
Qualsiasi aiuto è molto apprezzato!
Soluzione
In the newest release of the "SharePoint Online Management Shell" (v16.0.4630.1200) the included Microsoft.SharePoint.Client.dll
adds the property RequestAccessEmail
to the Web
class.
Download: https://www.microsoft.com/en-us/download/details.aspx?id=35588
You may use this DLL until the NuGet-Package is released.
EDIT: Since version 16.1.4727.1200
of the Microsoft.SharePointOnline.CSOM
NuGet-Package the RequestAccessEmail
property is supported.
Altri suggerimenti
Unfortunately this property is not accessible via CSOM
.
How to retrieve all available properties for Web client object:
var allProperties = clientContext.Web.AllProperties;
clientContext.Load(allProperties);
clientContext.ExecuteQuery();
This is possible but in my opinion a hack. I wrote an article to discuss if this is a valid way to do it - Manipulating SharePoint UI over an IFrame to add missing clientside Features
Here's the Code:
//quite dirty hack but at this point the only possibility to set the AccessRequest mail via clientside
function setAccessRequest(mail) {
var iframe = document.createElement('iframe');
//set the setrqacc.aspx link
var setrqaccUrl = _spPageContextInfo.webAbsoluteUrl + '/_layouts/15/setrqacc.aspx?type=web';
//create setrqacc.aspx hidden iframe
iframe.setAttribute('src', setrqaccUrl);
iframe.setAttribute('style', 'display:none');
iframe.onload = function () {
//this will fire 2 times - the first time when its initially loaded. the second after the changes were applied (page is reloaded (postback) after the submitbutton is triggered)
var $iframeInput = $('input[id*="_txtEmail"]', $(iframe).contents());
if ($iframeInput.length) {
//initial load - apply settings
$iframeInput.val(mail);
//gets iframeInput's parent so the current input can be placed inside
var $iframeBtn = $('input[id*="_btnSubmit"]', $(iframe).contents());
//trigger the post
$iframeBtn.trigger('click');
} else {
//second load - do callback
callback('AccessRequest');
}
};
document.body.appendChild(iframe);
}
It should be wrapped in a waitingdialog and some warnings when the user tries to exit the page. Loading a page in an IFrame can take some time and this code is doing it twice.