Remove sharing permission for files shared externally with Link.

2,943 views
Skip to first unread message

Marcin Ostrowski

unread,
Feb 7, 2017, 1:28:30 AM2/7/17
to GAM for G Suite
Hello,

is it possible to turn off sharing permission for all files that are externally shared with a link? Is it possible for the whole domain? For example in the domain.com you can find 500 files shared externally with link and 500 shared with link but only for domain users. We wanted to turn off sharing permission for this 500 externally shared files. 

Thank you in advance.

Robert Robinson

unread,
Feb 7, 2017, 4:39:41 AM2/7/17
to GAM for G Suite
You can turn off sharing outside of the domain entirely in the admin console. Apps > G Suite > Settings for Drive and Docs > Sharing Options > Choose betweem Off/Whitelist/On with some other drill down options.

Ostrowski, Marcin

unread,
Feb 7, 2017, 4:50:23 AM2/7/17
to google-ap...@googlegroups.com
Hi,

thank you for your response but this is not what i mean. I've already have files shared externally with link and as far as i know if i change this option i Admin Console it won't change sharing permissions for already shared files. We gonna share files externally with link but for first have to change those one.


Best regards

 Sent with Mailtrack

Marcin Ostrowski
Google Apps Deployment Specialist



  
Buena Cloud - Google Cloud Partner
  
     

