Automation: how to change all users's individual signatures: Difference between revisions
Line 8: | Line 8: | ||
== How to change users's individual signatures based on their ldap attributes globally == | == How to change users's individual signatures based on their ldap attributes globally == | ||
---- | |||
==Purpose== | ==Purpose== | ||
Line 30: | Line 30: | ||
do | do | ||
echo -ne "Checking account: $i \t" | echo -ne "Checking account: $i \t" | ||
$path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE | $path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE | ||
signature=`$path/zmprov ga $i | egrep "(^cn|^ou|^company|^street|^telephoneNumber|^mobile|^title)" | cut -d : -f 2 | sed 's/^\ //g'` | signature=`$path/zmprov ga $i | egrep "(^cn|^ou|^company|^street|^telephoneNumber|^mobile|^title)" | cut -d : -f 2 | sed 's/^\ //g'` | ||
$path/zmprov ma $i zimbraPrefMailSignature "$signature" | $path/zmprov ma $i zimbraPrefMailSignature "$signature" | ||
echo "done!" | echo "done!" | ||
Revision as of 21:49, 25 September 2015
Zimbra Automation
- This article is a Work in Progress, and may be unfinished or missing sections.
Zimbra automation using scripting.
How to change users's individual signatures based on their ldap attributes globally
Purpose
The purpose of this article is to show how to create a simple script which, can modify every user's signature globally, based on their ldap attribute values in ldap.
Resolution
For the purpose we will use two scripts. In the process I will explain why combining the two scripts into one will not work.
Script 1
#!/bin/bash path="/opt/zimbra/bin" for i in `/opt/zimbra/bin/zmprov -l gaa` do echo -ne "Checking account: $i \t" $path/zmprov ma $i zimbraPrefMailSignatureEnabled TRUE signature=`$path/zmprov ga $i | egrep "(^cn|^ou|^company|^street|^telephoneNumber|^mobile|^title)" | cut -d : -f 2 | sed 's/^\ //g'` $path/zmprov ma $i zimbraPrefMailSignature "$signature" echo "done!" done
- The first script does the following:
- set the default path to zmprov.
- sets the zimbraPrefMailSignatureEnabled attribute to TRUE.
- sets a variable called signature.
- assigns to this variable different attribute values, that are assign to that user in LDAP. In this example: (^cn|^ou|^company|^street|^telephoneNumber|^mobile|^title). The attributes can be changed as per the admin needs.
- the last line modifies the account, as it writes the values from LDAP to the signature of the user.
Script 2
#!/bin/bash path="/opt/zimbra/bin" for i in `/opt/zimbra/bin/zmprov -l gaa` do echo -ne "Adding SignatureID to account: $i \t" signatureid=`$path/zmprov ga $i zimbraSignatureId | sed -n '2p' | cut -d : -f 2 | sed 's/^\ //g'` $path/zmprov ma $i zimbraPrefDefaultSignatureId "$signatureid" $path/zmprov ma $i zimbraPrefForwardReplySignatureId "$signatureid" echo "done!" done
- The second script:
- assigns a value to the zimbraSignatureId attribute.
- assigns the value from zimbraSignatureId, to the zimbraPrefDefaultSignatureId attribute.
- assigns the value from zimbraSignatureId, to the zimbraPrefForwardReplySignatureId attribute.