Help me with scripts

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

Help me with scripts

Postby tutek » Thu Jul 25, 2019 12:39 pm

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: 1133
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

Postby DualBoot » Thu Jul 25, 2019 1:23 pm

Hello,

you should work with ldapsearch command which is more appropriate.

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

Re: Help me with scripts

Postby tutek » Thu Jul 25, 2019 2:24 pm

Maybe my script is wrong or e-mail attribute?
User avatar
DualBoot
Elite member
Elite member
Posts: 1133
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

Postby DualBoot » Thu Jul 25, 2019 3:17 pm

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: 609
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.0.9.GA.6191.UBUNTU12.64 FOSS

Re: Help me with scripts

Postby ccelis5215 » Thu Jul 25, 2019 3:18 pm

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: 12
Joined: Sat Jun 03, 2017 4:51 pm

Re: Help me with scripts

Postby tutek » Thu Jul 25, 2019 3:31 pm

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: 1133
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

Postby DualBoot » Thu Jul 25, 2019 3:33 pm

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

Re: Help me with scripts

Postby tutek » Thu Jul 25, 2019 3:39 pm

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: 609
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.0.9.GA.6191.UBUNTU12.64 FOSS

Re: Help me with scripts

Postby ccelis5215 » Thu Jul 25, 2019 3:58 pm

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: 12
Joined: Sat Jun 03, 2017 4:51 pm

Re: Help me with scripts

Postby tutek » Thu Jul 25, 2019 4:20 pm

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.

Return to “Administrators”

Who is online

Users browsing this forum: MSN [Bot] and 7 guests