Sunday, December 04, 2011

Tech Tuesday is back and not just on Tuesdays.

Scripting and database connections.

The ability to create and run scripts within SmartConnect when processing maps is a great asset to the SmartConnect community. However it can raise issues about password security.

When a script requires connection to a database, and other users have access to the map setup screen, it is a simple exercise to open the map, open the script and read the database login details from the script window.

An additional issue is what happens if the database credentials change, and I need to update the script? You would need to remember everywhere you used those credentials in a script, then find and update the script. You have probably thought that surely there is a better way to both manage connection credentials, and hide restricted information?

Well now there is.

As of SmartConnect 20.11.11.50 (20.11.10.50 for those connecting to GP 10) all default connections are available for use as variables within the scripting windows. What does that mean for those users maintaining and creating scripts? Well firstly it means setting up and maintaining database connection details in a single place. If the database connection required is to a MSSQL or GP database, or to an ODBC or OLEDB compliant database the connection can be setup up under default connections. (Setup / Generic Defaults / then MSSQL, ODBC or OLEDB data source defaults, or Setup / Dynamics GP Defaults / Dynamics GP Query for GP connections). These connections can then not only be used in the relevant data source windows, but can also be used in scripting.

When opening the scripting task on a SmartConnect map, there is now a Default Connections node in the tree on the left. Expanding the node will give you the different types of connections that have been defined, and expanding the type will give a list of each connection of the selected type. The connection can then be dragged into the script window and used in scripting. How is it used? Let’s look at an example.

Originally your script would look something like this:
Dim conString as String = “DataSource=MYSERVER;Initial Catalog=MYDATABASE;User=UserName;Password=UserPassword;”

The new script would look something like this:
Dim conString as String = _SQLDEF_MYDATABASE


You will have noticed that using the default connection also removes all credential information from the script. It can no longer be read directly from the scripting window. You can also use the same default connection in other scripts, but only update the single default connection if something changes. With SmartConnect, Yes you can have easy script access, with easy database connection maintenance, while still maintaining security around connection credentials.

Kevin

1 comment:

Aldus Logan said...

I am so glad to view this informative blog. Thanks for the sharing....



online business software