HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
16 Functions for access control
This chapter contains reference information on access control routines.
Table 16-1 Access control routines
DescriptionFunction
Determines if the user who is requesting the current operation has the access
rights to perform an operation on a given entry, attribute, or value.
“slapi_access_allowed()”
Determines if a user has the rights to perform the specified modifications on
an entry.
“slapi_acl_check_mods()”
Determines whether the access control items (ACIs) on an entry are valid.“slapi_acl_verify_aci_syntax()”
16.1 slapi_access_allowed()
Description Call this function to determine if a user has access rights to a specified entry,
attribute, or value. The function performs this check for users who request the operation that
invokes this plug-in.
For example, suppose you are writing a preoperation plug-in for the add operation. You can call
this function to determine if users have the proper access rights before they can add an entry to
the directory.
As part of the process of determining if the user has access rights, the function does the following:
Checks to see if the user requesting the operation is the root DN.
If so, the function returns LDAP_SUCCESS. (The root DN has permission to perform any operation.)
Gets information about the operation being requested, the connection to the client, and the
back end database where directory information is stored.
If for some reason the function cannot determine which operation is being requested,
the function returns LDAP_OPERATIONS_ERROR.
If no connection to a client exists (in other words, if the request for the operation was
made by the server or its back end), the function returns LDAP_SUCCESS. (The server
and its back end are not restricted by access control lists.)
If the back end database is read-only and the request is checking for write access
(SLAPI_ACL_WRITE), the function returns LDAP_UNWILLING_TO_PERFORM.
Determines if the user requesting the operation is attempting to modify his or her own entry.
ACLs can be set up to allow users the rights to modify their own entries. The
“slapi_access_allowed()” function checks for this condition.
The caller must ensure that the back end specified in the pblock is set prior to calling this
function. For example:
be = slapi_be_select( slapi_entry_get_sdn_const( seObjectEntry ));
if ( NULL == be ) {
cleanup("back end selection failed for entry: \"%s\"\n",
szObjectDN);
slapi_send_ldap_result( pb, LDAP_NO_SUCH_OBJECT, NULL,
" Object could not be found", 0, NULL );
return( SLAPI_PLUGIN_EXTENDED_SENT_RESULT );
} slapi_pblock_set( pb, SLAPI_BACKEND, be );
nAccessResult = slapi_access_allowed( pb, seObjectEntry, "*", bval,
SLAPI_ACL_DELETE);
Determines if a user (who is requesting the current operation) has the access rights to perform
an operation on a given entry, attribute, or value.
Syntax
16.1 slapi_access_allowed() 155