GetWSEnabledCompanyForUserList


Description

Retrieves a list of company objects for which the current user is assigned to at least one security role, allowing them to run service methods.

Parameters

Parameter

Type

Description

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetWSEnabledCompanyForUserListResult

ArrayOfCompany

The collection of company objects for which the user is able to run methods.


Interfaces

 

Examples

The following C# example displays a list of all companies the current user can run web methods in.

 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)
		{
			Context context;
			Company[] companies;

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

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

			// Create a context with which to call the service
			context = new Context();

			// Set up the context object
			context.OrganizationKey = null;

			// Retieve the list of companies enabled for the current user
			companies = wsDynamicsGP.GetWSEnabledCompanyForUserList(context);

			// Display the list of companies
			StringBuilder companyList = new StringBuilder();
			foreach (Company c in companies)
			{
				companyList.AppendLine(c.Name);
		}
			MessageBox.Show(companyList.ToString());
	}
}
}

 Native endpoint

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

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			Context context;
			Company[] companies;

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

			// Create a context with which to call the service
			context = new Context();

			// Set up the context object
			context.OrganizationKey = null;

			// Retieve the list of companies enabled for the current user
			companies = wsDynamicsGP.GetWSEnabledCompanyForUserList(context);

			// Display the list of companies
			StringBuilder companyList = new StringBuilder();
			foreach (Company c in companies)
			{
				companyList.AppendLine(c.Name);
		}
			MessageBox.Show(companyList.ToString());

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


Documentation Feedback