Googleドライブのメンバー確認と権限管理の質問

51 views
Skip to first unread message

朴昌雨

unread,
Jan 31, 2023, 10:33:31 PM1/31/23
to Google Apps API Japan

お世話になります。
平尾と申します。

Googleドライブにつきまして以下のような情報が知りたく投稿しました。

現在以下の様なプロセスのGASを作成しています。

1.特定ドライブに属しているメンバーのメールアドレスを取得する
2.取得したメールアドレスの内、特定のドメインと一致しないドメインのメールアドレスのメンバーはドライブからアクセス権限を解除する


1.の場合は    

// Log the email address of all users who have edit access to a file.   
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');   
var editors = file.getEditors();   
for (var i = 0; i < editors.length; i++) {     
    Logger.log(editors[i].getEmail());   
}        

或は        

// Log the domain names associated with all users who have edit access to a file.   
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');   
var editors = file.getEditors();   
for (var i = 0; i < editors.length; i++) {     
     Logger.log(editors[i].getDomain());   
}        

でEmailやDomainの取得は出来ると思いますが、   
この場合ドライブのEditor権限者だけの取得になるとおもいます。   
ドライブにアクセス出来る全メンバーの取得の方法はありますでしょうか?


2.では取得したメンバーの中で特定の対象に対して該当ドライブからのアクセス権を外す方法とかはありますでしょうか?    


以上、よろしくお願いします。

ogawa tak

unread,
Jan 31, 2023, 11:54:31 PM1/31/23
to Google Apps API Japan
1についてですが、getEditorsの他にgetgetViewers()とgetOwner()という関数があるので
これらを組み合わせれば取得できそうに見えます。

2については、removeEditor(),removeCommenter(),removeViewer()が使えそうです。
ownerを削除する場合はsetOwner()でownerを変えれば削除できそうに見えます。

その他の操作についても下記のドキュメントにまとまっています。

2023年2月1日水曜日 12:33:31 UTC+9 changw...@lixil.com:

朴昌雨

unread,
Feb 1, 2023, 2:18:42 AM2/1/23
to google-app...@googlegroups.com
ありがとうございます

お陰様で無事解決できました!

2023年2月1日(水) 13:54 ogawa tak <mistolt...@gmail.com>:
--
このメールは Google グループのグループ「Google Apps API Japan」のトピックを登録しているユーザーに送られています。
このトピックの登録を解除するには https://groups.google.com/d/topic/google-apps-api-japan/cyDziZ_XscQ/unsubscribe にアクセスしてください。
このグループを退会し、グループのすべてのトピックの登録を解除するには google-apps-api-...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/google-apps-api-japan/af2a3d41-4845-4828-a919-2b57b7df750bn%40googlegroups.com にアクセスしてください。
Reply all
Reply to author
Forward
0 new messages