Open deajan opened 1 day ago
getting user list should not include mailing lists IMO.
i know exactly how you feel :rofl: . that mlist was historicaly seen a bit different but i can only concur that could be divided to somethine else.
And the --filter=
feature isn't that good at filtering or i just couldn't make out how to do it.
I ended up just using bonkers jq
with the json-output..
e.g.
grom_doms is a function
grom_doms ()
{
grommunio-admin domain query domainname # not needed anymore. ->. | sed '/domainname/d'
}
grom_users is a function
grom_users ()
{
local doms;
if [[ $# -ge 1 ]]; then
doms=$(grep "^${1}" <<<"$(grom_doms)");
else
doms=$(grom_doms);
fi;
for dom in $doms;
do
grommunio-admin user query username status maildir --format json-structured | jq -r '.[]|select((.username|endswith("'"${dom}"'")) and (.maildir|.!="") and ((.status==0) or (.status==4)))|.username';
done
}
grommunio-admin user query
returns users, but also groups, with no way to differentiate users from groups.
it will also give you contacts which at least only show up as 'contact-NNN' (when not of your domain) and status 5/contact
You can differentiate when you query ID status maildir username(not really but could help..)
i wrote this thingy once but never extended it to orgs and contacts but that might help ^_^
#!/bin/bash
set -e
set -x
# retrieve mailbox folders, usually /var/lib/gromox/{user,domain}
domainPrefix=$(grommunio-admin config get options.domainPrefix)
userPrefix=$(grommunio-admin config get options.userPrefix)
# retrieve all configured domains
domaindata="$(grommunio-admin domain query --format=csv --separator=';' homedir ID domainname | grep "^${domainPrefix}")"
userdata="$(grommunio-admin user query --format=csv --separator=';' maildir ID username domainID | grep "^${userPrefix}")"
#
# grommunio-admin domain query --format json-structured ID orgID domainname activeUsers address adminName chat chatID displayname domainStatus endDay homedir homeserverID inactiveUsers maxUser tel title virtualUsers
# grommunio-admin org query --format json-structured ID name domainCount description
# grommunio-admin user query --format json-structured ID aliases changePassword chat chatAdmin domainID forward homeserverID lang ldapID maildir pop3_imap privArchive privChat privFiles privVideo publicAddress smtp status username
#
for domain in ${domaindata[@]}; do
domainID="$(awk -F';' '{print $2}' <<< "$domain")"
domainname="$(awk -F';' '{print $3}' <<< "$domain")"
homedir="$(awk -F';' '{print $1}' <<< "$domain")"
users="$(awk -F';' '$4=='$domainID'' <<< "$userdata")"
for user in $users; do
read maildir username <<< $(awk -F';' '{print $1, $3}' <<< "$user")
done
done
While developping around
grommunio-admin
, I noticed thatgrommunio-admin user query
returns users, but also groups, with no way to differentiate users from groups. Pretty sure that should be a job forgrommunio-admin mlist list
, getting user list should not include mailing lists IMO.Using