使用 Google Apps Provisioning API 检索所有用户

本文关键字:用户 检索 API Google Apps Provisioning 使用 | 更新日期: 2023-09-27 18:36:31

我正在尝试检索域中的所有用户,但它永远不会起作用。我的代码中从未出现任何错误。

我正在我的项目中添加Google.GData.Apps.dll作为参考。我正在使用Google Apps Provisioning API。我指的是这些链接 https://developers.google.com/google-apps/provisioning/

法典:-

    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();

使用 Google Apps Provisioning API 检索所有用户

以下内容对我有用 - RetrieveAllUsers() 返回一个包含所有用户的用户源对象。请注意,我为应用程序服务使用不同的构造函数(使用用户名/密码凭据而不是 OAuth)。

this.appsService = new AppsService(credential.域、凭据。用户名、凭据。密码);UserFeed userFeed = this.appsService.RetrieveAllUsers();选择除网域超级用户之外的所有用户。var 用户名在域中 =  (来自userFeed.Entries 中的UserEntry用户   其中用户。Login.Admin != true   选择"用户"。登录名)。ToList();

在您的情况下,返回的用户源对象包含什么?

这是我

的解决方案:-

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

  foreach (UserEntry s1 in s.Entries)
  {
      string username = s1.Login.UserName.ToString();
  }