none
Prevent Site Collection Administrators from adding other Site Collection Administrators via /_layouts/15/mngsiteadmin.aspx

    질문

  • I need to block SCAs from adding other SCAs via the /_layouts/15/mngsiteadmin.aspx page.  Changing COREV15.CSS file does not work if a site theme has changed since it no longer uses COREV15.CSS.  I think I can accomplish it using an event receiver but not sure which type of event receiver to use.  Microsoft.SharePoint.SPListEventReceiver, Microsoft.SharePoint.SPItemEventReceiver  or something else.  Any guidance is appreciated.

    Evy

    2018년 7월 11일 수요일 오후 5:07

답변

  • Hi Evy,

    Per my knowledge, SharePoint event receiver can't meet your requirement, as a workaround, we can check if the current user is a user name, then disable the "OK" button and add the message. The code below for your reference.

    <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    var myVar;
    $(function () {
    	if(window.location.href.indexOf("mngsiteadmin.aspx")!=-1){
    		if(getCurrentUserName()!="System Account"){			 
    			$("input[value='OK']").prop('disabled', true); 
    			$(".ms-authoringcontrols > tbody").append("<tr><td><span style='color:red'>Please contact the SharePoint admin team.</span></td></tr>");
    		}	
    	}
    	
    });
    function getCurrentUserName(){
    	var username="";
    	$.ajax({
    		url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/CurrentUser",
    		method: "GET",
    		headers: { "Accept": "application/json; odata=verbose"},
    		async:false,
    		success: function (data) {			 
    			username=data.d.Title;			 
    		},
    		error: function (err) {
    			console.log(err);
    		}
    	});
    	return username;
    }
    </script>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • 답변으로 표시됨 Evys 2018년 7월 13일 금요일 오전 11:37
    2018년 7월 13일 금요일 오전 1:42
    중재자

모든 응답

  • Hi,

    We can disable the people picker control from the mngsiteadmin.aspx page using jQuery, add the code below into <head/> in master page.

    <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    var myVar;
    $(function () {
    	if(window.location.href.indexOf("mngsiteadmin.aspx")!=-1){
    		myVar = setInterval(function(){				 
    			if($("input.sp-peoplepicker-editorInput").length>0){
    				$(".sp-peoplepicker-delImage").hide();
    				//disable peoplepicker control
    				$("input.sp-peoplepicker-editorInput").prop('disabled', true); 
    				//set disable css style
    				$("div.sp-peoplepicker-topLevel").addClass("sp-peoplepicker-topLevelDisabled");
    				clearInterval(myVar);
    			}
    		}, 300);
    	}
    });
    </script>

    Or hide this control using CSS below.

    <style>
    #ctl00_PlaceHolderMain_ctl00_PeopleEditorAdminsClientPicker_TopSpan{
    	display:none;
    }
    </style>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018년 7월 12일 목요일 오전 3:30
    중재자
  • Thanks Dennis.  It occurred to me afterwards that hiding the page is not a good idea.  The reason is that we allow up to 4 SCAs.  We do not want other SCAs adding new ones, but we need the ability for our team to add them.  I was thinking of probably disabling the OK button based on a role in an event receiver and give a message 'contact the SharePoint admin team, etc'

    Evy

    2018년 7월 12일 목요일 오후 5:41
  • Hi Evy,

    Per my knowledge, SharePoint event receiver can't meet your requirement, as a workaround, we can check if the current user is a user name, then disable the "OK" button and add the message. The code below for your reference.

    <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    var myVar;
    $(function () {
    	if(window.location.href.indexOf("mngsiteadmin.aspx")!=-1){
    		if(getCurrentUserName()!="System Account"){			 
    			$("input[value='OK']").prop('disabled', true); 
    			$(".ms-authoringcontrols > tbody").append("<tr><td><span style='color:red'>Please contact the SharePoint admin team.</span></td></tr>");
    		}	
    	}
    	
    });
    function getCurrentUserName(){
    	var username="";
    	$.ajax({
    		url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/CurrentUser",
    		method: "GET",
    		headers: { "Accept": "application/json; odata=verbose"},
    		async:false,
    		success: function (data) {			 
    			username=data.d.Title;			 
    		},
    		error: function (err) {
    			console.log(err);
    		}
    	});
    	return username;
    }
    </script>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • 답변으로 표시됨 Evys 2018년 7월 13일 금요일 오전 11:37
    2018년 7월 13일 금요일 오전 1:42
    중재자
  • great. Thanks.  I will try this

    Evy

    2018년 7월 13일 금요일 오전 11:35