Remove a Contact Group

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

A contact group is an instance of the groups category. To remove a contact group on Office Communications Server, the removed contact category instance must be published to the server with the operation type UCCPOT_REMOVE.

Programming Pattern

Removing a contact group involves the following steps:

  • Create a publication manager object by casting an IUccEndpoint object into an IUccPublicationManager object. The publication manager is responsible for creating a publishable category instance object and publication object.
  • Get a publishable category instance representing the group to be added by casting the IUccGroup interface into an IUccCategoryInstance.
  • Set the publication operation on the publishable category to be removed by filling the PublicationOperation property using a Unified Communications Client API enumeration value UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_REMOVE.
  • Create a publication object by calling CreatePublication and casting the returned value to the IUccPublication interface.
  • Register for publication events to catch the asynchronous response to this publication request.
  • Add the IUccCategoryInstance created earlier to the publication with a call into AddPublishableCategoryInstance.
  • Publish the group by calling the Publish method on the publication object. In this example, the optional operation context is not supplied with the request.
public void RemoveGroup(IUccGroup group)
{
   try
   {
     IUccPublicationManager pubMgr = endpoint as IUccPublicationManager;
     // Get the publishable category instance for the contact to be removed
     IUccCategoryInstance cat = group as IUccCategoryInstance;

     // Set publication operation on the category to Remove
     categoryInstance.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_REMOVE;
     IUccPublication pub = pubMgr.CreatePublication() as IUccPublication;
     UCC_Advise<_IUccPublicationEvent>(pub, this);
     pub.AddPublishableCategoryInstance(cat);
     pub.Publish(null);
   }
   catch (COMException ex)
   {
      Console.WriteLine(ex.ToString());
   }
}

See Also

Concepts

Create a Contact Group
Add a Contact to a Contact Group
Move a Contact to Another Contact Group
Remove a Contact from a Contact Group
Rename a Contact Group