SQL vs. ISAM User Authentication
Many new c-treeSQL Server administrators are confronted with the necessity of adding users. A common question we are asked at FairCom is “How do I create a new user for the c-treeSQL Server?” Fortunately, the c-treeSQL Server behaves exactly as our proven and highly successful standard c-tree Server. SQL only adds an additional interface into the proven core c-tree database technology. Once you understand the basics of user administration for one solution, you know both!
A user can connect to the c-treeSQL Server and c-tree Server utilizing any of the numerous interfaces provided. The c-treeSQL Server simply adds additional functionality to the proven c-tree Server, but shares the same user list and authentication systems. They are one and the same as far as connections are concerned.
A user with a password is defined server-wide with no dependency on the interface used to connect or, in the case of SQL, the database. Thus, for a successful SQL connection, the user must be recognized just as they would be by the c-tree Server. At first, this might throw off a SQL administrator, as users may not be recognized by the c-treeSQL Server. This is easy to rectify once the administrator adds the user in a manner the server traditionally expects.
There are several options available to create a c-treeSQL Server user, and they are divided into two categories here:
1. Command Line Utilities
ctadmn
ctadmn is a command line utility providing an easy to use menu-driven system to control and monitor your c-tree Server. Adding a user is easy with ctadmn as shown here:
- From the command line, run ctadmn and connect to the server:
> ctadmn –u ADMIN –a ADMIN servername@hostname
- From the menu, select option 1: User Operations.
- From the next menu, again select option 1: Add Users.
- Follow the remaining prompts to provide details about your new user.
- Press ‘q’ to exit any menu, or to exit the ctadmn utility.
A complete description of ctadmn can be found in the c-tree Server Administrator’s Guide.
sa_admin
sa_admin is a powerful utility for manipulating user and group information. Designed for use with common administrator scripts, sa_admin provides a flexible interface to quickly add, change and delete user and group parameters. To add a user to the server, enter a command line entry such as the following:
> sa_admin –aADMIN –pADMIN –sSERVERNAME@HOSTNAME –oua newuser newpass
There are numerous command line options available for this powerful utility. A complete description of all the available options can be found in the c-tree Server Administrator’s Guide.
2. The SA Programmatic Interface
c-tree Plus gives you the ability to add, delete and modify user and group information directly from your application by providing programmatic API calls. For example, you can use the SA programmatic interface to add a user to the server as described here.
To begin, declare a variable of type saUSRINFO and set the fields as desired. The usr_id field is the only required field. Specify any of the other fields as an empty string to use the default value for that option. Call SA_USERS() with the ctuNEW action and the address of your saUSRINFO structure.
EXAMPLE
COUNT rc;
saUSRINFO usrinfo;
ctsfill(&usrinfo, 0, sizeof(saUSRINFO));
strcpy(usrinfo.usr_id, "QATEST");
strcpy(usrinfo.usr_desc, "QA test account");
strcpy(usrinfo.usr_pass, "qat$145");
strcpy(usrinfo.usr_group, "QA");
strcpy(usrinfo.usr_memory, "100000");
strcpy(usrinfo.usr_memrule, "D");
strcpy(usrinfo.usr_xbegdat, "05/23/1999");
strcpy(usrinfo.usr_xenddat, "12/31/1999");
strcpy(usrinfo.usr_xlgnlmt, "3");
if ((rc = SA_USERS(ctuNEW, &usrinfo)) != 0)
printf("Add user failed with error %d (%d).
", rc, isam_err);
else
printf("Successfully added user.
");
The SA Programmatic Interface is a very powerful and flexible API, giving the developer complete control over the c-tree Server. The combination of SA_USERS(), SA_GROUP(), SA_FILES(), SA_LOGON(), SA_LOGOF(), and SECURITY() provide a multitude of direct programmatic calls to control the server. A complete description of this API can be found in the c-tree Plus Programmer’s Reference Guide by their respective names.
Once a user has been added to the c-tree Server, then the SQL administrator can GRANT privileges as expected.
|