Using the Google Audit API to Monitor Google Apps Email

I need some admin users to use gmail gmail to track the email of their employees. You used the Google Audit API for this.

I would like administrators to just click on an email, but that is not the case.

If this is important, the application is a rail application. The email is completely filled in with googles mail through Google applications. Anyone who would do this would be helpful.

Update! 500 points for this one!

I am using ruby ​​on rails where there is an application on the hero. Email is completely hosted with the Google Apps standard, and not with business, so we will need to update, and DNS with zerigo, which you already know if you use a hero.

+3
source share
1 answer

Well, I didn’t plan to extend gdata-ruby-util gem :), but here is some code that could be used for the Google documentation audit API . I wrote only a method create_monitor_on, but everything else is pretty easy to get.

Let me know if it works or needs rewriting and I will update it here:

    class Audit < GData::Client::Base

      attr_accessor :store_at

      def initialize(options = {})
        options[:clientlogin_service] ||= 'apps'
        options[:authsub_scope] ||= 'https://apps-apis.google.com/a/feeds/compliance/audit/' 
        super(options)
      end

      def create_monitor_on(email_address)
        user_name, domain_name = email_address.split('@')
        entry = <<-EOF
        <atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
        <apps:property name='destUserName' value='#{@store_at}'/>
        <apps:property name='beginDate' value=''/>
        <apps:property name='endDate' value='2019-06-30 23:20'/>
        <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='outgoingEmailMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/>
        </atom:entry>
        EOF

        return true if post('https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/'+domain_name+'/'+user_name, entry).status_code == 201
        false
      end   
   end

Then use it elsewhere:

auditor = Audit.new
auditor.store_at = 'this-username'
auditor.clientlogin(username, password)
render :success if auditor.create_monitor_on('email-address@my-domain.com')

, , , . Rails Net:: IMAP , . .. , " Joe Email", :

require 'net/imap'

imap = Net::IMAP.new('imap.gmail.com', 993, true)
imap.login('this-username@my-domain.com', password)
imap.select('INBOX')

messages = []
imap.search(["TO", "joe@email.com").each do |msg_id|
  msg = imap.fetch(msg_id, "(UID RFC822.SIZE ENVELOPE BODY[TEXT])")[0]
  body = msg.attr["BODY[TEXT]"]
  env = imap.fetch(msg_id, "ENVELOPE")[0].attr["ENVELOPE"]
  messages << {:subject => env.subject, :from => env.from[0].name, :body => body }
end

imap.logout
imap.disconnect

- .

+8

All Articles