Help me with scripts

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
tutek
Posts: 24
Joined: Sat Jun 03, 2017 4:51 pm

Help me with scripts

Post by tutek »

Hi,
I would like to export all users with two columns fields: "mail" and "zimbraAuthLdapExternalDn" so executed command:
zmprov -l gaa -v domain.com | grep -e zimbraAuthLdapExternalDn -e mail

but it list everything with "mail" word. Could you help me?
User avatar
DualBoot
Elite member
Elite member
Posts: 1326
Joined: Mon Apr 18, 2016 8:18 pm
Location: France - Earth
ZCS/ZD Version: ZCS FLOSS - 8.8.15 Mutli servers
Contact:

Re: Help me with scripts

Post by DualBoot »

Hello,

you should work with ldapsearch command which is more appropriate.

Regards
tutek
Posts: 24
Joined: Sat Jun 03, 2017 4:51 pm

Re: Help me with scripts

Post by tutek »

Maybe my script is wrong or e-mail attribute?
User avatar
DualBoot
Elite member
Elite member
Posts: 1326
Joined: Mon Apr 18, 2016 8:18 pm
Location: France - Earth
ZCS/ZD Version: ZCS FLOSS - 8.8.15 Mutli servers
Contact:

Re: Help me with scripts

Post by DualBoot »

the real attribute which match the main address is zimbraMailDeliveryAddress
For information using ldapsearch is more efficient because it does not use Java.
User avatar
ccelis5215
Outstanding Member
Outstanding Member
Posts: 632
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.8.15.GA.3869.UBUNTU18.64 P12

Re: Help me with scripts

Post by ccelis5215 »

tutek wrote:Hi,
I would like to export all users with two columns fields: "mail" and "zimbraAuthLdapExternalDn" so executed command:
zmprov -l gaa -v domain.com | grep -e zimbraAuthLdapExternalDn -e mail

but it list everything with "mail" word. Could you help me?
Hi, fully agree with DualBoot, ldapsearch is way efficient.

Try

Code: Select all

zmprov -l gaa -v domain.com | grep -e "zimbraAuthLdapExternalDn" -e "^mail: "
ccelis
tutek
Posts: 24
Joined: Sat Jun 03, 2017 4:51 pm

Re: Help me with scripts

Post by tutek »

it works, but create zimbraAuthLdapExternalDn on new line, below e-mail
is any way to have e-mail and zimbraAuthLdapExternalDn side by side?

thanks
User avatar
DualBoot
Elite member
Elite member
Posts: 1326
Joined: Mon Apr 18, 2016 8:18 pm
Location: France - Earth
ZCS/ZD Version: ZCS FLOSS - 8.8.15 Mutli servers
Contact:

Re: Help me with scripts

Post by DualBoot »

use sed before the second returning attribute.
tutek
Posts: 24
Joined: Sat Jun 03, 2017 4:51 pm

Re: Help me with scripts

Post by tutek »

Code: Select all

 zmprov -l gaa -v domain.com | grep -e "zimbraAuthLdapExternalDn" sed -e "^mail: " > file.csv
grep: sed: No such file or directory
User avatar
ccelis5215
Outstanding Member
Outstanding Member
Posts: 632
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.8.15.GA.3869.UBUNTU18.64 P12

Re: Help me with scripts

Post by ccelis5215 »

tutek wrote:

Code: Select all

 zmprov -l gaa -v domain.com | grep -e "zimbraAuthLdapExternalDn" sed -e "^mail: " > file.csv
grep: sed: No such file or directory
Try

Code: Select all

zmprov -l gaa -v domain.com | grep -e "zimbraAuthLdapExternalDn" -e "^mail: " |  awk '{ ORS = (NR%2 ? FS : RS) } 1' 
ccelis
tutek
Posts: 24
Joined: Sat Jun 03, 2017 4:51 pm

Re: Help me with scripts

Post by tutek »

no,
now output looks like mail zimbraAuthLdapExternalDn
but in next new line if mail do not have corresponding zimbraAuthLdapExternalDn, then in paste next mail to this line, so it looks mail mail
and because of that next lines have wrong order and wrong corresponding zimbraAuthLdapExternalDn attributes.
Post Reply