For the past several weeks I have been looking on the internet for, but unable to find, some information on how to perform user provisioning tasks in Zimbra via SOAP/Perl.
Attached is a Perl script that contains several subroutines that allow easy manipulation of a Zimbra server using only the perl modules that were supplied with the Zimbra installation. To setup the script, modify these variables to match your Zimbra server:
Quote:
my $zimbraAdmin = "admin";
my $zimbraPasswd = "z1mbra";
my $mh = "zimbra.test.domain.org";
|
To retrieve either just the Zimbra ID or a complete listing of all of the attributes associated with a specific user account, call one of the following subroutines:
Quote:
get_zimbra_id($mailAcct) # Returns Zimbra ID as a scalar variable
get_account($mailAcct) # Prints all account information
|
To create a new account, call the following subroutine with the new account name, a password, the users name, and an employee number (this is the primary key of our personnel database, not necessary for normal Zimbra operation):
Quote:
|
create_account($newAcct,$newPasswd,$newgivenName,$ newsn,$newdispName,$newempNum)
|
To modify an existing account, call the following subroutine with the account name, the attribute to be modified and the new attribute value:
Quote:
|
modify_account($mailAcct,$modZimAttr,$modZimVal)
|
The policy in our organization is to disable (lock) accounts after a user disappears from our personnel database. A locked account will still receive any email sent to it, however, the user will not be able to log in and retrieve these messages. After a period of 90 days, the account is then closed (mail sent will bounce back to sender) and the admin is notified to archive and remove the account from Zimbra.
Quote:
disable_account($disAcct) # Account locked, still visible in GAL
close_account($disAcct) # Account closed, no longer visible in GAL
|
If the user reappears in our personnel database, we simply call the following subroutine and the existing account is restored to an active state:
Quote:
|
enable_account($disAcct) # Reenable a locked or closed account
|
Hopefully, these subroutines will help someone trying to accomplish a similar task...