Results 1 to 8 of 8

Thread: Create Contacts and Contact Groups from CLI

  1. #1
    _ariel_ is offline New Member
    Join Date
    Oct 2012
    Location
    Argentina
    Posts
    4
    Rep Power
    2

    Default Create Contacts and Contact Groups from CLI

    Hi all, I'm using Zimbra 8 OSE. I need to migrate contacts from Roundcube to my new Zimbra installation. Roundcube stores this data in mysql database, so I got the contacts, the contact groups and the users in two txt files. The first file contain users and contacts order by users, and the Second file contains users, contact groups and contacts order by users. Then I'll create a script to insert this data in every account that has contacts and/or contact groups with the zmmaibox command.

    First for the account test@domain.com I created a group called "grupo" and a contact named "Juan Perez" with email "jperez@example.com" and then join that contact to the group "grupo" everything do it from the Web Client. Then whit the command zmmailbox -z -m test@domain.com gact -v from CLI I've got:

    [
    {
    "attrs": {
    "email": "jperez@example.com",
    "firstName": "Juan",
    "lastName": "Perez"
    },
    "date": 1350854387000,
    "flags": "",
    "folderId": "7",
    "hasFlags": false,
    "hasTags": false,
    "id": "7593",
    "isFlagged": false,
    "isGalContact": false,
    "isGroup": false,
    "metaDataChangedDate": 1350854387000,
    "revision": "95364",
    "tagIds": ""
    }
    ,
    {
    "attrs": {
    "fileAs": "8:grupo",
    "nickname": "grupo",
    "type": "group"
    },
    "date": 1351458944000,
    "flags": "",
    "folderId": "7",
    "hasFlags": false,
    "hasTags": false,
    "id": "7606",
    "isFlagged": false,
    "isGalContact": false,
    "isGroup": true,
    "metaDataChangedDate": 1351458944000,
    "revision": "123532",
    "tagIds": ""
    }
    ]

    But I don't see anything that reference the contact with the group. So, I deleted the group and the contact, then created everything from CLI.

    To create a contact from CLI I use:
    zmmailbox -z -m test@domain.com cct email "jperez@example.com" firstName "Juan" lastName "Perez"

    To create a contact group from CLI I use:
    zmmailbox -z -m test@domain.com cct nickname "grupo" fileAs "8:grupo" type "group"

    I know the use of the attribute "dlist" but it's not doing what I want.

    If I use:
    zmmailbox -z -m test@domain.com cct nickname "grupo" fileAs "8:grupo" type "group" dlist "jperez@example.com"

    It doesn't show the contact added to the group "grupo" in the Web Client, but it shows the attribute "dlist" when I check it with zmmailbox -z -m test@domain.com gact -v. Off course, if I compose a new message and try to write the name of the group in te TO box, it doesn't shows because the group is empty.

    Is there a way to create a contact and add it to a previusly created group, or something like that?

    Thanks for the help!

  2. #2
    strnous is offline New Member
    Join Date
    Oct 2012
    Location
    Czech Republic
    Posts
    3
    Rep Power
    2

    Default

    We are having similar problem.

    We have developed a script which relies on getting the list of users within a contact group as seen in dlist attribute in pre 8.0.0 Zimbra versions. We used zmprov/zmmailbox commands for that purpose. Since 8.0.0 upgrade the dlist attribute or any other containing contact group members isn't present in the zmprov/zmmailbox output.
    The command we actually use is:
    zmprov sm <some_account> gact -f <address_book_folder>

    Currently we are not aware of any CLI way to extract the members of a contact group

  3. #3
    ccelis5215 is offline Elite Member
    Join Date
    Jun 2011
    Location
    Caracas Venezuela
    Posts
    443
    Rep Power
    3

    Default

    Hello _ariel_,

    I'm not sure about group concept here, i wonder if you are looking for folders in Contacts... if so:

    Create folder in Contacts using

    Code:
    zmmailbox -z -m test@domain.com cf -V contact /Contacts/Grupo
    Then, create contacts under the folders
    Code:
    zmmailbox -z -m test@domain.com cct -f /Contacts/Grupo firstName "test" email "test@email.com"
    Hope it's helps.

    ccelis


    EDIT: Sorry, i miss the Contact Group feature available in ZCS. I'll be digging...
    Last edited by ccelis5215; 10-29-2012 at 07:27 PM. Reason: Contact group in ZCS 8

  4. #4
    ccelis5215 is offline Elite Member
    Join Date
    Jun 2011
    Location
    Caracas Venezuela
    Posts
    443
    Rep Power
    3

    Default

    Hello strnous,

    Use attributes to look for.

    Code:
    zmprov sm <some_account> gact -f <address_book_folder> firstName email
    ccelis

  5. #5
    _ariel_ is offline New Member
    Join Date
    Oct 2012
    Location
    Argentina
    Posts
    4
    Rep Power
    2

    Default

    Hi ccelis5215,
    Thanks for your answer, I'm not looking for folders in Contacts. The concept of a Contact Group is the same as Distribution Lists but created by the user in his personal addressbook. The user can create a Group, then add some contacts (personal contacts, gal contacts, etc) and later he can send emails to that group and every member receives the message. I'm able to create this Contact Group in my addressbook using the ZCS Webmail interface and use it normally.
    What I was looking for is the way to tell zmmaibox/zmprov to create a Contact Group and add Contacts previusly created for an existing account. Or maybe create a Contact and make it member of an existing Group, I don't know.

    Thanks for the help.

  6. #6
    strnous is offline New Member
    Join Date
    Oct 2012
    Location
    Czech Republic
    Posts
    3
    Rep Power
    2

    Default

    Quote Originally Posted by ccelis5215 View Post
    Hello strnous,

    Use attributes to look for.

    Code:
    zmprov sm <some_account> gact -f <address_book_folder> firstName email
    ccelis
    Hello ccelis,

    what you describe here i unfortunately not useful for contact group.
    The contact group is a special contact entry of type group. In previous versions each contact of type group had an attribute called dlist which contained a list of contacts which were members of that group. The attribute could be manipulated via CLI (zmprov/smmailbox) and in the same way via web client.
    Since 8.0.0 there's no dlist attribute for contact group (contact with type group) or any other attribute showing the group members even though members were already added to the group via GUI.
    Similarly when one sets/changes the dlist attribute of contact group using zmprov/zmmailbox the change is not reflected in the GUI.

  7. #7
    ccelis5215 is offline Elite Member
    Join Date
    Jun 2011
    Location
    Caracas Venezuela
    Posts
    443
    Rep Power
    3

    Default

    Hi strnous,

    Your completely right, ZCS 8 stores references about contacts in groups instead of contact itself. A very good improvement in my opinion.

    I've been playing with contact groups as _ariel_ with no luck, maybe zmprov/zmmailbox doesn't provide options to configure from CLI or there's no documentation to modify contacts to the group. There's an "groupMember" attribute but didn't find how to use.

    Maybe i'ts time to fill an RFE.

    Just to know, create a group named testcontactgroup, then via ZWC add two contacts, another contact from GAL and a no contact.

    Look how zmprov -d show the SOAP response:

    Code:
    zmprov -d sm testaccount@domain.com gact
    <cn id="2811" fileAsStr="testcontact8x" f="" tn="" rev="48" d="1351600820000" t="" md="1351600820" ms="48" l="7">
    <meta/>
    <a n="nickname">testcontact8x</a>
    <a n="type">group</a>
    <a n="fileAs">8:testcontact8x</a>
    <m value="2571" type="C"/>
    <m value="2585" type="C"/>
    <m value="uid=someuser,ou=people,dc=domain,dc=com" type="G"/>
    <m value="42c05ca7-00f0-47bc-bd18-89d0b36f8eb9:261" type="C"/>
    </cn>
    ...
    ...
    Id: 2811
    Folder: /Contacts
    Date: 10/30/12 19:23
    Revision: 105
    Attrs:
    nickname: testcontact8x
    fileAs: 8:testcontact8x
    type: group
    In ZCS 7.1.4:

    <cn id="174681" f="" fileAsStr="testcontact7x" d="1351645822000" rev="298488" t="" md="1351645822" ms="298488" l="7">
    <meta/>
    <a n="nickname">testcontact7x</a>
    <a n="dlist">"somename" &lt;someemail@somedomain.com>, "Another contact" &lt;anothercontact@domain.com></a>
    <a n="type">group</a>
    <a n="fileAs">8:testcontact7x</a>
    </cn>
    ...
    ...
    Id: 174681
    Folder: /Contacts
    Date: 10/30/12 20:40
    Revision: 298488
    Attrs:
    nickname: testcontact7x
    dlist: "somename" <someemail@somedomain.com>, "Another contact" <anothercontach@domain.com>
    fileAs: 8:testcontact7x
    type: group
    ccelis

  8. #8
    SandroInova is offline Starter Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    1

    Default

    Hi folks,

    I have the same problem provisioning group of contacts, as a workaround I did an import by command line, that way it's possible to continue with the bulk provisioning:
    Code:
    /opt/zimbra/bin/zmmailbox -z -m mail@domain postRestURL \"/Contacts/?fmt=csv&resolve=reset\" contact.csv
    Export group contacts in the zimbra UI of a particular account: preferences > Import/Export > Choose Contacts and the specified folder
    With that in hand, you could see the format to create your csv accordingly to your needs.

    I hope this tip help somebody.

    Tested with 8.0.6 NE.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Contact Groups
    By Mindways in forum Users
    Replies: 1
    Last Post: 06-27-2012, 10:47 AM
  2. Contact Groups dissapear and Contacts multiply
    By Physicsguy in forum General Questions
    Replies: 0
    Last Post: 08-04-2011, 08:06 PM
  3. Contacts and Contact Groups
    By pbowden in forum General Questions
    Replies: 0
    Last Post: 08-26-2010, 09:33 AM
  4. Replies: 1
    Last Post: 08-26-2009, 12:35 PM
  5. Replies: 5
    Last Post: 08-03-2009, 03:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •