1

I am using SPServices to list out each permission group and then under each group, each user is listed out. Next to the user, there is a button that will be used to remove that user (and later, another to add a user).

The members are listed after the groups are built. groupString and groupTitle are brought in from building groups:

function listMembers(groupString, groupTitle) { var groupStringx = groupString; groupStringx = '#' + groupString; $().SPServices({ operation: "GetUserCollectionFromGroup", async: false, webURL: "website.name", groupName: groupTitle, completefunc: function(xData, Status){ $(xData.responseXML).find("User").each(function(){ userName = $(this).attr("LoginName").split('provider|')[1]; userArray.push([groupTitle, userName]); arrayLength = userArray.length-1; $(groupStringx).append( '<table style="width:900px;">' + '<tr>' + '<td class="userName" style="width:50%;">' + $(this).attr("Name") + '</td>' + '<td class="orgName" style="width:25%;"></td>' + '<td><div class="name" onclick="deleteClick(' + arrayLength + ')"' + '>GTFO</div></td>' + '</tr>' + '</table>' ); //end append });//end xdata }//end completefunc }); //end spservices GetUserCollectionFromGroup } 

Then when a user clicks "Remove" they trigger this function:

function deleteClick(arrayPos){ var group = userArray[arrayPos][0]; var user = userArray[arrayPos][1]; if (confirm("Are you sure you want to delete User from group?")) { deleteUserFromGroup(group, user); } } 

And the function contained within that one is:

function deleteUserFromGroup(group, user){ $().SPServices({ operation: "RemoveUserFromGroup", groupName: group, userLoginName: user, async: false, completefunc: null }); } 

The pop-up comes up, the parameters are passed successfully (after console.log testing), so I am not sure what I am missing here. Any help would be greatly appreciated!

5
  • 1
    Are there any errors being logged in the console? Does the user performing the operation have permission to modify permissions? Does the user performing the action have permission to modify the group membership? Commented Apr 27, 2015 at 13:15
  • No errors in the logs, it just doesn't do anything. I am a site owner, and I have permission to do this operation and I am the one doing it. Commented Apr 27, 2015 at 13:41
  • What does the user variable look like? It could be that the \ in the domain isn't being escaped? like domain\\useraccount. Commented Apr 27, 2015 at 13:46
  • The user variable is domain\\user so it comes back domain\\first.last. As far as I can tell in the console, it appears correct, but maybe it isn't being read properly. Commented Apr 27, 2015 at 14:00
  • Alright, I fixed it thanks to your domain question. I was missing part of my domain name, and I was also assuming I had to use \\. However, what finally worked was printing the "user" variable off as: domaindata|somedomainname|user.name Now it works! Commented Apr 27, 2015 at 14:22

1 Answer 1

3

It appears I was simply missing accurate domain information. My "user" variable changed to include the domain name and user name combined allowed me to finally remove a user from the group.

function deleteClick(arrayPos){ var group = userArray[arrayPos][0]; //group name var user = userArray[arrayPos][1]; //user.name var domain = userArray[arrayPos][2]; //partial domain name if (confirm("Are you sure you want to delete User from group?")) { deleteUserFromGroup(group, user, domain); } } function deleteUserFromGroup(group, user, domain){ userInfo = 'data|' + domain + '|' + user; //userInfo prints off as data|domain|user.name //data is the other part of my domain name required to remove user $().SPServices({ operation: "RemoveUserFromGroup", groupName: group, userLoginName: userInfo, async: false, completefunc: null }); } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.