Display Firstname, Lastname, Email, Lastlogon, MailBox size



  • Dear All,

    I need the below details of all my users on my zarafa mail server

    first name , lastname , email id , last log on and mailbox size

    zarafa-admin username gives me the above details but need for all users

    It can be done with a script but i am new babe in scipting…
    really appreciate some one can he help

    regards

    simon


  • Kopano

    @sbdcunha

    You can user python-kopano for this
    This example should do the trick (not really tested)

    import kopano
    from kopano.errors import *
    from MAPI.Tags import *
    
    for user in kopano.users():
        print("firstname: {}".format(user.prop(PR_GIVEN_NAME_W).value))
        print("Surname: {}".format(user.prop(PR_SURNAME_W).value))
        print("storeid: {}".format(user.store.entryid))
        try:
            print("last logon: {}".format(user.store.prop(PR_LAST_LOGON_TIME).value))
        except NotFoundError:
            print("last logon: never")
        print("mailboxsize: {}".format(user.store.size))
    


  • Based on zarafa-admin, I’m using the following shell script :

    /usr/bin/showusers.sh

    #!/bin/sh
    #hostname=`hostname` 
    
    if  [ "$1"  =  "all" ] ;  then
        userlist=`zarafa-admin -l | awk '{print $1}'`
      else
        hostname=`hostname`
        userlist=`zarafa-admin -l | grep -i $hostname |awk '{print $1}'`
    fi
    
    for i in $userlist
    do
      zarafa-admin --details $i > /tmp/oneuser.txt 2>/dev/null
      size=`cat /tmp/oneuser.txt | grep "Current store"|cut --delimiter=":" -f 2`
      ll=`cat /tmp/oneuser.txt | grep "Last logon"|cut --delimiter=":" -f 2| cut -c-12`
      ac=`cat /tmp/oneuser.txt | grep "Active"|cut --delimiter=":" -f 2`
      hs=`cat /tmp/oneuser.txt | grep "Home server"|cut --delimiter=":" -f 2`
      echo  "$i \t $size \t $ll \t $hs \t $ac"
    done
    


  • Thanks you so much eli
    I will check it out and let you know

    regards

    simon



  • dear eli,

    I tried to run the script but no file is being creted.
    apprecite if you can help me to debug the scriprt as to where i am going wrong

    thanks and regards

    simon



  • You’re still using old zarafa?

    Pipe the whole script in less

    script.sh | less
    

    quick&dirty:

    for name in $(zarafa-admin -l |sed -n 5,1000p | cut -f 2 | sort)
    do
            zarafa-admin --details $name > /tmp/details.txt
            grep Fullname /tmp/details.txt
            grep size /tmp/details.txt
            grep Email /tmp/details.txt
            grep logon /tmp/details.txt     
    done
    

  • Kopano

    No need to redirect the output into a file. You could also store the output of zarafa-admin/kopano-admin/kopano-cli in a variable.



  • Dear Guys,

    Thank you for you support and help… really apprecite
    actually when i run the script the /tmp/detials.txt file was just 546 bytes and had only details of 2 usernames but i did a direct of the script itself to a file and it worked just the way i wanted

    once again thanks a lot

    regards

    simon


Log in to reply