Visual Studio Tools and Dynamics GP Security


David Meego - Click for blog homepageThis is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.

Michael 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

This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on http://www.winthropdc.com/blog.

3 thoughts on “Visual Studio Tools and Dynamics GP Security

Please post feedback or comments

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.