Group Feed Question .net

20 views
Skip to first unread message

Randy Maltbie

unread,
Jul 26, 2011, 12:16:40 PM7/26/11
to google-app...@googlegroups.com
I am by no means a proficient .net developer but I have managed to get groups and users to create using the .net API.  I need help with one last area though.  I need to periodically cycle through all of my groups and delete all members of all groups.  That seems really simple but I have been chasing my tail and looking at the same code and pages over and over and nothing is clicking for me.

I get the basic concept of how to retrieve a list of all users, but I am not sure how to iterate through them to issue the individual delete from group commands.  Any help would be greatly appreciated (especially a code snippet). 

Loop Through Groups
  Retrieve All Users In Group
  For x = 0 to Number of Users in Group
    Delete this user from this group
  Next
  Move to Next Group
End Loop

Thanks!

Thanks!

Claudio Cherubino

unread,
Jul 28, 2011, 2:36:57 PM7/28/11
to google-app...@googlegroups.com
Hi Randy,

The following C# code iterates all groups in your domain and removes each member from them:


AppsService service = new AppsService(domain, username, password);
AppsExtendedFeed groups = service.Groups.RetrieveAllGroups();
for (int i = 0; i < groups.Entries.Count; i++) {
  AppsExtendedEntry group = (AppsExtendedEntry)groups.Entries[i];
  string groupId = group.getPropertyValueByName("groupId");
  AppsExtendedFeed members = service.Groups.RetrieveAllMembers(groupId);
  for (int j = 0; j < members.Entries.Count; j++) {
    AppsExtendedEntry member = (AppsExtendedEntry)members.Entries[j];
    string memberId = member.getPropertyValueByName("memberId");
    service.Groups.RemoveMemberFromGroup(memberId, groupId);
  }
}


Claudio

--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-apps-mgmt-apis/-/tEVrxvs1tlQJ.
To post to this group, send email to google-app...@googlegroups.com.
To unsubscribe from this group, send email to google-apps-mgmt...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Reply all
Reply to author
Forward
0 new messages