Results 1 to 6 of 6

Thread: Mass delete contacts

  1. #1
    Join Date
    Aug 2006
    Posts
    19
    Rep Power
    9

    Default Mass delete contacts

    I'm trying to import contacts into Zimbra from a very old copy of Lotus Notes and have one person with over 1,800 contacts.

    Is there a way that I can quickly (via a CLI) delete his contacts if I screw up the import? I'm using the REST interface via a CSV file and the import goes very smoothly; but I need to be able to quickly reset his address book. The thought of selecting over 1,800 contacts via a GUI breaks my heart!

    (if you can point me to where openLDAP stores the records, I might be able to hack a perl script together, but would rather not do the work if I don't have to...)

    TIA.

  2. #2
    Join Date
    Aug 2006
    Posts
    19
    Rep Power
    9

    Default mass delete (cont)

    Okay, I've poked around a bit and it looks as if the personal contacts are stored in the mysql database for the individual user's mail store in the mail_item table, with a NULL subject field.

    Can I simply delete these records from the database if I want to wipe out his contacts and import them afresh?

    TIA.

  3. #3
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default Not a perfect solution...

    Those contacts are indexed, so deleting the rows from MySQL won't clean everything up.

    If you can do a little SOAP crafting, you could just empty the user's Contacts folder (folder 7). Here's what the SOAP would look like (cribbed from the SOAP used to empty the Trash):

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
      <soap:Header>
        <context xmlns="urn:zimbra">
          <authToken>put a valid authtoken here</authToken>
        </context>
      </soap:Header>
      <soap:Body>
        <FolderActionRequest xmlns="urn:zimbraMail">
          <action op="empty" id="7"/>
        </FolderActionRequest>
      </soap:Body>
    </soap:Envelope>
    Bugzilla - Wiki - Downloads - Before posting... Search!

  4. #4
    Join Date
    Aug 2006
    Posts
    19
    Rep Power
    9

    Default Thanks -- and calendar folder mass delete?

    Can I use the same SOAP fragment on the calendar folder?

    and am I right in thinking that the calendar folder is always 10 (at least the default one)?

    Is there SOAP for discovering folder numbers, as well (I found the url for the svn SOAP documentation -- guess I could RTFM --

  5. #5
    Join Date
    Aug 2006
    Posts
    19
    Rep Power
    9

    Default Just for documentation purposes

    Here's how I got the SOAP message to the server in Ruby:
    Code:
    #!/usr/bin/ruby -w                                                                                                                                                                                                                                                                  
    #require 'yaml'                                                                                                                                                                                                                                                                     
    require 'soap/rpc/driver'
    require 'soap/header/simplehandler'
    
    class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
        MyHeaderName = XSD::QName.new("urn:zimbra", "context")
    
        def initialize(sessionid = nil, authtoken = nil)
          super(MyHeaderName)
          @sessionid = sessionid
          @authtoken = authtoken
        end
    
        def on_simple_outbound
          if @sessionid
            { "sessionId" => @sessionid, "authToken" => @authtoken}
          end
        end
    end
    
    class FolderAction < SOAP::SOAPRawString
      attr :extraattr, true
      def initialize(op,id)
        super(nil)
        @extraattr = {"op"=>op,"id"=>id}
      end
    end
    
    class FolderActionRequest
      @@schema_element = ["action", "SOAP::SoapString"]
      attr_accessor :action
      def initialize(action)
        @action = action
      end
    end
    
    #----------- open up a SOAP connnection                                                                                                                                                                                                                                             
    # the urn is zimbraAccount (for work on user accounts) or zimbra (for general admin functions)                                                                                                                                                                                      
    
    s = SOAP::RPC::Driver.new('https://zimbraHost:7071/service/admin/soap/',
                              'urn:zimbraAccount')
    s.wiredump_dev = STDERR  #if $DEBUG                                                                                                                                                                                                                                                 
    
    s.options["protocol.http.ssl_config.verify_mode"] = nil
    s.add_method('AuthRequest',"account", "password")
    token, lifetime, sessionid = s.AuthRequest(user_id,password)
    s.headerhandler << ClientAuthHeaderHandler.new(sessionid, token)
    
    #-------now run the command                                                                                                                                                                                                                                                         
    mNS = 'urn:zimbraMail'
    folder_action = 'empty' # or read or delete or ...                                                                                                                                                                                                                                  
    folder_id = 7 # here I want to work on empty the address book                                                                                                                                                                                                                       
    
    s.add_document_method('FolderActionRequest',
                          'FolderActionRequest',
                          [XSD::QName.new(mNS, 'FolderActionRequest')],
                          [XSD::QName.new(mNS, 'FolderActionResponse')])
    
    # do it!                                                                                                                                                                                                                                                                            
    s.FolderActionRequest(FolderActionRequest.new(FolderAction.new(folder_action,folder_id)))
    Hope this is useful for someone else; it took me a minute to figure out...

  6. #6
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default calendar = 10

    Quote Originally Posted by nyamada
    and am I right in thinking that the calendar folder is always 10 (at least the default one)?
    Yes, that's correct.
    Bugzilla - Wiki - Downloads - Before posting... Search!

Similar Threads

  1. [SOLVED] Mass delete calendar entries
    By achow in forum Users
    Replies: 10
    Last Post: 03-05-2008, 03:24 PM
  2. Is it just me? (Shared Contacts in Outlook)
    By russgalleywood in forum Administrators
    Replies: 13
    Last Post: 11-16-2006, 10:55 AM
  3. Setting File as: attribute for contacts -- mass import
    By nyamada in forum Administrators
    Replies: 6
    Last Post: 08-31-2006, 02:48 PM
  4. Cannot delete Contacts
    By zzzzsg in forum Administrators
    Replies: 5
    Last Post: 05-09-2006, 02:50 PM
  5. vbscript to convert Thunderbird contacts
    By zzzzsg in forum Administrators
    Replies: 0
    Last Post: 05-04-2006, 03:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •