skip to main content
Designing and coding the IP : Privileges : Implementing DCL support
 

Implementing DCL support

The DCL function allows setting up user accounts and defining user privileges. To implement the DCL function:
1. In C/C++ register the ip_dcl() function in the dcl slot.
2. Have the IP (the ip_getSupport () routine) return TRUE for the DCL commands you wish to support. This can be done by updating the support array in the ip_drv.c file to mark support for IP_SUPPORT_CREATE_USER, IP_SUPPORT_DROP_USER, IP_SUPPORT_CREATE_ROLE, IP_SUPPORT_DROP_ROLE, IP_SUPPORT_GRANT and IP_SUPPORT_REVOKE.
3. Implement ip_dcl () to check the type of command and use the Privilege Management functions of the OpenAccess SDK SQL engine to get details about the DCL command. If the command is GRANT or REVOKE, get the list of privileges, using the dam_getFirstPrivilege() and dam_nextPrivilege() functions. Check the type of privilege (system privilege, object privilege or role name). If the Privileges are Object Privileges, check the object names by using dam_getFirstGrantedObject() and dam_getNextGrantedobject(). Get the list of Grantee(s) by the using dam_getFirstGrantee() and dam_getNextGrantee(). Grant or revoke the specified privilege(s) from the grantee(s) that are referred to in the command. The Grantee can be a user name, role name or PUBLIC.
 
Table 19: Summary of privilege management functions
Function
Description
dam_getUser
Get the user information that is given in the CREATE USER and DROP USER commands.
dam_getRole
Get the role name that is given in the CREATE ROLE and DROP ROLE commands.
dam_firstPrivilege
Get the first privilege that are specified in GRANT and REVOKE commands.
dam_nextPrivilege
Get the next privilege that is specified in GRANT and REVOKE commands.
dam_firstGrantee
Get the name of the user/role that is specified in GRANT and REVOKE commands.
dam_nextGrantee
Get the next name of the user/role that is specified in GRANT and REVOKE commands.
dam_firstGrantedObject
Get the first object that is specified in GRANT and REVOKE commands.
dam_nextGrantedObject
Get the next object that is specified in GRANT and REVOKE commands.