CB Linked Server for Enterprise Applications Document History Version Date Author Changes 1.0 24 Mar 2016 Sherif Kenawy Creation 2.0 29 Mar 2016 Sherif Kenawy Modified Introduction & conclusion 2.1 29 Mar 2016 Michal Hainc Review Summary [The benefits of connecting ConnectBridge to Microsoft SQL Server via Linked Servers feature with an easy to follow tutorials on how to achieve that] All rights reserved. No part of the document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the written permission of Connecting Software s.r.o. & Co. KG. Company or product names mentioned in this document may be trademarks or registered trademarks of their respective companies.
Table of Contents 1. Introduction... 3 1.1 Why should you read this article?... 3 1.2 What are we trying to achieve here?... 3 1.3 Why should you do that?... 3 1.4 What are your current available options? Why Not?... 3 1.5 So what are we proposing?... 3 1.6 Why this is the right solution?... 4 2. ConnectBridge... 4 2.1. What is ConnectBridge?... 4 2.2. How does ConnectBridge look like?... 4 2.3. Why Should you use ConnectBridge?... 5 2.4. More on ConnectBridge... 5 3. Configure ConnectBridge to connect to the required Platform... 5 3.1. ConnectBridge Terminologies:... 5 3.2. Steps to configure CB to connect the required platform:... 6 4. Microsoft SQL Server... 6 4.1. MS SQL Server & its Management Studio... 6 4.2. MS SQL Server Query Analyzer... 6 4.3. MS SQL Server Linked Servers... 7 5. Configure MS SQL Server to Connect to External Data-source(s)... 7 6. Link MS SQL Server to ConnectBridge... 10 6.1. What we understood so far?... 10 6.2. What s Next?... 10 6.3. Why will we connect CB & MS SQL Server?... 10 6.4. Steps to link MS SQL Server to CB via Linked Server & CB Accounts... 10 7. Conclusion:... 15 24 Mar 2016 Page 2/16
1. Introduction 1.1 Why should you read this article? No matter how big or small your company is, this article is valuable to you, if your company s enterprise application is connected to Microsoft SQL Server database for its day to day operation while in the same time your company is using or willing to use different business platforms & workflows like CRM, SharePoint, Exchange, Dropbox and so on. 1.2 What are we trying to achieve here? In few words, we are trying to create a centralized data source to integrate & synchronize between the local company database and the business platforms we mentioned earlier. 1.3 Why should you do that? There are so many advantages, due to the fact that you will have a centralized database/datasource, you are enabling your company s enterprise application to access all data from all company s branches and departments so you or person in charge - can track what is happening? when it s happening? and where it s happening? You are able to see a complete picture no matter how complex is your operations and regardless of how many business platforms your company is using or going to use in the future. 1.4 What are your current available options? Why Not? 1. Modify the source code of company s application to access those platforms. Why not? a. You can t access/modify the source code of your company s enterprise application b. You don t have enough resources to modify the source code of your company s enterprise application c. Your company s enterprise application is developed using outdated technology/programming language it can happen and you are not willing to upgrade it at the moment and it s expensive to outsource a developer experienced in that outdated technology d. Your company s enterprise application is stable and working without errors and you don t want to risk modifying it 2. Develop a software/tool that gets data from those business platforms and writes them to the company s database. Why not? a. Such an application will be expensive and time consuming b. Such an application could have errors or bugs or even wrong logic that could render your database and data inconstant which could be really costly c. This application will be based on a certain platform, let s say SharePoint2010, now imagine, that your company would like to upgrade to SharePoint2013 or even worse discard SharePoint and use CRM. What will happen? Of course now that software/tool will become useless, and your company will have to develop a new one d. Imagine that your company is using more than one business platform 1.5 So what are we proposing? We are proposing a solution that reduces risks & costs and increases productivity, a solution that doesn t involve modifying the company s enterprise application or developing a new 24 Mar 2016 Page 3/16
tool/software, in fact the solution doesn t involve writing a single line of code. That solution will depend on 2 main technologies ConnectBridge & MS SQL Server Linked Server. 1.6 Why this is the right solution? 1. As we said, no external tool/software will be needed 2. No modification to the source code of the company s application is needed 3. No need to hire a software developer, not a single line of code would need to be written. 4. No need to study any platform APIs/Functions or hire a platform integration specialist 5. Solution is based on SQL statements & Stored Procedures utilizing the true power of SQL. Yes! You are going to interact with those platforms using SQL Statements and still without accessing the database of those platforms. 6. There is also a possibility to work with SSIS (SQL Server Integration Services) easily. 7. The entire solution is maintained in Microsoft SQL Server Database 8. The DB administrator/consultant currently in charge of the company s database is capable enough to work with this solution 9. The integration/synchronization between those platforms and the local company database could be done periodically using MS SQL Server Scheduled Job & database triggers Now, let s see how we are going to deliver what we promised. 2. ConnectBridge 2.1. What is ConnectBridge? ConnectBridge is an integration/middleware tool based on a brilliant concept that allows the interaction with many platforms (SharePoint, CRM, Exchange ) using simple and easy to understand SQL Statements and SQL Stored Procedures without actually accessing the backend/database of those platforms. 2.2. How does ConnectBridge look like? Imagine ConnectBridge as a box which takes from you SQL statements, converts/translates them to code let s say C# - then it makes function calls to any platform you want for example SharePoint. SharePoint reacts, do some tasks, sends data/result/status message back to ConnectBridge. ConnectBridge then gets the data back from that platform and gives it back to you visualized as grid if possible. Notice! ConnectBridge won t access the database of SharePoint at all, there is no interaction whatsoever between ConnectBridge and the database of SharePoint or any other platform for that matter. Check Figure 1 MS SQL Server with ConnectBridgebelow. 24 Mar 2016 Page 4/16
Figure 1 MS SQL Server with ConnectBridge 2.3. Why Should you use ConnectBridge? Simple because we make life easier for you. We simplified things, by allowing you to type SQL statements that you already know. You don t have to study the APIs/Functions of SharePoint to insert a contact to SharePoint. 2.4. More on ConnectBridge Please refer to our ConnectBridge documentations. 3. Configure ConnectBridge to connect to the required Platform In this section, we are going to use certain ConnectBridge terminologies. Although I am going to explain them briefly, it s definitely better to read our ConnectBridge Quick-Reference first so we could be on the same page. Please refer to our ConnectBridge documentation. 3.1. ConnectBridge Terminologies: Here we are the most common terminologies we are going to use in this document which are related to ConnectBridge: 1. CB: CB is an abbreviation for ConnectBridge 2. CB Connector: CB Connector is basically a DLL file. This connector will be used by ConnectBridge to connect to the required platform. You have a connector for each supported platform. 3. CB Account: as we said a connector allows CB to connect to the required platform, but as you know, to be able to actually use the connector to connect to the required platform, you have to configure it by providing username, password and so on. Now this configured connector is what we call CB Account. So if we configured a connector to connect to SharePoint, we have an account called ACCOUNT_SHAREPOINT. Notice! We could have more than one account configured to use SharePoint, for example, in case we have multiple user access details to SharePoint. 4. CB Group: okay so now CB has a CB Account which is configured to connect to a particular platform, but who is authorized to use that CB Account? CB Group is part of the answer to this question. We create a CB Group for example GROUP_SHAREPOINT who is authorized to access SharePoint. 5. CB User: Great! From the previous step, we have a group of users who are able to connect to SharePoint using CB, but in fact there are no users in that group yet we just created a group, but it still empty! - so let s create those users to fill that group. Here we are going to create CB User by giving him a full name, login and password - 24 Mar 2016 Page 5/16
let s say (Mr. Martin Tomlinson) with login (mto) and password (****) - and of course assign him to the group we created in the previous step - GROUP_ SHAREPOINT. 6. CB Administration Tool: So if you followed the logic in steps 2 5, you should have now a user (mto) who is a member of group (GROUP_SHAREPOINT) who are authorized to connect to SharePoint via the account (ACCOUNT_SHAREPOINT). Now you might ask, where I am going to do all those steps? The answer is CB Administration Tool. What s that? It is a tool created by us to configure CB to connect to the required platform(s) and decide who which user can connect to what which platform using ConnectBridge. 7. CB Query Analyzer: okay great, now the ultimate question, how can Martin start accessing SharePoint via ConnectBridge? Where is he going to use his login and password to interact with SharePoint? Good question! Using another tool, we created for any CB User. This tool is called CB Query Analyzer. 8. CB Connection String: okay now Martin logged to CB Query Analyzer, but there is nothing there to access SharePoint as we promised him, why? That s okay! It s because Martin needs to do one more step before he can access SharePoint, basically he needs to add a connection to SharePoint, how will he do that? he will have to provide his username and password and that account we created earlier. Once he does that, a connection will be created for SharePoint, this connection is basically a line of text/string with some info required to connect to SharePoint, that s why it s called Connection- String or CB Connection String. 3.2. Steps to configure CB to connect the required platform: What we need to do here is to load 2 connectors, one connector for CRM and another one for SharePoint, configure them by creating an account for each, create a group for each account, and finally create a single user and assign those two groups to that user and get the connection string for each platform. No worries, we are here to help, to achieve that, please Follow the steps in our (CB Quick- Reference). I already followed those steps and I have those Connection Strings to 2 platforms: CRM Connection: Driver={Media Gateway ODBC Driver};IMPL=CORBA;HOST='localhost';PORT='8087';ACC='ACCOUNT_CRM'; UID='mto';PWD='*****' SharePoint Connection: Driver={Media Gateway ODBC Driver};IMPL=CORBA;HOST='localhost';PORT='8087';ACC='ACCOUNT_SHAREPOINT'; UID='mto';PWD='*****' 4. Microsoft SQL Server 4.1. MS SQL Server & its Management Studio Of course we all know that Microsoft SQL Server is a very powerful relational database management system - RDBMS. MS SQL Server is having a graphical user interface GUI that allows us to right click and choose menu options New Table, Properties to work with our database, this GUI is called MS SQL Server Management Studio. You might have noticed that it s called MS SQL Server, why? because this software MS SQL will be installed on the machine as a Server which is basically a software that is able to get requests and 24 Mar 2016 Page 6/16
send responses. For example, you are going to ask MS SQL Server to give you list of Contacts stored in table Contacts in a database called MyCompanyDB. That requires MS SQL Server to be able to listen to you, accept request from you, do the job and send you back the result. Using MS SQL Server, we are able to create databases and perform Create, Read, Update and Delete - CRUD - operations on the tables inside our databases. 4.2. MS SQL Server Query Analyzer If you have a solid knowledge of SQL statements and prefer to write queries code to perform your CRUD queries, then MS SQL Server Query Analyzer is the perfect tool for you. Using that tool, you can write queries to do anything you want to achieve we are actually going to use it in this document. You can access any database you want, access any table you want and get any information you want, you can even access more than one database at the same time in the same statement but those databases obviously need to be on the same MS SQL Server. Great, but what if from my MS SQL Server s Query Analyzer, I want to access a database which is not in my MS SQL Server?! Is it Possible?! Yes! This is where MS SQL Server Linked Servers comes to rescue! 4.3. MS SQL Server Linked Servers So as we understood using this feature MS SQL Server Linked Servers we are able to connect our MS SQL Server to external data sources, so that from within our Server we are able to perform CRUD operations on external data sources. How? let s see next. 5. Configure MS SQL Server to Connect to External Data-source(s) 5.1. Start Microsoft SQL Server Management Studio and login using either windows authentication or username and password as shown below in Figure 2: MS SQL Server Management Studio Login Screen Figure 2: MS SQL Server Management Studio Login Screen 24 Mar 2016 Page 7/16
Figure 3: MSDASQL Properties 5.2. Navigate to Sever Objects -> Linked Servers -> Providers -> MSDASQL by expanding the corresponding nodes as shown above in (Figure 3: MSDASQL Properties). Right click on MSDASQL Microsoft Data Access SQL and select Properties to show the dialog in (Figure 4: MSDASQL Properties Settings) Figure 4: MSDASQL Properties Settings 5.3. We have to ensure that the following settings/options are checked: 5.3.1. Level zero only: For security reasons we have to ensure that only OLE DB providers that are compliant with level 0 OLE DB interface are supported. 5.3.2. Allow inprocess: to allow the data provider(s) external data sources to be instantiated as an in-process server in the same process as MS SQL Server. We need to do that to avoid passing authentication information between MS SQL Server and the Provider and to be able to work with datatypes like (varchar(max), nvarchar(max), varbinary(max), text, ntext, or image). Without enabling this option, we won t be able get a data of type image from SharePoint - for example - and insert it in our MS SQL Server Database. 24 Mar 2016 Page 8/16
5.4. Now we need to enable MS SQL Server to connect to external providers and execute queries to query data from external providers that use OLEDB let s call them External OLEDB Data Sources. We will do that in 3 steps: 5.4.1. We need to open a new Query window by clicking the New Query button as shown in Figure 5: MS SQL Server Query Analyzer below. It doesn t matter which database is active, because what we are going to do is going to affect the entire MS SQL Server installation and in turn each and every database in there. As show below I have master as the active/target database Figure 5: MS SQL Server Query Analyzer 5.4.2. We need to reconfigure MS SQL Server so that we can change/configure its advanced options. To do that we are going to execute a stored procedure called sp_configure it s a preinstalled system stored procedure - and we are going to specifically show advanced options by setting this option to 1. To do that we type the following stored procedure and press F5 to execute it. If everything goes right, you should get a message similar to the message in Figure 6: MS SQL Server - Showing Advanced Options below Figure 6: MS SQL Server - Showing Advanced Options 5.4.3. Now we need to allow MS SQL Server to query those External OLEDB Data Sources using something called Ad Hoc Distributed Queries. By default, MS SQL Server doesn t allow the Ad Hoc Distributed Queries therefore we need to reconfigure this advanced option that s why we did the previous step by executing the stored procedure sp_configure passing the setting Ad Hoc Distributed Queries and the value 1 to enable it. If everything goes right, you should get a message similar to the message in Figure 7: MS SQL Server - Enabling Ad Hoc Distributed Queries below 24 Mar 2016 Page 9/16
Figure 7: MS SQL Server - Enabling Ad Hoc Distributed Queries 6. Link MS SQL Server to ConnectBridge 6.1. What we understood so far? Okay by now we understood the following: 6.1.1. CB is a powerful tool that can connect to many platforms using APIs (function calls) while allowing you to interact with it using simple SQL Statements. 6.1.2. CB is using CB Account to connect to the required platform(s). 6.1.3. We already loaded 2 connectors, configured them as 2 accounts CRM & SharePoint, we got the connection string for each one of them; 6.1.4. We have a user called Martin with login mto who is authorized to use those 2 accounts. 6.1.5. We can login to MS SQL Server using windows authentication or using some username and password (we used sa ) 6.2. What s Next? Now we want to Connect MS SQL Server to ConnectBridge using the Linked Servers feature. Basically we are going to create 2 Linked Server, one Linked Server for CRM and the second one for SharePoint. 6.3. Why will we connect CB & MS SQL Server? Because of the goal we set at the beginning, remember? Accessing SharePoint without studying SharePoint - using SQL statements but without accessing the database of SharePoint. Great! Let s see how to do that! 6.4. Steps to link MS SQL Server to CB via Linked Server & CB Accounts 6.4.1. Login to MS SQL Server, on the left side, navigate to Sever Objects -> Linked Servers. Right click on Linked Servers and choose New Linked Server as shown in the Figure 8: MS SQL Server - Adding New Linked Server below 24 Mar 2016 Page 10/16
Figure 8: MS SQL Server - Adding New Linked Server 6.4.2. In the new Linked Server dialog, type in the required settings as shown in Figure 9: MS SQL Server - Configuring New Linked Server - General below. You will notice that we choose Microsoft OLE DB Providers for ODBC Drivers that s because ConnectBridge is relying on OLE DB and ODBC. Please don t close this dialog yet! Figure 9: MS SQL Server - Configuring New Linked Server - General 6.4.3. Now we need to establish a relationship between the user using/accessing MS SQL Server and the user using/accessing CB. The user using MS SQL Server is called Local Login (in our scenario it s sa ) and the user using/accessing CB is called Remote User (in our scenario it s Martin with login mto). This is what we have to configure, and to do 24 Mar 2016 Page 11/16
that we click security tab to show the dialog in Figure 10: MS SQL Server - Configuring New Linked Server - Security below: Figure 10: MS SQL Server - Configuring New Linked Server - Security 6.4.4. When the above dialog is displayed, we click the Add button and we type in the Local Login and the Remote User as we agreed. That s what I did here in Figure 11: MS SQL Server - Configuring New Linked Server - Logins Figure 11: MS SQL Server - Configuring New Linked Server - Logins 24 Mar 2016 Page 12/16
6.4.5. Okay I know you want to close the dialog but wait, we need to do one more step. Now we need to go to Server Options tab on the left hand side to show the dialog in Figure 12: MS SQL Server - Configuring New Linked Server - Server Options below and enable 2 features: 6.4.5.1. RPC: to enable a certain security feature which we would need when we use some legacy feature called Remote Server don t worry about it now so that login validation between CB and MS SQL Server is possible. 6.4.5.2. RPC Out: to enable Remote Procedure Call feature, as we need to allow our stored procedures to be able to run remotely Figure 12: MS SQL Server - Configuring New Linked Server - Server Options 6.4.6. Now we click okay and we are done! Yes! We configured MS SQL Server to connect to SharePoint. Now we can see SharePoint platform as a database in MS SQL Server, we can see table called Contacts, we can show a list of contacts from SharePoint, all this, without accessing SharePoint database as you could see in Figure 13: MS SQL Server - Linked Server Configured Successfully below 24 Mar 2016 Page 13/16
Figure 13: MS SQL Server - Linked Server Configured Successfully 6.4.7. Now, I am going to try to show all contacts on SharePoint, by writing the SQL Statement SELECT * FROM SHAREPOINT Contacts;. Why the? because it follows the syntax server.database.schema.table and as you could see from Figure 13: MS SQL Server - Linked Server Configured Successfully above, our Server is SHAREPOINT, our database is without name our schema is without name and finally our table is Contacts. Okay let s try it out: Figure 14: MS SQL Server - Querying The Linked Server 6.4.8. As you can see in Figure 15: Confirming the results of the Linked Server Query below, this is what I actually have online on SharePoint as well. Notice! The result of executing this 24 Mar 2016 Page 14/16
statement will be different as it depends on what is being stored in your SharePoint account. Figure 15: Confirming the results of the Linked Server Query 6.4.9. I am sure you can add CRM as Linked Server to MS SQL Server on your own, you just need to repeat the same steps from 6.4.1 to 6.4.9 but of course using CRM Connecting String. You should have something similar to Figure 16: MS SQL Server - The 2nd Linked Server Configured Successfully below by the time you finish. You will notice difference in column names of course. Notice! The result of executing this statement will be different as it depends on what is being stored in your CRM account. Figure 16: MS SQL Server - The 2nd Linked Server Configured Successfully 24 Mar 2016 Page 15/16
7. Conclusion: We used 2 main technologies ConnectBridge and Microsoft SQL Server Linked Server to create an optimal solution maintained in SQL Server and based on SQL statements & stored procedures. Solution that allowed us to synchronize between multiple business platforms and our local MS SQL Server, giving us the advantage of a centralized data storage location, regardless of the platforms used and without writing a single line of code. Solution that s able to access those platforms using SQL statements but still without accessing the back end of those platforms which saves us the time, effort and money to study those platforms, makes us independent on how many or which platforms the company is using or going to use and finally allows our DB administrator to utilize his SQL knowledge to quickly use the solution to automate the synchronization process. Solution that can dramatically decrease costs and risks and increase productivity. 24 Mar 2016 Page 16/16