Retrieves a list of security objects for the specified member within the specified security context. The security objects identify the role summary objects for the member.
Parameter |
Type |
Description |
---|---|---|
member |
The member’s logon name. The property should be set to the logon name in the form: DOMAIN\USERNAME. |
|
context |
A security context object that specifies the application and scope properties of the request. |
Value |
Type |
Description |
---|---|---|
GetRolesResult |
A list of security objects that identify the roles for the specified member. |
The following C# example retrieves the list of role summary objects for a specified member. The example’s security context uses the Microsoft Dynamics GP web service application and the sample company. The member is identified by the logon name “DOMAIN\\username“. A message box displays all the role names for the specified member.
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using DynamicsSecurityServiceSample.DynamicsSecurityWebService; namespace DynamicsSecurityServiceSample { class Program { static void Main(string[] args) { ApplicationKey applicationKey; ScopeKey scopeKey; SecurityContext securityContext; SecurityObject[] roles; // Create an instance of the security service DynamicsSecurityService wsDynamicsSecurity = new DynamicsSecurityService(); // Use default credentials wsDynamicsSecurity.UseDefaultCredentials = true; // Create a security context object securityContext = new SecurityContext(); // Create the application key and add it to the security context object // Use the ID of the Dynamics GP web service application applicationKey = new ApplicationKey(); applicationKey.Id = "25cc1a21-2cc4-4b13-a1c8-eea186fb688a"; securityContext.ApplicationKey = applicationKey; // Create the scope key and add it to the security context object // Use the Id of the sample company scopeKey = new ScopeKey(); scopeKey.Id = "-1"; securityContext.ScopeKey = scopeKey; // Retrieve the list of security objects roles = wsDynamicsSecurity.GetRoles("DOMAIN\\username", securityContext); // Display the name property from each role summary object StringBuilder summaryList = new StringBuilder(); foreach (RoleSummary a in roles) { summaryList.AppendLine("Role name: " + a.Name); } MessageBox.Show(summaryList.ToString()); } } }