--[  more7 GmbH
--[  Open Source Software Solutions - VoIP, CRM, CMS, Linux, VPN
--[  ul. Wichrowa 20C, 60-449 Poznań
--[  Heinrich-Hertz-Str. 7, 41516 Grevenbroich
--[  Tel.:     +49 2131 3847404
--[  Mobile: +49 162 177 9939
--[  http://www.more7.com 
--[  E-Mail: marcin.o...@more7.com 

--[  Ust-IdNr.: DE231146213 
--[  SteuerNr.: 122/5721/1183 
--[  HRB: 12667 
--[  Amtsgericht: Neuss 
--[  Geschaeftsfuehrer: Cezary Augustynowicz 
--[  Gezeichnetes Kapital: 25.000 EUR 

Please consider your environmental responsibility before printing this e-mail. 
Denken Sie bitte an die Umwelt, bevor Sie diese E-Mail ausdrucken. 
Prosze pomysl o ochronie srodowiska zanim wydrukujesz ten e-mail.


The Stephen Perse Pre-Prep, Stephen Perse Foundation Junior School, Stephen Perse Foundation Senior School, The Stephen Perse Sixth Form College and Dame Bradbury's School are the schools of the Stephen Perse Foundation. The Stephen Perse Foundation is a Registered Charity (No:1120608) and a Company limited by guarantee, registered in England and Wales (No:6113565). Its registered office is 19 Union Road, Cambridge, Cambridgeshire CB2 1HF.

This e-mail and any attached file is intended only for the use of the addressee(s) named above and is confidential and may be legally privileged. If you have received this email and are not a named addressee please delete it; you must not disclose, copy, distribute or use the contents in any way that may be unlawful. Although the Stephen Perse Foundation operates anti-virus programmes, it does not accept responsibility for any loss or damage whatsoever that arises from the use of the email or attachments. In addition the Stephen Perse Foundation cannot be held liable for incomplete or corrupted transmissions, delay in receipt or any errors or omissions in the content of the email, as a result of transmission. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Foundation.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/3982cbbc-4c4b-46c8-a7f3-3bded4b1eb4a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

+KimNilsson

unread,
Feb 7, 2017, 5:45:42 AM2/7/17
to GAM for G Suite
You first have to find all those files.
Then it's perfectly possible to change the ACL.
I don't know the commands by heart, but it's going to require a few steps.

If this is something you need to do regularly you would perhaps want to schedule the final command too.

If you don't want to do it manually, with GAM, then I know that this is exactly what the tool GAT (GeneralAudiTool) does. It's not free, though.

Ostrowski, Marcin

unread,
Feb 7, 2017, 7:03:46 AM2/7/17
to google-ap...@googlegroups.com
Great, 

thank you. I will take a look at GAT.



 Sent with Mailtrack

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Ross Scroggs

unread,
Feb 7, 2017, 9:02:07 AM2/7/17
to google-ap...@googlegroups.com
Marcin,

Here is a Python script that may help.

Ross

#!/usr/bin/env python                                                                                                                                                                                                                                                                                                                                 
"""                                                                                                                                                                                                                                                                                                                                                   
# Purpose: For a Google Drive User(s), delete all drive file ACls for files shared outside of a list of specified domains                                                                                                                                                                                                                             
# Note: This script can use basic GAM: https://github.com/jay0lee/GAM or advanced GAM: https://github.com/taers232c/GAMADV-X                                                                                                                                                                                                                          
# Usage:                                                                                                                                                                                                                                                                                                                                              
# 1: Get ACLS for all files, if you don't want all users, replace all users with your user selection in the command below                                                                                                                                                                                                                             
#  $ gam all users print filelist id title permissions > filelistperms.csv                                                                                                                                                                                                                                                                            
# 2: From that list of ACLs, output a CSV file with headers "Owner,driveFileId,driveFileTitle,permissionId,role,type,emailAddress"                                                                                                                                                                                                                    
#    that lists the driveFileIds and permissionIds for all ACls except those from the specified domains.                                                                                                                                                                                                                                              
#    (n.b., role, type, emailAddress and title are not used in the next step, they are included for documentation purposes)                                                                                                                                                                                                                           
#  $ python GetNonDomainDriveACLs.py filelistperms.csv deleteperms.csv                                                                                                                                                                                                                                                                                
# 3: Inspect deleteperms.csv, verify that it makes sense and then proceed                                                                                                                                                                                                                                                                             
# 4: Delete the ACLS                                                                                                                                                                                                                                                                                                                                  
#  $ gam csv deleteperms.csv gam user "~Owner" delete drivefileacl "~driveFileId" "~permissionId"                                                                                                                                                                                                                                                           
"""

import csv, re, sys
email_n_address = re.compile(r"permissions.(\d+).emailAddress")
# Substitute your domain(s) in the list below, e.g., domainList = ['domain.com',] domainList = ['domain1.com', 'domain2.com',]                                                                                                                                                                                                                        
domainList = []
inputFileName = sys.argv[1]
outputFileName = sys.argv[2]

with open(outputFileName, 'wb') as outputFile:
  outputFile.write('Owner,driveFileId,driveFileTitle,permissionId,role,type,emailAddress\n')
  with open(inputFileName, 'rb') as inputFile:
    perms = csv.DictReader(inputFile)
    for row in perms:
      for k, v in row.iteritems():
        mg = email_n_address.match(k)
        if mg and v:
          perm_group = mg.group(1)
          if row['permissions.{0}.domain'.format(perm_group)] not in domainList:
            outputFile.write('{0},{1},{2},id:{3},{4},{5},{6}\n'.format(row['Owner'], row['id'], row['title'],
                                                                       row['permissions.{0}.id'.format(perm_group)],
                                                                       row['permissions.{0}.role'.format(perm_group)],
                                                                       row['permissions.{0}.type'.format(perm_group)],
                                                                       v))


To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.

Robert Robinson

unread,
Feb 8, 2017, 6:07:54 AM2/8/17
to GAM for G Suite
I'm trying this script now but get a str/bytes error:

Traceback (most recent call last):
  File "GetNonDomainDriveACLs.py", line 26, in <module>
    outputFile.write('Owner,driveFileId,driveFileTitle,permissionId,role,type,emailAddress\n')
TypeError: a bytes-like object is required, not 'str'
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Jay Lee

unread,
Feb 8, 2017, 6:39:04 AM2/8/17
to GAM for G Suite

Sounds like you used Python 3 and the script expects Python 2.
.
Jay


To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
The Stephen Perse Pre-Prep, Stephen Perse Foundation Junior School, Stephen Perse Foundation Senior School, The Stephen Perse Sixth Form College and Dame Bradbury's School are the schools of the Stephen Perse Foundation. The Stephen Perse Foundation is a Registered Charity (No:1120608) and a Company limited by guarantee, registered in England and Wales (No:6113565). Its registered office is 19 Union Road, Cambridge, Cambridgeshire CB2 1HF.

This e-mail and any attached file is intended only for the use of the addressee(s) named above and is confidential and may be legally privileged. If you have received this email and are not a named addressee please delete it; you must not disclose, copy, distribute or use the contents in any way that may be unlawful. Although the Stephen Perse Foundation operates anti-virus programmes, it does not accept responsibility for any loss or damage whatsoever that arises from the use of the email or attachments. In addition the Stephen Perse Foundation cannot be held liable for incomplete or corrupted transmissions, delay in receipt or any errors or omissions in the content of the email, as a result of transmission. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Foundation.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.
--

Jay

Robert Robinson

unread,
Feb 8, 2017, 6:47:04 AM2/8/17
to GAM for G Suite
Indeed you're correct!
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.

The Stephen Perse Pre-Prep, Stephen Perse Foundation Junior School, Stephen Perse Foundation Senior School, The Stephen Perse Sixth Form College and Dame Bradbury's School are the schools of the Stephen Perse Foundation. The Stephen Perse Foundation is a Registered Charity (No:1120608) and a Company limited by guarantee, registered in England and Wales (No:6113565). Its registered office is 19 Union Road, Cambridge, Cambridgeshire CB2 1HF.

This e-mail and any attached file is intended only for the use of the addressee(s) named above and is confidential and may be legally privileged. If you have received this email and are not a named addressee please delete it; you must not disclose, copy, distribute or use the contents in any way that may be unlawful. Although the Stephen Perse Foundation operates anti-virus programmes, it does not accept responsibility for any loss or damage whatsoever that arises from the use of the email or attachments. In addition the Stephen Perse Foundation cannot be held liable for incomplete or corrupted transmissions, delay in receipt or any errors or omissions in the content of the email, as a result of transmission. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Foundation.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
--

Jay

Robert Robinson

unread,
Feb 9, 2017, 5:16:00 AM2/9/17
to GAM for G Suite
Got round to trying this again but now getting this error:

python GetNonDomainDriveACLs.py filelistperms.csv deleteperms.csv
Traceback (most recent call last):
  File "GetNonDomainDriveACLs.py", line 31, in <module>
    mg = email_n_address.match(k)
TypeError: expected string or buffer

I've never used python so probably something I'm doing wrong.

Kent Chapple

unread,
Oct 15, 2018, 4:20:08 PM10/15/18
to GAM for G Suite
Ross, this is great. You've saved me tons of work. Thank you!
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages