Get group names from GetGroupCollectionFromUser

Jul 22, 2010 at 4:44 PM

I want to use the GetGroupCollectionFromUser method to create an array with all the groups the user belongs to

I am having some trouble parsing the response to get the correct information.

Here's what my response looks like

<?xml version="1.0" ?>

- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <GetGroupCollectionFromUserResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
- <GetGroupCollectionFromUserResult>
- <GetGroupCollectionFromUser>
- <Groups>
  <Group ID="4" Name="Leah Dev Owners" Description="Use this group to give people full control permissions to the SharePoint site: Leah Dev" OwnerID="4" OwnerIsUser="False" />
  </Groups>
  </GetGroupCollectionFromUser>
  </GetGroupCollectionFromUserResult>
  </GetGroupCollectionFromUserResponse>
  </soap:Body>
  </soap:Envelope>

I want to get the Group -> Name attribute

thanks,

Luis

 

 

Coordinator
Jul 23, 2010 at 2:58 AM

Luis:

It'll be something like this:

  $().SPServices({
   operation: "GetGroupCollectionFromUser",
..the other options you need...

   async: false,
   completefunc: function(xData, Status) {
    $(xData.responseXML).find("Groups").each(function() {
     $(this).find("Group").each(function() {
      alert($(this).attr("Name"));
     });
    });
   }
  });

M.

Jul 23, 2010 at 1:17 PM

That worked.

Thanks,

Luis

 

Coordinator
Jul 24, 2010 at 12:22 AM
PGh0bWw+PGJvZHkgYmdjb2xvcj0iI0ZGRkZGRiI+PGRpdj5FeGNlbGxlbnQhIE9uZSBzdWdnZXN0 aW9uOiBsb29rIHRocm91Z2ggdGhlIFNQU2VydmljZXMgbGlicmFyeSBpdHNlbGYgZm9yIGV4YW1w bGVzLiBJIHB1bGxlZCB0aGUgb25lIGFib3ZlIHN0cmFpZ2h0IGZyb20gb25lIG9mIHRoZSBmdW5j dGlvbnMgYW5kIGp1c3QgYWRhcHRlZCBpdCBhIGxpdHRsZSB0byBtYXRjaCB5b3VyIHF1Z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