01.07.2014 Views

AN-016 Protégé Server ODBC Database Connectivity

AN-016 Protégé Server ODBC Database Connectivity

AN-016 Protégé Server ODBC Database Connectivity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>AN</strong>-<strong>016</strong><br />

Protégé <strong>Server</strong><br />

<strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


PUBLICATION INFORMATION<br />

This application note covers the use of the protégé system to perform a specific function and may be used in conjunction with<br />

other publications. Specifications may change without notice, for updates visit the Integrated Control Technology website at<br />

www.integratedcontroltechnology.com. No other hardware was used to prepare this application note and will not affect the result<br />

of the application using the programming information presented.


CONTENTS<br />

Contents........................................................................ 1<br />

Protégé system ............................................................. 2<br />

Introduction ....................................................................................................................... 2<br />

Application Note Information ............................................................................................. 2<br />

Firmware Version ............................................................................................................... 2<br />

<strong>Connectivity</strong> .................................................................. 3<br />

Overview ............................................................................................................................ 3<br />

<strong>Database</strong> Block Diagram..................................................................................................... 3<br />

Enabling MSDE/SQL Network Access .................................................................................. 3<br />

<strong>Database</strong> Overview............................................................................................................. 4<br />

Making The Connection....................................................................................................... 6<br />

External User Table ..................................................... 11<br />

Introduction ..................................................................................................................... 11<br />

External User Table Structure........................................................................................... 11<br />

Example Application .................................................... 13<br />

Introduction ..................................................................................................................... 13<br />

Connecting With <strong>ODBC</strong> ..................................................................................................... 13<br />

Example MS Access Form.................................................................................................. 13<br />

Information................................................................. 14<br />

Introduction ..................................................................................................................... 14<br />

Contact ............................................................................................................................. 14<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

1


PROTÉGÉ SYSTEM<br />

Introduction<br />

The Protégé System is a powerful integrated alarm and access control management system designed<br />

to provide integration with building automation, apartment complex control and HVAC in one flexible<br />

package. Communicating through a proprietary high speed protocol across an encrypted RS-485<br />

network using modular-based hardware design, system installers have the flexibility to accommodate<br />

any installation from small or large, residential or commercial.<br />

Application Note Information<br />

Focusing on interoperability and flexible database integration the Protégé System allows Integrated<br />

Control Technology to provide access to the external global user table for programming from a remote<br />

application or database. <strong>Connectivity</strong> with remote Microsoft Access, Microsoft SQL <strong>Server</strong>, MSDE,<br />

MySQL and Oracle databases can be achieved using a simple linked table approach.<br />

Connections can also be used with any application that is able to utilise SQL and <strong>Database</strong> connections<br />

from a programming environment.<br />

The following application note describes the procedures to connect to the Protégé SQL <strong>Server</strong><br />

<strong>Database</strong> using an <strong>ODBC</strong> connection. The example details an interface in to the global external users<br />

table which automatically adds and downloads users to the Protégé System Controllers. This example<br />

uses a simple MS Access *.MDB file with a linked table. The example can be downloaded from the<br />

software download section.<br />

Firmware Version<br />

This application note does not utilise firmware from the system controller or Protégé Modules. We<br />

recommend that this application note is used in conjunction with the latest available release of the<br />

Protégé Integrated System Management Suite.<br />

2 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


CONNECTIVITY<br />

Overview<br />

This document describes the methods used to connect an external third party application or<br />

database to the Protégé System Management Suite to update and manage users within the<br />

protégé installation.<br />

Connecting to the Protégé System Management Suite using the external database and<br />

<strong>ODBC</strong> connections requires extensive knowledge of networking, database<br />

connectivity and security configuration parameters which are beyond the scope of<br />

this document.<br />

<strong>Database</strong> Block Diagram<br />

The external users table is provided to allow a remote database (student database, SAP, ERP or<br />

custom application) to connect and program users in the Protégé System.<br />

Figure 1 – Basic <strong>Database</strong> Structure<br />

Enabling MSDE/SQL Network Access<br />

