We have been using the distribution lists feature via the Admin UI for a while now, and we keep finding more and more uses for them. The only problem that we have come across (caused by us) is that we need to periodically audit the members of each distribution list. We do this to make sure that all required users are on each list, and that no one is on a list that they shouldn't be.
I did not see anything already available that did this so I put together a real basic LDAP query to accomplish this task. I figured that if I needed to do this someone else would also, so here is the basic query to list the members of all distribution lists:
ldapsearch -x -v -H 'ldap://localhost/' -b 'ou=people,dc=mydomain,dc=com' "objectClass=zimbraDistributionList" mail zimbraMailForwardingAddress
If you only want to list a single distribution list you can run the query as follows:
ldapsearch -x -v -H 'ldap://localhost/' -b 'uid=distributionlistname,ou=people,dc=mydomain,dc=com' "objectClass=zimbraDistributionList" mail zimbraMailForwardingAddress
These commands need to be run as the zimbra user. Also, make sure you replace these strings:
mydomain - should be your domain name
distributionlistname - should be the name of the distribution list you are trying to list
Hopefully, someone else will get some use out of this.
RobertJ
[SOLVED] Listing Distribution List Members
[SOLVED] Listing Distribution List Members
Simpler would be to :
su zimbra
zmprov gdl list@domain.com
If you forget the list names:
zmprov gadl (or zmprov gadl domain.com)
su zimbra
zmprov gdl list@domain.com
If you forget the list names:
zmprov gadl (or zmprov gadl domain.com)
[SOLVED] Listing Distribution List Members
Funny enough I prefer the ldap search query over the zmprov's method since usually the people who ask for such information do not need to know all the information the it provides.
zmprov gadl > /tmp/distlist.tmp
for list in `cat /tmp/distlist.tmp`; do
zmprov gdl $list > /home/zimbra/temp/$list;
done
Which will give you a directory full of text files for each distribution list.
Which I might now modify with the ldap queries.
zmprov gadl > /tmp/distlist.tmp
for list in `cat /tmp/distlist.tmp`; do
zmprov gdl $list > /home/zimbra/temp/$list;
done
Which will give you a directory full of text files for each distribution list.
Which I might now modify with the ldap queries.
-
- Posts: 28
- Joined: Sat Sep 13, 2014 1:24 am
[SOLVED] Listing Distribution List Members
Hello,
glitch23 I have ran your script but getting an error:
"ambiguous redirect".
Maybe you know how to solve it?
Thank You
glitch23 I have ran your script but getting an error:
"ambiguous redirect".
Maybe you know how to solve it?
Thank You
[SOLVED] Listing Distribution List Members
[quote user="11444Mindaugas"]Maybe you know how to solve it?[/QUOTE]How about one of these: site:zimbra.com +"ambiguous redirect" - Yahoo! Search Results
If that doesn't work an internet search for the error message should find an answer.
If that doesn't work an internet search for the error message should find an answer.
[SOLVED] Listing Distribution List Members
[quote user="11444Mindaugas"]Hello,
glitch23 I have ran your script but getting an error:
"ambiguous redirect".
Maybe you know how to solve it?
Thank You[/QUOTE]
Make sure you use back ticks(sp?) " ` " versus apostrophes " ' "
for list in 'cat /tmp/distlist.tmp'; do (This will give you an error)
...
for list in `cat /tmp/distlist.tmp`; do (This will not)
glitch23 I have ran your script but getting an error:
"ambiguous redirect".
Maybe you know how to solve it?
Thank You[/QUOTE]
Make sure you use back ticks(sp?) " ` " versus apostrophes " ' "
for list in 'cat /tmp/distlist.tmp'; do (This will give you an error)
...
for list in `cat /tmp/distlist.tmp`; do (This will not)
-
- Posts: 28
- Joined: Sat Sep 13, 2014 1:24 am
[SOLVED] Listing Distribution List Members
Thank you very much.
[SOLVED] Listing Distribution List Members
I made this:
for lista in `zmprov gadl`; do
echo -e "$lista
" >> /tmp/listmembers.txt
for usuario in `zmprov gdl $lista | grep zimbraMailForwardingAddress | cut -d" " -f2`; do
member=`zmprov ga $usuario | grep displayName | cut -d: -f2`
echo -e "$usuario $member" >> /tmp/listmembers.txt
done
echo -e "----------
" >> /tmp/listmembers.txt
done
It creates a file (/tmp/listmembers.txt) in a very readable format.
Regards
for lista in `zmprov gadl`; do
echo -e "$lista
" >> /tmp/listmembers.txt
for usuario in `zmprov gdl $lista | grep zimbraMailForwardingAddress | cut -d" " -f2`; do
member=`zmprov ga $usuario | grep displayName | cut -d: -f2`
echo -e "$usuario $member" >> /tmp/listmembers.txt
done
echo -e "----------
" >> /tmp/listmembers.txt
done
It creates a file (/tmp/listmembers.txt) in a very readable format.
Regards
[SOLVED] Listing Distribution List Members
Thank for sharing this. Could you please let me know how to import all distribution lists and members to new zimbra server using shell script?