the operation GetGroupCollectionFromUser doesn't work for some users

Nov 5, 2013 at 12:00 PM
Hi All,
    I have been using SPServices for ages and i'll say again its great and thanks to Marc.
But I'm working on as SP 2010 site and i want to disable some elements based o the sharepoint groups.So using the operation : "GetGroupCollectionFromUser",
When i log in it works perfectly but when other users log in i can see i get no data back by doing this:
alert(xData.responseXML.xml); -- this returns nothing when other users log in.

What could be the issue?
I'm thinking its permission.So my question is what permissions do users needs to be able run this operation:GetGroupCollectionFromUser

thanks in advance
Nov 5, 2013 at 4:26 PM
I believe this has something to do with users not having the ability to view permissions. There is a permission [Enumerate Permissions] that allows users to at least view permissions and I believe it is what you need to have.

Regards,
Dan
Nov 6, 2013 at 3:45 AM
Thanks Dan.
Where would this setting be as i have looked at the group settings of this group and it has been set to "Who can set this membership of this view - Everyone.
Any ideas?
Thanks
Nov 7, 2013 at 12:59 PM
Sorry for the late reply! This is a permission level that you can apply to allow users the ability to view the permissions of an item/list. In my opinion this should be set by default but in most cases it is not. So for example if a user belongs to a specific group "Readers" or whatever, you can give that group the [Enumerate Permissions] "Permission" by updating the "Permission Level". For example, the "Contribute" Permission Level does not have that permission set by default, but you can add that so it should work. It is under site permissions.
Nov 13, 2013 at 7:45 PM
Also check "Site Settings>>Site permissions>>permission levels." By default, the "Read" permission level includes the ability for a user to "Browse User Information" and "Use Remote Interfaces." The latter must be checked or the user won't be able to run the Web Services calls if I'm not mistaken. Could the permission levels have been changed? Nothing else comes to mind at the moment.

Geoff
Dec 3, 2013 at 11:39 AM
Thanks Geoff and spevilgenius i have selected those options as suggested but still can' t get t to work.
When i hardcode the username value and log on as me IT WORKS.
But when i login as the user.
It returns nothing.......

Any more ideas what it could be?

Thanks in Advance
Dec 3, 2013 at 12:46 PM
That's a puzzler. I'm not sure what your code looks like for the call. Here's an example I use that works consistently for me (I use it for the same reason you intend to):
function UserIsAdmin() {
//Checks user group membership to see if the current user is a member of "epassTOM_AppAdmins"
    var booAdminUser = new Boolean(false);
    $().SPServices({
        operation: "GetGroupCollectionFromUser",
        userLoginName: $().SPServices.SPGetCurrentUser(),
        async: false,
        completefunc: function(xData, Status) {
            if($(xData.responseXML).find("Group[Name='epassTOM_AppAdmins']").length == 1) {
                booAdminUser = true;
            }
        }
    });
    return booAdminUser;
}
For the userLoginName, are you using the $().SPServices.SPGetCurrentUser() function?
Dec 4, 2013 at 1:28 AM
I know :)
Thanks gkoliver.
I'm doing exact code you are using.
Only when i use $().SPServices.SPGetCurrentUser() i don't get the users returned ..no data.
So what i did is add a CEWB that gave me the logged in user and then pass that to the GetGroupCollectionFromUser

Cheers
Coordinator
Dec 4, 2013 at 3:09 AM
Are you by any chance calling from the root site? There's a bug in 2013.01.

M.
Dec 4, 2013 at 5:36 AM
Hi Marc,
  Will check.But don't think so.
Where is the $().SPServices.SPGetCurrentUser() getting the data from.
If you let me know I would confirm what i find.
Thanks
Coordinator
Dec 4, 2013 at 11:22 AM
If you check the docs, you'll see that it's getting the info from /_layouts/userdisp.aspx
https://spservices.codeplex.com/wikipage?title=$().SPServices.SPGetCurrentUser&referringTitle=Documentation

M.
Dec 5, 2013 at 6:20 PM
I have found that the $().SPServices.SPGetCurrentUser() returns an empty logonName when used at a subsite level, versus a root site level, where the LogonName does populate properly. I am using SPServices 0.7.2 and Win 7 with MOSS 3.0/SP 2007. I had to resort to placing a div with LogonUser and then hiding with styling and then pulling .html() from the Div, in a separate CEWP, then passing that into a variable and using that variable versus the direct call($().SPServices.SPGetCurrentUser()), in order to use the GetGroupCollectionFromUser for a sub site.