0

ユーザー数が 40000 を超えるドメインで UserManager.getAllUsers() を実行したいと考えています。このスクリプトは 5 分以上実行され、決して終了しません。このリクエストを fomr SitesApp.getalldescendants のように分割する方法はありますか?

よろしくお願いします

4

3 に答える 3

1

この問題をご覧ください。スターを付けて、そこに記載されている回避策を試してください。

于 2012-07-03T16:45:11.253 に答える
0

アカウント レポートには Google Apps Reporting API を使用できます。UrlFetchApp と Oauth を一緒に使用して、アカウント レポートを取得できます。1 回の呼び出しで、最大 100,000 個のアカウントを CSV 形式で返すことができます。ドメイン内のすべてのアカウントのディスク使用量レポートを取得するために、約 3 か月前に Apps Script にこれを実装しました。 https://developers.google.com/google-apps/reporting/#Accounts_Report

于 2012-07-04T11:58:54.333 に答える
0

アカウント データを CSV 文字列形式で返す小さなコードを次に示します。コードを実行するには、Google Apps ドメインの管理者である必要があります。CSV 文字列を解析して、必要なフィールドを取得できます

    //Refernce API URL
    // https://developers.google.com/google-apps/reporting/#accounts_report
    function startHere(){
      var domain = UserManager.getDomain();
      var fDate = Utilities.formatDate(new Date(), Session.getTimeZone(), 'yyyy-MM-dd');
      var url = 'https://www.google.com/hosted/services/v1.0/reports/ReportingData';
      var fetchArgs = googleOAuth_('Reporting', url);
      fetchArgs.method = 'POST';
      var rawXML = '<?xml version="1.0" encoding="UTF-8"?>'
          +'<rest xmlns="google:accounts:rest:protocol" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance ">'
          +'<type>Report</type>'
          +'<domain>'+domain+'</domain>'
          +'<date>'+fDate+'</date>'
          +'<page>1</page>'
          +'<reportType>daily</reportType>'
          +'<reportName>accounts</reportName>'
          +'</rest>';
      fetchArgs.payload = rawXML;
  //fetchArgs.contentType = "application/xml";
  fetchArgs.headers = {"Content-type": "application/atom+xml charset=UTF-8"};  
  var csvData = UrlFetchApp.fetch(url, fetchArgs).getContentText();
}


    //Google oAuth, helper function
    function googleOAuth_(name,scope) {
      var oAuthConfig = UrlFetchApp.addOAuthService(name);
      oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
      oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
      oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
      oAuthConfig.setConsumerKey("anonymous");
      oAuthConfig.setConsumerSecret("anonymous");
      return {oAuthServiceName:name, oAuthUseToken:"always"};
    }
于 2012-07-04T16:09:09.017 に答える