Sample user mapping plug-in (C programming language)

Review the sample source code to learn how to develop a plug-in that provides a C interface to an external user mapping repository.

This sample user mapping plug-in uses a file as the external repository. The sample source files are automatically installed on your system. Where they are installed depends on the operating system that you use:
  • On Windows, %DB2PATH%\samples\federated\umplugin\file, where %DB2PATH%is the directory where the Db2® database system is installed
  • On Linux® and UNIX, inst_home/sqllib/samples/federated/umplugin/file, where inst_home is the instance home directory
The sample includes these files:
fsumplugin_file.h
The header file that contains data structures and function definitions for the sample plug-in.
fsumplugin_file.c
The source code for the sample plug-in, which uses a file as the external repository.
fsumplugin_file.txt
A file that contains sample user mapping entries that are in plain text.
fsumlookup
A stand-alone program that tests the sample plug-in outside of the federated server environment. On Microsoft Windows, the file is fsumlookup.exe.
fsumsetup_file
A stand-alone program that sets the full path and file name of the file that stores the user mappings. On Microsoft Windows, the file is fsumsetup_file.exe
bldplugin
The build script that compiles and links the plug-in. On Microsoft Windows, the file is bldplugin.bat.
README
A file that contains instructions for compiling, building, testing, and deploying the sample plug-in.

In the file fsumplugin_file.txt, each user mapping entry occupies one line, and the passwords are encrypted by simply reversing the bytes. This is a very simple encryption method. If you modify the sample plug-in for use in a production environment, you must use an encryption method that meets the security requirements of the environment.

The following syntax shows the format for a sample user mapping entry.
Note: Although the code displays on multiple lines here, you must enter all of this code on one line in your application. Note that a semicolon separates the parts of the user mapping and that a colon separates the REMOTE_AUTHID and REMOTE_PASSWORD option names from their corresponding settings.
fsInstance;fsDatabase;fsRemoteServer;
fsAuthid;REMOTE_AUTHID:remote_authID;
REMOTE_PASSWORD:remote_password
For example:
DB2INST1;TESTDB;MSSQL2K;ALICE;REMOTE_AUTHID:TESTUSR1;REMOTE_PASSWORD:drowssap