Depending on the configuration of your MSDE or SQL <strong>Server</strong> <strong>Database</strong> that is installed it may<br />

not be possible to connect to the database remotely without enabled the network interface<br />

connection.<br />

The following procedure explains how to connect to the Protege Instance of the<br />

MSDE/SQL <strong>Server</strong> that is installed as part of the server installation. Other SQL <strong>Server</strong><br />

installations may require different administration requirements which are beyond the<br />

scope of this application note.<br />

1. Using the file explorer browse to the C:\Program Files\Microsoft SQL<br />

<strong>Server</strong>\80\Tools\Binn directory and execute the program SVRNETCN.EXE. Your directory<br />

may be different depending on your installation.<br />

2. Before using the application below ENSURE that you have selected the correct SQL<br />

<strong>Server</strong> Instance or configured server. Verify that the correct computer name and<br />

database are located at the top right hand side BEFORE proceeding.<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

3


3. You will be shown the screen above, as in the above screen enable the connection type<br />

that suites your environment. If you are not sure then you need to consult a network or<br />

database administrator and close this application immediately.<br />

4. In the examples contained in this application note the TCP/IP connection is used to the<br />

standard SQL <strong>Server</strong> Port 1433.<br />

5. Close the SVRNETCN.EXE application.<br />

<strong>Database</strong> Overview<br />

The ability to connect from remote applications that require user data to be updated in real<br />

time allows for many possible interfaces and configurations. In most cases the data connectivity<br />

function will allow applications such as an external photo id issuing station, employee database<br />

or custom applications to connect to the protégé system. This functionality may be used<br />

permanently or only at the initial stages of installation to get all users within a company in to<br />

the database in real time.<br />

Figure 1 - Basic <strong>Database</strong> Connection<br />

In the above example a remote database is being used to store user data, this database is<br />

connected to the protégé external user table allowing data for the access control system to be<br />

updated in real time.<br />

4 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


In most cases this is the typical use of the database connectivity, the database can be an<br />

employee or administration database maintained by a larger company wide application and<br />

example of this is SAP, PeopleSoft, DataCard Image Works or similar Photo ID, Company or<br />

employee management applications.<br />

For an example of a connection using <strong>ODBC</strong> and Microsoft Access complete with example forms<br />

and reports refer to the Example Application Section on Page 13.<br />

Figure 2 - Advanced <strong>Database</strong> Connection<br />

In the above example a remote application is being used for Photo-ID and is using data from<br />

the remote database to attach additional user information (Photo, Issue Number). This<br />

database then uses a trigger or internal update method to send the information to the Protégé<br />

System when the data changes.<br />

The example is further complicated by the external database being modified and maintained by<br />

a distributed data entry application used for the initial entry and data processing portion of the<br />

users being added to the system.<br />

It is important to note that in the advanced connection the remote database is the primary<br />

database and the Protégé System external user table is a secondary portion being updated<br />

from data within the remote database.<br />

To import users into the Protégé System Management Suite from an external file use<br />

the Import User wizard available from the File Menu in the Protégé System<br />

Management Application. Many formats are already included and user definable<br />

formats available, for more information consult the Protégé System Management<br />

Suite Help File.<br />

To import users from an existing database use an appropriate update query or code<br />

to write the users in to the External <strong>Database</strong> Table. This will mean the protégé<br />

system controllers will be updated at the same time. It is recommended to batch load<br />

users in smaller groups.<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

5


Making The Connection<br />

Making the connection to the protégé server is done by a <strong>ODBC</strong> link. The following example<br />

shows how to link a table in Microsoft Access using <strong>ODBC</strong> and the Protégé System Management<br />

Suite.<br />

1. Open MS Access and create a test database, this is typically DB1.MDB, in our example<br />

we have used the name ProtégéExternalUsers.MDB<br />

2. As shown in the above example right click in the table window and select the Link Tables<br />

option from the context menu.<br />

3. When prompted for the filename scroll the file types and select the <strong>ODBC</strong> <strong>Database</strong>()<br />

option which will be located towards the end of the available entries.<br />

6 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


4. From the select data source screen select the button new located to the right of the DSN<br />

