11

In the server side object model it's possible to set the request access email address through the property SPWeb.RequestAccessEmail (MSDN).

Since we are moving our SharePoint tenant to Office365 I'm looking for a way to set this value. I know it's possible to do so manually in the UI (Site Settings > Site Permissions > Access Request Settings) but since we have some self-service site creation, it's not possible to change it manually each time a web has been created.

Unfortunately there is no property Web.RequestAccessEmail in the client side object model.

Is there a way to set this email address through the property bag (aka Web.AllProperties["__SecretKey"]), a web service (_vti_bin, etc.) or any other workaround?

Any help is highly appreciated!

8

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.

  • Could you specify the cmdlet to use? I do not see anything in Set-SPOSite... – grisha Nov 26 '15 at 18:02
  • @grisha Try Set-SPOWeb -RequestAccessEmail "mail@domain.com" – Stefan Born Nov 27 '15 at 21:02
  • Thank you, Stefan, but still no :( I tried reinstalling Powershell on 2 different machines and the cmdlet is still not available. I posted it as a separate question here sharepoint.stackexchange.com/questions/163693/… Please kindly help if you have any suggestions – grisha Dec 1 '15 at 9:53
  • 1
    @grisha It was just a guess. I have no experience with the PowerShell commands. I just use the Microsoft.SharePoint.Client.dll out of this package and use it from my C# code. – Stefan Born Dec 1 '15 at 11:31
2

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();
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.