Developing for Dynamics GP

by David Musgrave (Perth, WA, Australia) and the Microsoft Dynamics GP Developer Support Team (Fargo, ND, USA)

Visual Studio Tools and Dynamics GP Security

Visual Studio Tools and Dynamics GP Security

  • Comments 2

David Meego - Click for blog homepageMichael Johnson recently discussed Visual Studio Tools Integration with GP Security on his blog.  Michael's post looked at how you can obtain the credentials you need to log into the SQL Server as the current user.

I would like to expand on this a little further.  When I think of Dynamics GP Security, I think about the application level security that restricts access to forms. So how can I leverage this application level security for my Visual Studio Tools forms?

The answer is to use Menus for Visual Studio Tools for Microsoft Dynamics GP 10.0 to access your forms and let it handle the security integration for you.  Built into Menus for Visual Studio Tools is the ability to link the security of your Visual Studio Tools form to any Dexterity form in any Dictionary.  You just need to specify the Dictionary ID and Resource ID. There is a helper function to convert the Dexterity Form's Technical Name to a Resource ID for you.

You can apply the security either when you register the menu entry for your Visual Studio Tools form or after you have registered your menu entry. Please see the code excerpts below taken from the example code which comes with Menus for Visual Studio Tools. These excerpts only show the main calls used and do not have the error handling of the full code.  Please use the full code included in the downloadable archive. The example registers two menus, one with Security and one without and then uses an additional command to add security to the second menu.

VB.Net Example

Dim MenuTag1 As Short
Dim
MenuTag2 As Short
Dim
ResID As Short = 0

' Get Security Form Resource ID for menus to inherit security access from
ResID = MenusForVisualStudioTools.Functions.GetFormResId.Invoke( _
                   DYNAMICS,
"PM_Vendor_Maintenance")

' Add Menu entry using API Function call to create first sub menu entry with security
MenuTag1 = MenusForVisualStudioTools.Functions.RegisterWithSecurity.Invoke( _
                   MenuListTag1, _
                  
"VS VB Test 1", _
                  
"Click for VS VB Test 1", _
                   Asc(
"A"), COMMAND_SHORTCUT_CTRLSHIFT, _
                  
True, False, False, _
                   0, _
                  
False, False, _
                   DYNAMICS, ResID)

' Add Menu entry using API Function call to create second sub menu entry without security
MenuTag2 = MenusForVisualStudioTools.Functions.Register.Invoke( _
                   MenuListTag1, _
                  
"VS VB Test 2", _
                  
"Click for VS VB Test 2", _
                   Asc(
"B"), COMMAND_SHORTCUT_CTRLSHIFT, _
                  
False, False, False, _
                   0, _
                  
False, False)

' And then add security as a separate step
Err = MenusForVisualStudioTools.Functions.ApplySecurity.Invoke( _
                   MenuTag2, _
                   DYNAMICS, ResID)

 

 

C# Example

short MenuTag1;
short MenuTag2;
short ResID = 0;

// Get Security Form Resource ID for menus to inherit security access from
ResID = MenusForVisualStudioTools.Functions.GetFormResId.Invoke(
                   DYNAMICS,
"RM_Customer_Maintenance"); // Get Form Resource ID for Security

// Add Menu entry using API Function call to create first sub menu entry with security
MenuTag1 = MenusForVisualStudioTools.Functions.RegisterWithSecurity.Invoke(
                   MenuListTag1,
// Parent Command Tag
                  
"VS C\\# Test 1", // Menu Caption
                  
"Click for VS C# Test 1", // Menu Tooltip
                  
(int)'A', COMMAND_SHORTCUT_CTRLALT, // Menu Shortcut Key, Shortcut Modifier
                  
true, false, false, // Checked, Disabled, Hidden
                  
0, // Add Below Command Tag
                  
false, false, // Add Separator, Add Command List
                  
DYNAMICS, ResID); // Security Dictionary and Form Resource ID

// Add Menu entry using API Function call to create second sub menu entry without security

MenuTag2 = MenusForVisualStudioTools.Functions.Register.Invoke(
                   MenuListTag1,
// Parent Command Tag
                  
"VS C\\# Test 2", // Menu Caption
                  
"Click for VS C# Test 2", // Menu Tooltip
                  
(int)'B', COMMAND_SHORTCUT_CTRLALT, // Menu Shortcut Key, Shortcut Modifier
                  
false, false, false, // Checked, Disabled, Hidden
                  
0, // Add Below Command Tag
                  
false, false); // Add Separator, Add Command List

// And then add security as a separate step
Err = MenusForVisualStudioTools.Functions.ApplySecurity.Invoke(
                   MenuTag2,
// Command Tag
                  
DYNAMICS, ResID); // Security Dictionary and Form Resource ID

 

 

For the links to download the tool and information about support please follow the link below:

Menus for Visual Studio Tools - The wait is over

David

Page 1 of 1 (2 items)
Comments Information

PLEASE READ BEFORE POSTING

Please only post comments relating to the topic of this page.

If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.

Leave a Comment
  • Please add 7 and 8 and type the answer here:
  • Post