1

We are sharing parts of our SharePoint 2013 enterprise site with our customers. Security-wise this can be managed pretty well, but I have one problem. Customers do see employee photo & names (next to a post in a newsfeed) and they can also click that name to go to the employee mysite. Browsing to this mysite should not be possible, but, I do want the customer to see the employee picture in the newsfeed, and this picture also comes from a mysite location.

How can I set this up?

1
  1. Create a SharePoint Security Group and add all your customer's
  2. Edit your master page and add following script.

    _spBodyOnLoadFunctionNames.push("HidePhotos('CustomerGroup')");
    
    function HidePhotos(groupName) {
        var currentContext = new SP.ClientContext.get_current();
        var currentWeb = currentContext.get_web();
        var currentUser = currentContext.get_web().get_currentUser();
        currentContext.load(currentUser);
        var allGroups = currentWeb.get_siteGroups();
        currentContext.load(allGroups);
        var group = allGroups.getByName(groupName);
        currentContext.load(group);
        var groupUsers = group.get_users();
        currentContext.load(groupUsers);
        currentContext.executeQueryAsync(OnSuccess,OnFailure);
    }
    function OnSuccess(sender, args) {
        var userInGroup = false;
        var groupUserEnumerator = groupUsers.getEnumerator();
        while (groupUserEnumerator.moveNext()) {
            var groupUser = groupUserEnumerator.get_current();
            if (groupUser.get_id() == currentUser.get_id()) {
                //Current user is in the group. Remove Photos
                $('.ms-peopleux-userImgDiv').remove();
                break;
            }
        } 
    }
    function OnFailure(sender, args) {
        alert("Failed");
    }    
    
3
  • 4
    Security trimming by javascript is not really security, it is just a "hiding" Dec 2 '14 at 14:38
  • 1
    Indeed, i was not looking for such a javascript hack / hide script.
    – Tys
    Dec 6 '14 at 12:42
  • Ok, i was just putting a suggestion. Also read your question wrongly, sorry. Dec 6 '14 at 12:46

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.