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 10-06-2011, 05:08 PM
Special Member
 
Posts: 138
Default [SOLVED] Creation of Mailboxes via a shell script

Has anyone created a shell script similar to what is described below?

Scenario: An automated windows script creates a comma-delimited list of current users in Active Directory and places it on the Samba share of an Ubuntu / Zimbra server on a daily basis. A cron job runs every hour looking for the file in the samba share.

Pseudo code for the Ubuntu script:

Code:
If /srv/samba/share/adlist.csv Exists
{
  Move /srv/samba/share/adlist.csv To /temp/adlist.csv
  While Not End of File (/temp/adlist.csv)
  {
    If Not Exist File.UserID in Zimbra
    {
      Create Zimbra Mailbox (File.UserID, File.FirstName, File.LastName, File.Password, DistributionList.Everyone)
      If successful mailbox creation
      {
        Write "Creation of UserID success!" To LogFile
      }
      Else if not successful mailbox creation
      {
        Write "Creation of UserID failed due to error such-n-so" To LogFile
      }
    }
    Read Next Line
  }  
  Delete /temp/adlist.csv
  If LogFile Exists
  {
    Email LogFile to Administrators
  }
}
Sample adlist.csv
Code:
UserID, FirstName, LastName, Password
JDoe, John, Doe, abc123
MJane, Mary, Jane, xyz321
ArnoldS, Arnold, Swartzensomething, gun4u
I have found the zmprov command-line documentation to "getAccount" and "createAccount" but I'm not well-versed in unix scripting and file manipulation. Any pointers, examples and whatnot would be appreciated.

EDIT: In case anyone wants to know, I did get AD Authentication and AD GAL working but it just works better if everything is controlled on the Zimbra side. Therefore, I'm avoiding the direct AD integration and opt'ing for a semi-automated sync.

Thanks,
LHammonds

Last edited by LHammonds; 10-11-2011 at 08:53 PM..
Reply With Quote
  #2 (permalink)  
Old 10-06-2011, 09:46 PM
Outstanding Member
 
Posts: 717
Default

Found this post where someone did something similar: Zimbra Active Directory Sync

Also, I believe Zimbra 8 will include an AD sync mechanism built into it.
__________________
01 Networks, LLC / Cybernetik.net
Zimbra NE and OSS Cloud Hosting
Shared Web Hosting
Consulting Services
Reply With Quote
  #3 (permalink)  
Old 10-07-2011, 08:04 AM
Special Member
 
Posts: 138
Default

Thanks for the link. I saw that one already. I would prefer to keep Linux and Active Directory separate...hence working with a flat file. It will be the responsibility of the Windows administrators for providing a cleaned up file such as not including service accounts or users that are not supposed to have mailboxes.

Including all the "logic" for AD user selection on the Linux side would just be a headache I'd rather avoid. It will also make it that much easier if we later decide to swap out Active Directory with another service such as OpenLDAP, Mandriva Directory Server, Fedora Directory Server, OpenDS or Apache Directory Server, etc. (which would still be administered on a different box).

LHammonds
Reply With Quote
  #4 (permalink)  
Old 10-11-2011, 08:52 PM
Special Member
 
Posts: 138
Default Resolved

I documented the solution for this script here --> Bash Script

LHammonds
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.