How to create a contact group from CLI

Revision as of 10:23, 10 July 2020 by GopalBhandari (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

How to create contact and contact group from CLI using Zmsoap command


   KB 24117        Last updated on 2020-07-10  




0.00
(0 votes)


Problem

How create contact and contact group from CLI using Zmsoap command and add local contact and GAL contact in the contact group?

Solution

Create a local contact through the Zmsoap command.

Create the SOAP XML as per Zimbra SOAP API /tmp/createcontact.xml and add the following line in this file and save.

<CreateContactRequest xmlns="urn:zimbraMail">
<cn l="7">
<a n="firstName">Test</a>
<a n="lastName">Test</a>
<a n="homeStreet">Test street</a>
<a n="mobilePhone">8000062359</a>
<a n="fullName">Test, Test</a>
<a n="email">test@gmail.com</a>
</cn>
</CreateContactRequest>

Run the below command to create local contact:

$zmsoap -v -z -m user@domain.com -f /tmp/createcontact.xml 

Create a contact group through Zmsoap.

Create the SOAP XML as per Zimbra SOAP API /tmp/createcontact_group.xml and add the following line in this file and save.

<CreateContactRequest xmlns="urn:zimbraMail">
<cn l="7">
<a n="fileAs">8:testgroup</a>
<a n="nickname">testgroup</a>
<a n="type">group</a>
<a n="fullName">testgroup</a>
</cn>
</CreateContactRequest>

Run the below command to create a contact group:

$zmsoap -v -z -m user@domain.com -f /tmp/createcontact.xml

Add the local contact in contact group.

$zmsoap -v -z -m user@domain.com ModifyContactRequest/cn @id=group_id m/@op="+" @type="C" @value="contact_id"

Here "group_id" is contact group ID and "contact_id" is the local contact ID.

Run the following command to get group_id and contact_id :

$zmmailbox -z -m user@domain.com  gact >/tmp/getall_contact.txt

You will get both ids in this file /tmp/getall_contact.txt.

Add the GAL contact in contact group.

$zmsoap -v -z -m test2@domain.com ModifyContactRequest/cn @id=group_id m/@op="+" @type="G" @value="uid=Gopal,ou=people,dc=domain,dc=com"

Here "group_id" is a contact group ID and "uid=Gopal,ou=people,dc=domain,dc=com" GAL contact we want to add in the contact group.

Contact gopal@domain.com save in LDAP that format "uid=Gopal,ou=people,dc=domain,dc=com" , replace UID with actual contact name and domain.

From more reference Zimbra SOAP API external link

Submitted by: Gopal Singh Bhandari
Verified Against: ZCS 8.8 Date Created: 2020-07-10
Article ID: https://wiki.zimbra.com/index.php?title=How_to_create_a_contact_group_from_CLI Date Modified: 2020-07-10



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »


Jump to: navigation, search