This example provides a common pattern for filtering Lookup Service registration data. This example is based on the code in the LsConnection.cs sample file. The file is located in the following vCloud Suite SDK for .NET directory: client/samples/src/Samples/vmware/vcloud/suite/samples/common/

This example uses the steps that are described in the Retrieve a vCenter Server ID by Using the Lookup Service procedure.

using System;
using System.Linq;
using vmware.vapi.util.security;
 
public String getMgmtNodeId(String nodeInstanceName)
{
  // 1 - List the vCenter Server instances.
  var services = LookupServiceUrls("com.vmware.cis",
                    "vcenterserver",
                                   "vmomi",
                                   "com.vmware.vim");
 
  // 2 - Find the matching node name and save the ID.
  foreach (var service in services)
  {
    foreach (var serviceAttribute in service.serviceAttributes
    {
      if (serviceAttribute.key.Equals("com.vmware.vim.vcenter.instanceName",
             StringComparison.CurrentCultureIgnoreCase) &&
          nodeInstanceName.Equals(serviceAttribute.value,
             StringComparison.CurrentCultureIgnoreCase))
      {
         return service.nodeId;
      }
    }
  }
}