Bulk Remove domain aliases
I have a domain expiring and have a large number of users with it setup as an alias. Zimbra won't let me remove the domain without removing each alias pointing to it first, is there a way to automate this process? I really don'twant to have to sort through all of my users to determine which ones have this set up as an alias... Is there any reason I can't search on the domain and get a list of emails/aliases for that particular domain? I'm working on a script for it now, but i'm not sure how well it will work out. If there's an easier/quicker way feel free to let me know.
I got it working somewhat......
It got all but 2 aliased accounts for me. I can post it here for you for now, and once i've refined it a little (probably over the weekend or next week) post a nice "I know this'll work version". The only problem I have with it is you HAVE to run this code as eith root or zimbra either way it will sudo -u zimbra for parts that require zimbra user do the work. It's ugly, but works.
I've also discovered " zmprov sa firstname.lastname@example.org " to get a full list of accounts. Up until now I've been connecting to and querying the mysql database directly. Since this would be used in production I think just querying the ldap would be quicker. It took me about 5 hrs to run through my 1900 accounts (as of this afternoon) and almost doubled the load on my server.
zimbra@mailserv6:~> zmprov sa email@example.com |wc -l
Keeping all of this in mind (and the fact that it did miss 2 or 3 accounts on my server.) If you still want this release posted on the wiki I'll get right on it.
If you want a nice (hopefully more processor friendly) release give me the this weekend and some of next week and I'll see what I can do to improve on it.