GetTenantList

Description

Retrieves a list of tenants that the specified user has access to.

Parameters

Parameter

Type

Description

activeTenantsOnly

boolean

The value true specifies that only active tenants are returned. The value false specifies that all tenants are returned.

Return Value:

Value

Type

Description

GetTenantListResult

ArrayOfTenant

The list of tenant objects.

Interfaces

  • Dynamics GP
  • Common

Examples

The following C# example retrieves the status that indicates whether tenants are enabled for the Microsoft Dynamics GP installation. If tenants aren't enabled, a message is displayed. If tenants are enabled, the list of active tenants is retrieved and displayed in a message box.

JJ902650.LegacyEndpoint(en-us,MSDN.10).gif** Legacy endpoint**

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            bool tenantEnabled;
            Tenant[] tenants;

            // Create an instance of the service
            DynamicsGP wsDynamicsGP = new DynamicsGP();

            // Be sure the default credentials are used
            wsDynamicsGP.UseDefaultCredentials = true;

            // Find out whether tenants are enabled
            tenantEnabled = wsDynamicsGP.MultitenantEnabled();

            if (tenantEnabled == true)
            {
                // Tenants are enabled, so retrieve a list of active tenants
                tenants = wsDynamicsGP.GetTenantList(true);

                // Display the list of tenants
                StringBuilder tenantList = new StringBuilder();
                foreach (Tenant t in tenants)
                {
                    tenantList.AppendLine(t.Name);
                }

                MessageBox.Show(tenantList.ToString());
            }
            else
            {
                MessageBox.Show("Tenants are not enabled.");
            }
        }
    }
}

JJ902650.NativeEndpoint(en-us,MSDN.10).gif** Native endpoint **

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            bool tenantEnabled;
            Tenant[] tenants;

            // Create an instance of the service
            DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

            // Find out whether tenants are enabled
            tenantEnabled = wsDynamicsGP.MultitenantEnabled();

            if (tenantEnabled == true)
            {
                // Tenants are enabled, so retrieve a list of active tenants
                tenants = wsDynamicsGP.GetTenantList(true);

                // Display the list of tenants
                StringBuilder tenantList = new StringBuilder();
                foreach (Tenant t in tenants)
                {
                    tenantList.AppendLine(t.Name);
                }

                MessageBox.Show(tenantList.ToString());
            }
            else
            {
                MessageBox.Show("Tenants are not enabled.");
            }

            // Close the service
            if (wsDynamicsGP.State != CommunicationState.Faulted)
            {
                wsDynamicsGP.Close();
            }
        }
    }
}