Using sybmapname to handle user principal names

sybmapname converts external user principal names used in Kerberos environment to the namespace of Adaptive Server user logins. sybmapname is a customizable shared object that can map names given on its input buffer to a name suitable for Adaptive Server login on its output buffer.

You can use sybmapname shared object to perform the custom mapping between the user principal name and the Adaptive Server login name. This shared object is optionally loaded at server start-up, and the function syb__map_name contained in the shared object is called after a successful Kerberos authentication and just before the user principal is mapped to a login in the syslogins table. This function is useful when the user principal name and the login name to be mapped are not identical.

The customizable logic is the function:

syb__map_name(NAMEMAPTYPE *protocol, char *orig, 
int origlen, char *mapped, int *mappedlen)

Where:

The function returns a value greater than 0 if the mapping succeeds, it returns a value of 0 if no mapping occurred, and it returns a value less than 0 when an error occurs in syb__map_name(). When an error occurs, a message displays in the Adaptive Server error log to report the mapping failure.

For example, to authenticate a Kerberos user on Adaptive Server:

  1. Configure Adaptive Server to use the Kerberos security mechanism. See the Adaptive Server System Administration Guide and Open Client/Server documentation, and the white paper titled “Configuring Kerberos for Sybase” on the Sybase Web site.

    A sample sybmapname.c file is located in $SYBASE/$SYBASE_ASE/sample/server/sybmapname.c.

  2. Modify sybmapname.c to implement your logic. Take precautions while coding as it may interfere with the proper running of Adaptive Server. See “Precautions when using sybmapname”.

  3. Build the shared object or DLL using the generic platform specific makefile supplied. The makefile may need to be modified to suit your platform specific settings.

  4. Place the resulting shared object generated in a location specified in your $LD_LIBRARY_PATH on UNIX machines, and PATH variable on Windows machines. The file should have read and execute permissions for the sybase user.

NoteSybase recommends that only the “sybase” user is allowed read and execute permissions, and that all other access should be denied.


Verifying your login to Adaptive Server using Kerberos authentication

To verify your login to Adaptive Server using Kerberos authentication, assume that:

Example 4

Example 1 If a client’s principal name is user@REALM, and the corresponding entry in syslogins table is user_REALM, then sybmapname can be coded to accept the input string user@realm and to convert the input string to the output string user_REALM.

Example 5

Example 2 If the client principal name is user, and the corresponding entry in syslogins table is USER, then sybmapname can be coded to accept the input string user and convert this string to uppercase string USER.

sybmapname is loaded by Adaptive Server at runtime and uses its logic to do the necessary mapping.

The following actions and output further illustrate the sybmapname function described in Example 2. The sybmapname.c file containing the customized definition for syb__map_name() should be compiled and built as a shared object (or DLL), and finally placed in the appropriate path location. Start Adaptive Server with the Kerberos security mechanism enabled.

To initialize the Ticket Granted Ticket (TGT):

$ /krb5/bin/kinit johnd@public
Password for johnd@public:
$

To list the TGT:

$ /krb5/bin/klist
   Cache Type: Kerberos V5 credentials cache
   Cache Name: /krb5/tmp/cc/krb5cc_9781
Default principal: johnd@public

Log in as “sa” and verify the user login for “johnd”:

$ $SYBASE/$SYBASE_OCS/bin/isql -Usa -P 
      -Ipwd`/interfaces
1>

1> sp_displaylogin johnd
2> go
No login with the specified name exists.
(return status = 1)

1> sp_displaylogin JOHND
2> go
Suid: 4
Loginame: JOHND
Fullname:
Default Database: master
Default Language:
Auto Login Script:
Configured Authorization:
Locked: NO
Password expiration interval: 0
Password expired: NO
Minimum password length: 6
Maximum failed logins: 0
Current failed login attempts:
Authenticate with: ANY
(return status = 0)

Successful Kerberos authentication, which maps lower case johnd to uppercase JOHND using the sybmapname utility and allows user johnd to log in to Adaptive Server:

$ $SYBASE/$SYBASE_OCS/bin/isql -V -I'pwd'/interfaces
1>

Precautions when using sybmapname

Be aware of the following issues when coding for sybmapname: