Google Apps Administrator have access control privilege for the documents of users in his/her domain. An administrator can share the document of one user to any other user in that domain. This is mostly required when you need to audit the documents of a domain user. Say, Bob's boss want to audit the documents of Bob and does not want to ask Bob to share the documents. In this case, Googe Apps Administrator can help Bob's boss. References: Here is a little Google Apps Script code which will share the document of user 1 with user 2 in the same Google Apps Domain.
function shareDocument(){ var base = 'https://docs.google.com/feeds/'; //Bob's ID var user1 = 'bobID@yourdomain.com'; //Bob's Boss's ID var user2 = 'BossOfBob@yourDomain.com'; //Doc ID which you want to share with Bob's Boss //In most of the cases administrator or Bob's boss will not be having the docID //You can use this tutorial to get the IDs of Documents of Bob // https://sites.google.com/site/appsscripttutorial/urlfetch-and-oauth/get-the-document-list-of-a-domain-user var docId = 'DocumentID'; //oAuth var fetchArgs = googleOAuth_('docs', base); fetchArgs.method = 'POST'; //Build the xml var rawXml = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>" +"<category scheme='http://schemas.google.com/g/2005#kind' " +"term='http://schemas.google.com/acl/2007#accessRule'/>" +"<gAcl:role value='writer'/>" +"<gAcl:scope type='user' value='"+user2+"'/>" +"</entry>"; fetchArgs.payload = rawXml; fetchArgs.contentType = 'application/atom+xml'; var url = base + user1+'/private/full/'+docId+'/acl?v=3&alt=json';//'+yourDocumentID+'/acl?v=3&alt=json'; var urlFetch = UrlFetchApp.fetch(url, fetchArgs); return urlFetch.getResponseCode(); }
Related tutorial: |
URLFetch and oAuth >