Previous Topic: authxapi_IsThereExitFunction FunctionNext Topic: authxapi_GetObjectListValue Function


authxapi_GetObjectProperty Function

Valid on UNIX

The authxapi_GetObjectProperty function retrieves the value of a single‑value property of an object stored in the database. Properties that have multiple values, such as lists, cannot be retrieved with this function. You retrieve property lists with the authxapi_GetObjectListValue function. All parameter strings must be NULL terminated.

If the function succeeds, it returns 0. If it fails, it sets the global variable errno and returns one of the following error codes:

Return Value

ERRNO

Meaning

AUTHXAPI_E_EINVAL

EINVAL

Invalid (NULL) pointers

AUTHXAPI_E_INVOBJ

EINVAL

Invalid object descriptor

AUTHXAPI_E_INVPROP

EINVAL

Invalid property descriptor

AUTHXAPI_E_NOCLASS

ENOENT

Required class not found

AUTHXAPI_E_NOOBJ

ENOENT

Required object not found

AUTHXAPI_E_NOPROP

ENOENT

Required property not found

AUTHXAPI_E_PTYPE

EINVAL

Property type is a list

AUTHXAPI_E_DBERROR

EIO

Suspect corruption of database

AUTHXAPI_E_NOVAL

ENOENT

No value for property associated with this object

int authxapi_GetObjectProperty (const char  *szClass,
                                const char  *szObj,
                                SEOSDB_ODF  *p_odf,
                                const char  *sz_Prop,
                                SEOSDB_PDF  *p_pdf,
                                void        *val,
                                int         *size);
szClass

The name of the class to which the resource belongs.

szObj

The name of the object (record) whose property value you want to retrieve.

p_odf

Points to an object descriptor fetched by this function or provided by the caller from a previous call to an Exits API get function.

szProp

The name of the property whose value you want to retrieve.

p_pdf

A pointer to a property descriptor fetched by this function or provided by the caller from a previous call to an Exits API get function.

val

A pointer to a variable that is filled with the value of the property. The caller should provide a pointer to a variable that is of the same type as the property's data type.

size

A pointer to the size, in bytes, of the region in memory to which the val parameter is pointing.

Example: Fetching a Value from the Database.

This example, part of an exit function for a general resource, retrieves a value stored in the database. The exit function checks that the request is for the correct resource class. Other classes are ignored. The authxapi_GetObjectProperty function is called to retrieve the value for the COMMENT property. If the retrieval was successful, the function tests if the string contains the substring “ NO ” (note the spaces before and after the word). If so, the request is denied. Otherwise the function returns control to CA ControlMinder to perform its standard checks.

#include stdio.h
#include authxapi.h
#include seostype.h

int MyExitFunction(void *exit_data, SEOS_EXITRES *result)
{
    SEOS_EXITGENR *genr_data;
    SEOSDB_ODF odf;
    SEOSDB_PDF pdf;
    SEOS_COMMENT comment;
    int rc;

    genr_data = (SEOS_EXITGENR *)exit_data;
    /* Ignore any class that is not of interest */
    if (strcmp(genr_data‑>szClass, “MyClass”))
        return 0;

    /* Fetch the information for the COMMENT property of the */
    /* resource to which access is verified. */
    rc = authxapi_GetObjectProperty(“MyClass”, genr_data‑>szRes,
               &odf, “COMMENT”, &pdf, comment, sizeof(comment));

    if (rc == 0)
    {
        /* We have now the comment string. Does it contain “NO”?*/
        if (strstr(comment, “ NO “) != NULL)
        {
            result‑>result = SEOS_EXITR_DENY;
        }
    }
    return 0;
}

Note: To update the COMMENT field from the selang command interpreter, you should use the comment argument. For example:

newres MyClass anobject \
comment('This object has “ NO “ in the comment property')