Name text box. You will now be presented with the data source type selection.<br />

5. Select SQL <strong>Server</strong> and then select the next button to proceed with the data source<br />

configuration. You will now be prompted to give the connection you are creating a name,<br />

this allows the information relating to this connection to be stored so that it can be used<br />

when you link other tables or information. In our example we have given it the name<br />

ProtégéExternalUsers which clearly describes the use of this DSN file. Select the next<br />

button and then select finish.<br />

6. When you have the create new data source to SQL server dialog box presented to you,<br />

select the Protégé SQL <strong>Server</strong> Instance from the drop down selection.<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

7


7. When you have the create new data source to SQL server dialog box presented to you,<br />

select the Protégé SQL <strong>Server</strong> Instance from the drop down selection. If the instance is<br />

not presented in the drop down list type in the name of the computer as shown above<br />

(PCNAME) followed by a backwards slash and PROTEGE in capitals. Select the next<br />

button to move to the next step.<br />

8. You will now be presented with the Login ID and Password, the default logon ID and<br />

Password is ‘ProtegeEx’ for the User and ‘ProtegeEx’ for the password, please note the<br />

password is case sensitive. Select the next button to proceed.<br />

8 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


9. Once the SQL <strong>Database</strong> is found and the user information verified the above screen will<br />

be presented to you. Select the default database as Protege and then select the next<br />

button to proceed.<br />

10. The next screen of the process does not get altered and you should select the finish<br />

button to complete the creation of the connection.<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

9


11. Once the connection has been completed you can test the connection by selecting the<br />

test data source button.<br />

Once the connection has been made the table will be shown as a linked table in the Microsoft<br />

database that you have created. For information on the Sample <strong>Database</strong> refer to the section<br />

Example Application on Page 13.<br />

10 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


EXTERNAL USER TABLE<br />

Introduction<br />

The external user table is used by the remote application to write, modify and read the current<br />

users. This table is used by the protégé application to activate internal triggers to update the<br />

appropriate user within the protégé system.<br />

This method protects the system from vulnerability by only allowing access to the database for<br />

the specific purpose that is required. This is further enhanced with a password and login name<br />

to be entered to gain access.<br />

The login and password default to the login id "ProtegeEx" and the password "ProtegeEx".<br />

The defaults are stored in the protégé administration settings and it is recommended that these<br />

be changed before any connections are made to ensure a high level of security.<br />

External User Table Structure<br />

The following shows the external user table structure. The structure below is also available in<br />

the attachment with this document "exusers.sql", this SQL table details the exact statements<br />

used for creation of the table and should provide enough information for the programmer or<br />

database administrator. The individual table elements and how they relate to the internal users<br />

and local users within the protégé system are detailed in the following section.<br />

TABLE Protege.dbo.ExGlobalUsers<br />

(<br />

[ExGlobalUsersID] [int] IDENTITY(0,1),<br />

[SiteID] int NOT NULL DEFAULT 1,<br />

[GlobalUserID] [int] NOT NULL DEFAULT 0,<br />

[FirstName] nvarchar(128) DEFAULT '',<br />

[LastName] nvarchar(128) DEFAULT '',<br />

[DisplayName] nvarchar(128) NOT NULL DEFAULT '',<br />

[PinNumber] nvarchar(8) NOT NULL DEFAULT '',<br />

[FamilyNumber] int NOT NULL DEFAULT 0,<br />

[CardNumber] int NOT NULL DEFAULT 0,<br />

[GlobalAccessLevel] int NOT NULL DEFAULT 16777215,<br />

[GlobalArea] int NOT NULL DEFAULT 16777215,<br />

[ExpiryDate] datetime NOT NULL DEFAULT GETDATE(),<br />

[ExpiryTime] datetime NOT NULL DEFAULT GETDATE(),<br />

[ShowAGreetingMessageToUser] bit NOT NULL DEFAULT 1,<br />

[GoDirectlyToTheMenuOnLoginNoAreaControl] bit NOT NULL DEFAULT 0,<br />

[UserCanAcknowledgeAlarmMemory] bit NOT NULL DEFAULT 1,<br />

[ShowAlarmMemoryOnLogin] bit NOT NULL DEFAULT 0,<br />

[TurnOffThePrimaryAreaIfUserHasAccessOnLogin] bit NOT NULL DEFAULT 1,<br />

[TurnOffTheUserAreaOnLoginIfUserHasAccess] bit NOT NULL DEFAULT 1,<br />

[AcknowledgeTroubles] bit NOT NULL DEFAULT 0,<br />

[AcknowledgeSystemTroubles] bit NOT NULL DEFAULT 0,<br />

[UserIsADualCodeMaster] bit NOT NULL DEFAULT 0,<br />

[UserIsADualCodeProvider] bit NOT NULL DEFAULT 0,<br />

[UserHasSuperRightsAndCanOverrideAntipassback] bit NOT NULL DEFAULT 0,<br />

[UserCanModifyTheirOwnCode] bit NOT NULL DEFAULT 0,<br />

[UserCanModifyAnyCodeWithTheirAccessLevel] bit NOT NULL DEFAULT 0,<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

11


)<br />

