Using sybmapname to handle user principal names

sybmapname converts external user principal names used in the Kerberos environment to the namespace of Adaptive Server user logins. You can customize the sybmapname shared object and map names specified in the Kerberos input buffer to names suitable for a login to the Adaptive Server output buffer.

Use the 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.

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

where:

syb__map_name returns a value greater than 0 if the mapping succeeds, or 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, reporting the mapping failure is written to the Adaptive Server error log.

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

  1. Configure Adaptive Server to use the Kerberos security mechanism. See “Using Kerberos” 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. See “Precautions when using sybmapname”.

  3. Build the shared object or DLL using the generic platform-specific makefile supplied. You may need to modify the makefile 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 6

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

Example 7

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 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), which is a encrypted file that provides identification:

$ /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, 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

When coding for sybmapname: