Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-28-2006, 07:25 PM
Intermediate Member
 
Posts: 19
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.
Reply With Quote
  #2 (permalink)  
Old 08-28-2006, 07:48 PM
Intermediate Member
 
Posts: 19
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.
Reply With Quote
  #3 (permalink)  
Old 08-28-2006, 10:00 PM
Zimbra Employee
 
Posts: 1,434
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!
Reply With Quote
  #4 (permalink)  
Old 08-29-2006, 08:22 AM
Intermediate Member
 
Posts: 19
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 --
Reply With Quote
  #5 (permalink)  
Old 08-29-2006, 02:28 PM
Intermediate Member
 
Posts: 19
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...
Reply With Quote
  #6 (permalink)  
Old 08-29-2006, 09:03 PM
Zimbra Employee
 
Posts: 1,434
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.