简体   繁体   中英

Retrieving all Users using Google Apps Provisioning API?

I am trying to retrieve all users in domain but it's never work. I never got any error in my code.

I am adding as reference Google.GData.Apps.dll in my project. I am using Google Apps Provisioning API. I am referring these link https://developers.google.com/google-apps/provisioning/

Code :-

    string domain = @"<domain name>";
    string subs = @"<Authorization code>";

    AppsService appService = new AppsService(domain, subs);

   // appService.CreateUser("john.jain","James","anderson","james@1234");
   // appService.DeleteUser("Amitesh");

    appService.RetrieveAllUsers();

The following works for me - RetrieveAllUsers() returns a UserFeed object containing all users. Note that I am using a different constructor for the apps service (using username/password credentials and not OAuth).

this.appsService = new AppsService(credential.Domain, credential.Username, credential.Password);
UserFeed userFeed = this.appsService.RetrieveAllUsers();

// Selecting all users except domain super administrators.
var usernamesInDomain = 
  (from UserEntry user in userFeed.Entries 
   where user.Login.Admin != true 
   select user.Login.UserName).ToList();

What does the returned UserFeed object contain in your case?

This is my solution :-

Google.GData.Apps.UserFeed s = appService.RetrieveAllUsers();



  foreach (UserEntry s1 in s.Entries)
  {

      string username = s1.Login.UserName.ToString();
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM