0

I am working on SharePoint 2016 on-premises environment. I need to implement the some functionality based on the result whether the currently logged-in user is a part of a security group or not using javascript/jquery. Can someone advise on how I can check the user membership in a security group?

1 Answer 1

0

You can use SPServices to check the Current User. Here is an example

var userInGroup=false;
var site = "/sites/Sitename";

  $().SPServices({
  operation: "GetGroupCollectionFromUser",
  userLoginName: $().SPServices.SPGetCurrentUser({
                           webURL: site
                       }),
  webURL: site,
  async: false,
  completefunc: function (xData, Status){
      if ($(xData.responseXML).find("Group[Name='Security Group name']").length == 1){
          userInGroup=true;
      }
  }
  });

  if(userInGroup)
  {
  $("input[title='Priority Confirmed']").closest("tr").show();

  }
  else
  {
  $("input[title='Priority Confirmed']").closest("tr").hide();
  } 
});

Here is an article for reference SPServices

1
  • Hello @rrr : thanks for your response. Well, I tried to implement the solution provided by you, but it does not work for me. To be on the same page, I want to clarify that here by security group I am referring to the distribution list that has been converted to security group to make it detectable in SharePoint environment. Any other suggestions?
    – Tarun K
    Nov 24, 2017 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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