[UserLoiterExpiryCountEnabled] bit NOT NULL DEFAULT 0,<br />

[UserCanLogInRemotely] bit NOT NULL DEFAULT 0,<br />

[UserIsADuressUser] bit NOT NULL DEFAULT 0,<br />

[CardMode] int NOT NULL DEFAULT 0,<br />

[DownloadType] int NOT NULL DEFAULT 0,<br />

[CreatedTime] datetime NOT NULL DEFAULT GETDATE(),<br />

[LastModifiedTime] datetime NOT NULL DEFAULT GETDATE()<br />

This structure is automatically provided to the connecting database or application when the<br />

<strong>ODBC</strong> link is made. The above and following information is provided for a reference only to the<br />

settings and default values.<br />

12 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


EXAMPLE APPLICATION<br />

Introduction<br />

The example application shows the ease at which the external user table can be connected and<br />

presented using the Microsoft Access <strong>Database</strong>. This application was chosen due to the<br />

simplicity and wide availability of the application. The example can easily be adapted to <strong>AN</strong>Y<br />

database or application.<br />

The default login "ProtegeEx" and password "ProtegeEx" have been used for this<br />

example and in the files that are supplied. This must be changed when used with a<br />

live system and data.<br />

Connecting With <strong>ODBC</strong><br />

Before the example database will operate you must create your own linked table to the Protégé<br />

SQL <strong>Server</strong> that is installed on your machine. To complete the connection follow the details in<br />

the Section Making the Connection on Page 6.<br />

Example MS Access Form<br />

The following figure shows the sample Microsoft Access Form that is provided in the sample<br />

database. The customisation of the form is very flexible and as can be seen easily extended to<br />

other applications as required.<br />

Figure 3 – Example MS Access Form<br />

<strong>AN</strong>-015 Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong><br />

13


INFORMATION<br />

Introduction<br />

Application notes are provided as is without any implied warranty or intended use and are<br />

written by Integrated Control Technology as an aid in programming and connecting devices to<br />

the Protégé System.<br />

Contact<br />

Integrated Control Technology welcomes all feedback. Please visit our website or use the<br />

information below.<br />

Integrated Control Technology<br />

P.O. Box 302-340 Unit C,<br />

North Harbour Post Centre<br />

6 Ascension Place<br />

Auckland<br />

Mairangi Bay<br />

New Zealand<br />

Auckland<br />

New Zealand<br />

Phone: +64-9-476-7124<br />

Fax: +64-9-476-7128<br />

www.integratedcontroltchnology.com<br />

14 <strong>AN</strong>-<strong>016</strong> Protégé <strong>Server</strong> <strong>ODBC</strong> <strong>Database</strong> <strong>Connectivity</strong>


Unit C, 6 Ascension Place, Mairangi Bay, P.O. Box 302-340<br />

North Harbour, Auckland, New Zealand.<br />

Phone: +64 (9) 476 7124 • Fax: +64 (9) 476 7128<br />

www.integratedcontroltechnology.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!