Summary of Contents for Netscape NETSCAPE DIRECTORY SERVER 6.02 - PLUG-IN
Page 1
Plug-In Programmer’s Guide Netscape Directory Server Version 6.02 May 2002...
Page 2
Netscape Communications Corporation (“Netscape”) and its licensors retain all ownership rights to the software programs offered by Netscape (referred to herein as “Software”) and related documentation. Use of the Software and related documentation is governed by the license agreement for the Software and applicable copyright law. Your right to copy this documentation is limited by copyright law.
Preface This book describes how to write server plug-ins in order to customize and extend the capabilities of the Netscape Directory Server (Directory Server). • What You Should Already Know • Using Directory Server Plug-In APIs • Document Conventions • Where to Find Directory Server Information What You Should Already Know This book assumes you have this basic background:...
Page 12
Using Directory Server Plug-In APIs • The main header file is located here: <server_root>/plugins/slapd/slapi/include/slapi-plugin.h • The location and syntax for the plug-in directives have changed. In the Directory Server 4.x release, the directives were in the database section plugin of the file.
Document Conventions Deprecated Functions and Their Suggested Replacements (Continued) Table 0-1 Deprecated Function Suggested Replacement Function slapi_entry_attr_replace() slapi_entry_attr_replace_sv() slapi_attr_get_values() slapi_attr_value_find() slapi_attr_get_oid() slapi_attr_get_oid_copy() slapi_pw_find() slapi_pw_find_sv() slapi_call_syntax_values2keys() slapi_call_syntax_values2keys_sv() slapi_call_syntax_assertion2keys_ava() slapi_call_syntax_assertion2keys_ava_sv() slapi_call_syntax_assertion2keys_sub() slapi_call_syntax_assertion2keys_sub_sv() slapi_entry_attr_hasvalue() slapi_entry_attr_has_syntax_value() The following internal-operation calls are deprecated. The new internal operation functions that are defined in slapi-plugin.h take a Slapi_PBlock for extensibility and support the new plug-in configuration capabilities.
Where to Find Directory Server Information http:// server.domain / path / file .html In these URLs, server represents the name of the server on which you run your application (such as ), domain represents your Internet domain research1 name (such as example.com), path represents the directory structure on the server, represents an individual filename.
Page 15
Where to Find Directory Server Information • Netscape Directory Server Configuration, Command, and File Reference. Contains information about using the command-line scripts shipped with Directory Server. • Netscape Directory Server Schema Reference. Contains information about the Directory Server schema. For a list of documentation installed with Directory Server, open the file, where is the <server_root>/manual/en/slapd/index.htm...
Page 16
Where to Find Directory Server Information Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Part 1 Introduction to Directory Server Plug-Ins Chapter 1, “An Overview of Directory Server Plug-Ins” Chapter 2, “Writing and Compiling Plug-Ins” Chapter 3, “Configuring Plug-Ins” Chapter 4, “A Quick Example”...
Page 18
Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 1 An Overview of Directory Server Plug-Ins This chapter introduces you to Netscape Directory Server (Directory Server) plug-ins and discusses the different types of plug-ins that you can write. The chapter covers the following topics: • What Are Directory Server Plug-Ins? •...
How Directory Server Plug-Ins Work • You can design an action that the Directory Server performs after the server successfully completes an LDAP operation. For example, you can send mail to a client after an LDAP operation is successfully completed. •...
How Directory Server Plug-Ins Work Calling Directory Server Plug-In Functions At specific LDAP events, the Directory Server calls all plug-in functions that are registered for that event. For example, before performing an LDAP add operation (an add event), the server calls all plug-in functions registered as pre-operation add functions.
Page 22
How Directory Server Plug-Ins Work The front-end receives LDAP requests from clients and processes those requests. When processing requests, the front-end calls functions in the back-end to read and write data. The front-end then sends the results back to the client. The back-end reads and writes data to the database containing the directory entries.
Page 23
How Directory Server Plug-Ins Work Directory Server Architecture Figure 1-1 Chapter 1 An Overview of Directory Server Plug-Ins...
Types of Directory Server Plug-Ins Types of Directory Server Plug-Ins You can write the following types of plug-ins for the Directory Server: • Pre-operation/data validation. The server calls a pre-operation/data validation plug-in function before performing an LDAP operation. The main purpose of this type of plug-in is to validate data before the data is added to the directory or before it is used in an operation.
Page 25
Types of Directory Server Plug-Ins Architecture of the Directory Server and Server Plug-Ins Figure 1-2 Chapter 1 An Overview of Directory Server Plug-Ins...
Page 26
Types of Directory Server Plug-Ins Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 2 Writing and Compiling Plug-Ins This chapter provides an introduction on how to write and compile Netscape Directory Server (Directory Server) plug-ins. Chapter 3, “Configuring Plug-Ins,” describes how to load your plug-in into the Directory Server configuration once it is successfully compiled.
Writing a Plug-In Function • Chapter 10, “Writing Extended Operation Plug-Ins” Including the API Header File The interface to the Directory Server plug-in API is located in the slapi-plugin.h header file. You must include this header file in the plug-ins you write. The following line of code shows an example of including this header file: #include "slapi-plugin.h"...
Writing a Plug-In Function Working with Parameter Blocks In the functions you write, you set values in the parameter block that pertain to the operation you are performing. You can also get data from the parameter block which you can use within your functions. This process is described in the next section, “Getting Data from the Parameter Block,”...
Writing a Plug-In Function Getting Data From the Parameter Block (Continued) Code Example 2-1 /* Indicate the point when the plug-in starts executing */ slapi_log_error( SLAPI_LOG_PLUGIN, "searchdn_preop_search", "*** PREOPERATION SEARCH PLUGIN ***\n"); /* Get the base DN of the search from the parameter block. */ slapi_pblock_get( pb, SLAPI_SEARCH_TARGET, &dn );...
Writing a Plug-In Function Setting Values in the Parameter Block (Continued) Code Example 2-2 "Unable to store database information\n" ); Notice that this example uses the function to notify the user slapi_new_condvar() if an error occurred. In this code example, identifies the parameter in the parameter SLAPI_PRIVATE block that contains private data for use in the database functions.
Writing Plug-in Initialization Functions In some cases, you may need to send an LDAP result back to the client. For example, if you are writing a pre-operation bind function and an error occurs during the processing of the function, the function should return a non-zero value, log an error message, and send the appropriate LDAP result code back to the client.
Writing Plug-in Initialization Functions NOTE You do not need to export all plug-in functions. Specifically, you do not need to export any plug-in function that is specified in the parameter block. Specifying Directory Server Compatibility You need to specify the compatibility version of your plug-in so that the Directory Server can determine whether or not it supports the plug-in.
Writing Plug-in Initialization Functions Specifying Plug-In Information (Continued) Code Example 2-3 /* Set this information in the parameter block */ slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&mypdesc ); In this example code specifies the following plug-in information: • The unique identifier for the server plug-in is test-plugin •...
Writing Plug-in Initialization Functions For example, if you want to register as a pre-operation searchdn_preop_search() search function, include the following code in your initialization function: slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_SEARCH_FN, \ (void *) searchdn_preop_search ) is the parameter that specifies the pre-operation SLAPI_PLUGIN_PRE_SEARCH_FN plug-in function for the LDAP search operation.
Compiling a Directory Server Plug-In An Example Initialization Function (Continued) Code Example 2-4 if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || /* Set up the server to call searchdn_preop_search() before each LDAP search operation. */ slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_SEARCH_FN, (void *) searchdn_preop_search ) !=0 ) { /* If a problem occurs, log an error message, return -1.*/ slapi_log_error(SLAPI_LOG_PLUGIN,"searchdn_preop_init",...
Page 37
Compiling a Directory Server Plug-In • If you want, you can compile all plug-in functions in a single library. Although you can include different types of plug-in functions in the same library, you need to write separate initialization functions for each type of plug-in function. Refer to the chapter “Configuring Plug-Ins”...
Page 38
Compiling a Directory Server Plug-In Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 3 Configuring Plug-Ins After you compile your server plug-in, you need to configure the Netscape Directory Server (Directory Server) so that it properly loads your plug-in. The following sections in this chapter show how this is done: • Creating a Plug-In Configuration File •...
Page 40
Creating a Plug-In Configuration File An Example Plug-In Configuration File (Continued) Code Example 3-1 5. cn: Example Plug-in 6. nsslapd-pluginpath: C:/ds60/lib/test-plugin.dll 7. nsslapd-plugininitfunc: searchdn_preop_init 8. nsslapd-plugintype: preoperation 9. nsslapd-pluginenabled: on 10. nsslapd-pluginid: Example Pre-operation Plug-in 11. nsslapd-pluginversion: 1.0 12. nsslapd-pluginvendor: Example Corporation 13.
Creating a Plug-In Configuration File You can also use the Directory Server Console to activate or deactivate the plug-in once the plug-in is loaded. • Line 10 uses the attribute to set the name of the plug-in. nsslapd-pluginid The name that you specify here will show up in the Directory Server Console. In this example, the plug-in identification is set to Example Pre-operation Plug-in...
Creating a Plug-In Configuration File In this example, the plug-in depends on two specifically named plug-ins: . This configuration line indicates that before your my_pluginA vendor_plugin plug-in can be loaded, the two specifically named plug-ins must be loaded. If either of these two plug-ins fail to load, the Directory Server will exit with a error code.
Creating a Plug-In Configuration File In the example above for a given LDAP operation, the pre-operation plug-in function registered by are called before the pre-operation plug-in pre_fn_1() function registered by pre_fn_2() So if is registered by pre_search_fn() pre_fn_1() pre_search_fn2() registered by , the Directory Server calls before pre_fn_2()
Loading the Plug-In Configuration File Directives for Specifying Different Plug-In Types (Continued) Table 3-1 Directive Description Declares a pre-operation/data validation plug-in, which is called by the server preoperation before performing an LDAP operation. Example of use: You can define a data validation function to check new entries before they are added to the directory.
Passing Extra Arguments to Plug-Ins Once the plug-in configuration is loaded, you must shut down the Directory Server and then restart it before you can make calls to your plug-in. There are various ways to shut down and restart the Directory Server; for example, you can: •...
Setting the Log Level of the Server Example 2: dn: cn=Internationalization Plugin,cn=plugins,cn=config objectClass: top objectClass: nsSlapdPlugin objectClass: extensibleObject cn: Internationalization Plugin nsslapd-pluginPath: d:/netscape/servers/lib/liblcoll.dll nsslapd-pluginInitfunc: orderingRule_init nsslapd-pluginType: matchingRule nsslapd-pluginEnabled: on nsslapd-pluginarg0: d:/netscape/servers/slapd-host/config/slapd-collations.conf nsslapd-pluginId: orderingrule nsslapd-pluginVersion: 6.0 nsslapd-pluginVendor: Netscape Communications Corporation nsslapd-pluginDescription: internationalized ordering rule plugin This method allows for more descriptive configuration, which is easier to maintain.
Chapter 4 A Quick Example This chapter provides an example of a pre-operation Netscape Directory Server (Directory Server) server plug-in that you can compile and run. Along with the source code to the example, the chapter provides a Solaris Makefile that you can use to build the plug-in.
An Example Pre-Operation Plug-In Writing the Plug-In Example The following example code includes the sample pre-operation search function and the sample initialization function. Code Example 4-1 Sample Pre-Operation Search and Initialization Functions #include <stdio.h> #include <string.h> #include "slapi-plugin.h" /* function prototypes */ int test_preop_init( Slapi_PBlock *pb );...
Page 49
An Example Pre-Operation Plug-In Sample Pre-Operation Search and Initialization Functions (Continued) Code Example 4-1 from the parameter block and prints the data to the error log. */ test_preop_search( Slapi_PBlock *pb ) char *base, *filter_str, *attr_type, *substr_init, *substr_final; char **substr_any; int scope, deref, filter_type, i; Slapi_Filter *filter;...
Page 50
An Example Pre-Operation Plug-In Sample Pre-Operation Search and Initialization Functions (Continued) Code Example 4-1 break; default: slapi_log_error( SLAPI_LOG_PLUGIN, "SLAPI_SEARCH_DEREF", "unknown value specified: %d\n", deref ); break; /* Get and log the search filter information */ if ( slapi_pblock_get(pb,SLAPI_SEARCH_FILTER, &filter)==0 ) { /* Get and log the filter type */ filter_type = slapi_filter_get_choice( filter );...
An Example Pre-Operation Plug-In Sample Pre-Operation Search and Initialization Functions (Continued) Code Example 4-1 slapi_log_error( SLAPI_LOG_PLUGIN, "\tFinal substring", "%s\n", substr_final ); break; case LDAP_FILTER_PRESENT: slapi_log_error( SLAPI_LOG_PLUGIN, "SLAPI_SEARCH_FILTER", "LDAP_FILTER_PRESENT\n" ); /* For presence filters, get and log the attribute type */ slapi_filter_get_type( filter, &attr_type );...
An Example Pre-Operation Plug-In Code Example 4-2 Example Solaris Makefile # SOLARIS Makefile for Directory Server plug-in examples CC = cc LD = ld INCLUDE_FLAGS = -I../include CFLAGS = $(INCLUDE_FLAGS) -D_REENTRANT -KPIC LDFLAGS = -G OBJS = srchxmpl.o all: srchxmpl.so srchxmpl.so: $(OBJS) $(LD) $(LDFLAGS) -o $@ $(OBJS) .c.o:...
An Example Pre-Operation Plug-In Running the Plug-In Example After compiling the plug-in and registering it with the Directory Server, you’re ready to make calls that are processed by the plug-in functions. The first step is to restart the Directory Server and check the error log to see that the plug-in is properly registered.
Page 54
An Example Pre-Operation Plug-In Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 5 Front-End API Functions The Netscape Directory Server (Directory Server) provides some general-purpose, front-end API functions that allow you to work with the entries in the Directory Server. This chapter explains how to use the front-end API functions to accomplish various tasks;...
Logging Messages Logging Messages To write an error message to the error log, call the function. slapi_new_condvar() For example, the following function call writes a message in slapi_log_error() the error log: slapi_log_error( SLAPI_LOG_PLUGIN, "searchdn_preop_search", "*** PREOPERATION SEARCH PLUGIN ***\n"); This call will create the following message in the error log: [01/Oct/1997:02:24:18 -0700] searchdn_preop_search \ - *** PREOPERATION SEARCH PLUGIN *** Make sure that the Directory Server is configured to log messages that have the...
Sending Data to the Client Sending Data to the Client Sometimes you might need to communicate various information directly back to the client. For example, you might want to do this in the following situations: • If you need to send a result code back to the client (for example, to report an error or a successful result to an LDAP operation), call the function.
Working with Entries, Attributes, and Values Working with Entries, Attributes, and Values This section discusses how to create new entries in the directory and how to convert them to LDIF and back. In certain situations, you will need to pass directory entries between the front-end and the client.
Working with Entries, Attributes, and Values Creating a New Entry In some situations, you might need to create a new entry. There are two basic ways to do this: • By allocating memory for a new entry To allocate memory for a new entry, call the function.
Working with Entries, Attributes, and Values If a double-colon is used after a data type, it signifies that the value after the double-colon is encoded as a base-64 string. Data is sometimes encoded as a base-64 string. For example, it might be encoded this way if the value contains a non-printing character or newline.
Working with Entries, Attributes, and Values To see if an entry complies with the schema, call the function. slapi_entry_schema_check() Getting the Attributes and Values of an Entry There are two basic ways to obtain the attributes and values of an entry: •...
Working with DNs and RDNs • To remove values from an entry, call slapi_entry_delete_values_sv() • In certain situations, you may want to add an attribute and its values to an entry while not replacing any attribute values that already exist. To do this, call function.
Working with DNs and RDNs Working with DN Suffixes A suffix of a DN identifies a subtree in the directory tree where the DN is located. For example, consider the following DN: cn=Babs Jensen, ou=Product Development, o=Example Corporation, c=US In this case, one of the suffixes is: o=Example Corporation, c=US This suffix indicates that the entry is located in the...
Working with Search Filters You can use the following front-end function to normalize and convert the case of a • normalize a DN. slapi_dn_normalize() • to convert all characters in a DN to lowercase. slapi_dn_ignore_case() • to both normalize the DN and convert all slapi_dn_normalize_case() characters in the DN to lowercase.
Working with Search Filters Front-End Functions for Manipulating Filters (Continued) Table 5-3 Function Description Convert a string representation of a filter to a slapi_str2filter() filter of the datatype Slapi_Filter Construct a new LDAP_FILTER_AND, slapi_filter_join() LDAP_FILTER_OR, or LDAP_FILTER_NOT filter from other filters Get the components of a filter (only applicable slapi_filter_list_first(), to LDAP_FILTER_AND, LDAP_FILTER_OR,...
Working with Search Filters Types of Filters (Continued) Table 5-4 Filter Type Description The search should find entries that contain a value LDAP_FILTER_GE greater than or equal to the specified attribute value. The search should find entries that contain a value less LDAP_FILTER_LE than or equal to the specified attribute value.
Checking Passwords Converting a String to a Filter A search filter can be represented by either the datatype or as a Slapi_Filter string. In a parameter block for a search operation, is a filter SLAPI_SEARCH_FILTER of the datatype is the string Slapi_Filter SLAPI_SEARCH_STRFILTER representation of that filter.
Page 70
Checking Passwords • (means Unix crypt algorithm and can be defined using the CRYPT plug-in) crypt-password-storage-scheme • (means Secure Hashing Algorithm and can be defined using the plug-in) -password-storage-scheme • (means Salted Secure Hashing Algorithm and can be defined using the SSHA plug-in) ssha-password-storage-scheme...
Chapter 6 Writing Pre/Post-Operation Plug-Ins This chapter explains how to write functions that the Netscape Directory Server (Directory Server) calls before and after executing an LDAP operation. These functions are called pre-operation and post-operation plug-in functions. • How Pre/Post-Operation Plug-Ins Work •...
Page 72
How Pre/Post-Operation Plug-Ins Work You can also set up the Directory Server to call your own plug-in functions before and after: • Sending an LDAP entry back to the client • Sending an LDAP result code back to the client •...
Types Pre-Operation and Post-Operation Functions Types Pre-Operation and Post-Operation Functions As is the case with other server plug-in functions, pre-operation functions and post-operation functions are specified in a parameter block that you can set on server startup. Each function corresponds to an ID in the parameter block. In your initialization function, you can call the function to specify slapi_pblock_set()
Types Pre-Operation and Post-Operation Functions Functions Called Before the Directory Server Executes an Operation (Continued) Table 6-1 ID in Parameter Block Description Specifies the function called before the Directory Server SLAPI_PLUGIN_PRE_MODIFY_FN executes an LDAP modify operation. For information on writing this type of function, see “Processing an LDAP Modify Operation”...
Page 75
Types Pre-Operation and Post-Operation Functions Table 6-2 Functions Called After the Directory Server Executes an Operation ID in Parameter Block Description Specifies the function called after the Directory Server SLAPI_PLUGIN_POST_BIND_FN executes an LDAP bind operation. For information on writing this type of function, see “Processing an LDAP Bind Operation”...
Registering Pre/Post-Operation Functions Functions Called After the Directory Server Executes an Operation (Continued) Table 6-2 ID in Parameter Block Description Specifies the function called after the Directory Server sends SLAPI_PLUGIN_POST_ENTRY_FN an entry back to the client (for example, when you call slapi_send_ldap_search_entry(), the post-operation entry function is called after the entry is sent back to the client).
Chapter 7 Defining Functions for LDAP Operations This chapter explains how to write pre-operation and post-operation functions for specific LDAP operations. In general, the functions outlined here use a parameter block to pass information between the plug-in and the Netscape Directory Server (Directory Server).
Specifying Start and Close Functions Specifying Start and Close Functions For each pre-operation and post-operation plug-in, you can specify the name of a function to be called after the server starts and before the server is shut down. Use the following parameters to specify these functions: Specifies the function called after the Directory Server SLAPI_PLUGIN_START_FN starts up.
Processing an LDAP Unbind Operation Your pre-operation and post-operation bind functions should return 0 if successful. If the pre-operation function returns a non-zero value, the post-operation bind function is never called. For information on defining a function that handles authentication, see Chapter 8, “Defining Functions for Authentication.”...
Processing an LDAP Search Operation • parameter specifies the pre-operation SLAPI_PLUGIN_PRE_UNBIND_FN unbind function. • parameter specifies the post-operation SLAPI_PLUGIN_POST_UNBIND_FN unbind function. You set these parameters to the names of your functions by calling slapi_pblock_set() Your plug-in functions should return 0 if successful. If the pre-operation function returns a non-zero value, the post-operation unbind function is never called.
Processing an LDAP Search Operation Getting the List of Candidates When the Directory Server receives an LDAP search request, the front-end gets information about the search (such as the scope and base DN). The front-end normalizes the base DN (by calling the function) and slapi_dn_normalize() determines if the base DN identifies a DSA-specific entry (DSE).
Processing an LDAP Search Operation Parameter ID Data Type Description Slapi_Filter struct (an SLAPI_SEARCH_FILTER Slapi_Filter * opaque data structure) representing the filter to be used in the search. String representation of the filter SLAPI_SEARCH_STRFILTER char * to be used in the search. Array of attribute types to be SLAPI_SEARCH_ATTRS char **...
Page 83
Processing an LDAP Search Operation Parameter ID Data Type Description Set of search results. SLAPI_SEARCH_RESULT_SET void * Entry returned from iterating SLAPI_SEARCH_RESULT_ENTRY void * through the results set. This “next entry” function actually sets this parameter. (Netscape Directory Server 4.x) SLAPI_SEARCH_RESULT_ENTRY_EXT void * Reserved for future use.
Processing an LDAP Compare Operation Processing an LDAP Compare Operation When the Directory Server receives an LDAP compare request from a client, the front-end gets the DN of the entry being compared and the attribute and value being used in the comparison. The front-end makes this information available to pre-operation and post-operation plug-in functions in the form of parameters in a parameter block.
Page 85
Processing an LDAP Add Operation The add function should check the following: • If the operation has been abandoned, the function should return -1. (You do not need to call to send an LDAP error code to slapi_send_ldap_result() the client. According to the LDAP protocol, the client does not expect a server response after an operation is abandoned.) •...
Processing an LDAP Modify Operation Processing an LDAP Modify Operation When the Directory Server receives an LDAP modify request from a client, the front-end gets the DN of the entry to be modified and the modifications to be made. The front-end makes this information available to pre-operation and post-operation plug-in functions in the form of parameters in a parameter block.
Processing an LDAP Modify RDN Operation • If the RDN of the entry contains attribute values that are not part of the entry (for example, if the RDN is “uid=bjensen” but the entry has no uid value or has a different uid value), the function should call slapi_send_ldap_result() send the LDAP error code and should return -1.
Page 88
Processing an LDAP Modify RDN Operation The modify RDN function should check the following: • If the operation has been abandoned, the function should return -1. (You do not need to call to send an LDAP error code to slapi_send_ldap_result() the client.
Processing an LDAP Delete Operation Processing an LDAP Delete Operation When the Directory Server receives an LDAP delete request from a client, the front-end gets the DN of the entry to be removed from the directory. The front-end makes this information available to pre-operation and post-operation plug-in functions in the form of parameters in a parameter block.
Page 90
Processing an LDAP Abandon Operation Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 8 Defining Functions for Authentication This chapter explains how to write a plug-in function to bypass or replace the standard function for authentication with your own function. Information on authentication with the Netscape Directory Server (Directory Server) is organized in the following sections: •...
How the Directory Server Identifies Clients SASL provides the means to use mechanisms other than simple authentication and SSL to authenticate to the Directory Server. How the Directory Server Identifies Clients The server keeps track of the identity of the LDAP client through the parameters.
Page 93
How the Authentication Process Works If the SASL mechanism is not supported by the server, the server sends an result code back to the client and ends the LDAP_AUTH_METHOD_NOT_SUPPORTED processing of the bind request. If the method of authentication is (simple authentication), LDAP_AUTH_SIMPLE the server checks if the DN is an empty string or if there are no credentials.
Page 94
How the Authentication Process Works If the credentials are correct, the server sets the SLAPI_CONN_DN parameter to the DN and the parameter to SLAPI_CONN_AUTHTYPE . The server sends an result code back LDAP_AUTH_SIMPLE LDAP_SUCCESS to the client and ends the processing of the bind request. If the credentials are incorrect, the server sends an result code back to the client and ends the LDAP_INVALID_CREDENTIALS...
Writing Your Own Authentication Plug-in Writing Your Own Authentication Plug-in A situation may arise in which you may want to write and implement your own function for authentication; that is, replace the standard means of authentication with your own function. You can write a pre-operation bind plug-in function (a function that the server calls before processing an LDAP bind request) that performs the authentication and bypasses the default bind functionality.
Page 96
Writing a Pre-Operation Bind Plug-in Using a Pre-Operation Bind Plug-In Function to Handle Authentication Figure 8-1 Figure 8-2 illustrates the steps that your pre-operation bind plug-in function must take to authenticate LDAP clients to the Directory Server. Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Writing a Pre-Operation Bind Plug-in How Your Pre-Operation Bind Plug-In Function Can Authenticate LDAP Figure 8-2 Clients Defining Your Authentication Function The following sections cover guidelines that you can follow when defining your authentication function: • Getting and Checking the Bind Parameters •...
Writing a Pre-Operation Bind Plug-in • structure containing the credentials sent SLAPI_BIND_CREDENTIALS berval by the client) If you plan to support authentication through SASL mechanisms, you should also parameter (a string value get the value of the SLAPI_BIND_SASLMECHANISM specifying the name of the SASL mechanism to use for authentication). Make sure to check the following: •...
Writing a Pre-Operation Bind Plug-in • (means Secure Hashing Algorithm and can be defined using the plug-in) -password-storage-scheme • (means Salted Secure Hashing Algorithm and can be defined using the SSHA plug-in) ssha-password-storage-scheme If you need to compare the client’s credentials against the value of the attribute, you can call the function.
Writing a Pre-Operation Bind Plug-in This sets the DN and authentication method for the connection to the client. (The server uses this DN and method in subsequent operations when checking access rights.) to one of the following values: You can set SLAPI_CONN_AUTHTYPE represents no authentication.
Writing a Pre-Operation Bind Plug-in Note that if you do not register your SASL mechanism, the Directory Server will send an result code back to the client and LDAP_AUTH_METHOD_NOT_SUPPORTED will not call your pre-operation bind function. NOTE Be sure to check this source file for an example of a pre-operation plug-in function for SASL authentication with LDAP bind operations: <server_root>/plugins/slapd/slapi/examples/testsaslbind.c Example of a Pre-Operation Bind Plug-In...
Page 102
Writing a Pre-Operation Bind Plug-in Sample Pre-Operation Bind Function (Continued) Code Example 8-1 Slapi_Entry *e = NULL; Slapi_Entry **entries = NULL; Slapi_Attr *attr = NULL; /* Log a message to the server error log. */ slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind", "Pre-operation bind function called.\n" ); /* Gets parameters available when processing an LDAP bind operation.
Page 103
Writing a Pre-Operation Bind Plug-in Sample Pre-Operation Bind Function (Continued) Code Example 8-1 if ( slapi_entry_attr_find( e, "userpassword", &attr ) != 0 slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind", "Entry has no userpassword attribute\n" ); rc = LDAP_INAPPROPRIATE_AUTH; break; slapi_attr_get_values( attr, &pwvals ); if ( slapi_pw_find( pwvals, credentials ) != 0 ) { slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind", "Credentials are not correct for the entry\n"...
Writing a Pre-Operation Bind Plug-in Sample Pre-Operation Bind Function (Continued) Code Example 8-1 break; /* This plug-in does not support any other method of authentication */ case LDAP_AUTH_SASL: default: slapi_log_error( SLAPI_LOG_PLUGIN, "test_bind", "Unsupported authentication method requested: %d\n", method ); rc = LDAP_AUTH_METHOD_NOT_SUPPORTED; break;...
Using SASL with an LDAP Client nsslapd-pluginType: preoperation nsslapd-pluginEnabled: on nsslapd-plugin-depends-on-type: database nsslapd-pluginId: test-bind Check this source file for an example of a pre-operation plug-in function that handles authentication: <server_root>/plugins/slapd/slapi/examples/testbind.c Using SASL with an LDAP Client If you intend to use SASL as the method for authenticating clients, you need to enable your LDAP clients to use SASL.
Page 107
Using SASL with an LDAP Client • is a pointer to an array of structures representing serverctrls LDAPControl the LDAP v3 server controls that you want passed to the server for the bind operation. is a pointer to an array of structures representing •...
Page 108
Using SASL with an LDAP Client • is the connection handle, which is a pointer to the LDAP structure containing information about the connection to the LDAP server. • is a pointer to the structure containing the results that you LDAPMessage want to parse.
Page 109
Using SASL with an LDAP Client LDAP Client Authenticating Using SASL Method (Continued) Code Example 8-3 if ( ldap_sasl_bind_s( ld, "uid=bjensen,ou=people,o=example.com", "babsmechanism", &cred, NULL, NULL, &servcred ) != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_sasl_bind_s" ); return( 1 ); /* get and print the credentials returned by the server */ printf( "Server credentials: %s\n", servcred->bv_val );...
Page 110
Using SASL with an LDAP Client Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 9 Writing Entry Store/Fetch Plug-Ins This chapter describes how to write entry store and entry fetch plug-ins. You can use these types of plug-ins to invoke functions before and after data is read from the default database. The chapter contains the following sections: •...
Writing Entry Store/Fetch Functions How the Server Calls Entry Store and Entry Fetch Plug-In Functions Figure 9-1 Writing Entry Store/Fetch Functions Unlike most other types of plug-in functions, entry store and entry fetch plug-in functions are not passed a parameter block when called. Instead, entry store and entry fetch plug-in functions must have the following prototype: void function_name( char **entry, unsigned long *len );...
Registering Entry Store/Fetch Functions Pointer to a string specifying the entry in LDIF format; for entry details on this format, see “slapi_filter_free()” on page 309. Pointer to the length of the entry string. Since the text of the entry is passed in as an argument, you can modify the entry before it gets saved to disk and modify the entry after it is read from disk.
Page 116
Registering Entry Store/Fetch Functions plugin entrystore [on|off] "<name of plugin>" \ <library_name> <function_name> plugin entryfetch [on|off] "<name of plugin>" \ <library_name> <function_name> is the name and path to your shared library or dynamic link <library_name> library, and is the name of your plug-in function. <function_name>...
Chapter 10 Writing Extended Operation Plug-Ins This chapter explains how to write plug-in functions to handle extended operations. Extended operations are are defined in the LDAP v3 protocol. The chapter contains the following sections: • How Extended Operation Plug-Ins Work •...
Writing Extended Operation Functions Writing Extended Operation Functions Like other plug-in functions, extended operation functions pass a single parameter block ( ) and return an integer value, as shown in the following Slapi_PBlock example declaration: int my_ext_func( Slapi_PBlock *pb ); Extended operation functions should return a value of if they are successful and a non-zero value if they are unsuccessful.
Registering Extended Operation Functions • If your function cannot handle the extended operation with the specified OID, your function should return the value . The front-end will send an SLAPI_PLUGIN_EXTENDED_NOT_HANDLED result code (with an “unsupported extended operation LDAP_PROTOCOL_ERROR error message”) back to the client. NOTE For a sample plug-in function (uncompiled C code) that implements an extended operation, check this file:...
Page 120
Registering Extended Operation Functions Sample Initialization Function for Passing an OID (Continued) Code Example 10-1 /* Get the number of additional arguments and copy them. */ for ( i = 0; argv[i] != NULL; i++ ) oids = (char **) slapi_ch_malloc( (i+1) * sizeof(char *) ); for ( i = 0;...
Specifying Start and Close Functions nsslapd-pluginEnabled: on nsslapd-plugin-depends-on-type: database nsslapd-pluginId: test-extendedop nsslapd-pluginarg0: 1.2.3.4 For an example plug-in function that implements an extended operation, take a look at this source file: <server_root>/plugins/slapd/slapi/examples/testextendedop.c In Netscape Directory Server 4.x, add this directive to the file: slapd.ldbm.conf plugin extendedop [on|off] “<name of plugin>”...
Page 122
Specifying Start and Close Functions Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Chapter 11 Writing Matching Rule Plug-Ins This chapter explains how to write plug-in functions that handle matching rules. Matching rule plug-in functions are described in the following sections: • Understanding Matching Rules • Understanding Matching Rule Plug-Ins • Indexing Based on Matching Rules •...
Understanding Matching Rules Extensible Match Filters In an “extensible match” filter, the client specifies that it wants to use the matching rule to compare a specified value against the values of entries in the directory. (For example, an extensible match filter might find all entries in which the attribute “sounds like”...
Understanding Matching Rule Plug-Ins Extensible Match Filters in the Directory Server Directory Server 6.x and earlier versions already include support for certain matching rules (which are used to determine the collation order and operator for searches of international data). You can enable the Directory Server to handle your own matching rules for extensible match searches by defining your own matching rules plug-ins and registering them with the server.
Understanding Matching Rule Plug-Ins When the server starts up and loads the matching rule plug-in, it calls the initialization function. In this function, you pass the server the pointers to the factory functions and the close function. The server calls these functions when needed (see “How Matching Rules Are Identified”...
Understanding Matching Rule Plug-Ins How the Server Associates Plug-Ins with OIDs When the server encounters the OID for a matching rule, it attempts to find the plug-in associated with that matching rule. If no plug-in is associated with the matching rule, the server calls each matching rule plug-in to find one that handles the specified matching rule.
Understanding Matching Rule Plug-Ins Finding a Plug-In for Searching To determine which matching rule plug-in is responsible for handling an extensible match filter for a given matching rule (based on its OID), the server does the following for each plug-in: In a new parameter block, the server sets the following Slapi_PBlock...
Indexing Based on Matching Rules How the Server Uses Parameter Blocks The server uses parameter blocks as a means to pass information to and from your plug-in functions. When calling your matching rule plug-in functions, the server will create a new parameter block, set some input parameters, and pass the Slapi_PBlock parameter block to your function.
Indexing Based on Matching Rules The server gets the OID returned in the parameter and SLAPI_PLUGIN_MR_OID associates this OID with the rest of the attribute indexing information (such as the attribute type and the type of index) for future reference. When adding, modifying, or deleting the values of an attribute, the server will check this information to determine if the attribute is indexed.
Indexing Based on Matching Rules Writing the Indexer Factory Function The indexer factory function takes a single argument. This function Slapi_PBlock should be thread-safe. The server may call this function concurrently. The indexer factory function should do the following: Get the OID from the parameter and determine SLAPI_PLUGIN_MR_OID whether or not that OID is supported by your plug-in.
Indexing Based on Matching Rules Set the parameter to the function responsible SLAPI_PLUGIN_DESTROY_FN for freeing any memory allocated by the factory function, such as the indexer object. (See “Writing a Destructor Function” on page 143 for details.) Return 0 (or the result code ) if everything completed LDAP_SUCCESS successfully.
Indexing Based on Matching Rules Input and Output Parameters Available to a Indexer Factory Function (Continued) Table 11-1 Parameter Name Data Type Description (Input parameter) Pointer to any private SLAPI_PLUGIN_PRIVATE void * data originally specified in the initialization function. (See “Writing an Initialization Function”...
Handling Extensible Match Filters Getting and Setting Parameters in Indexer Functions The following table summarizes the different parameters that the indexer function should get and set in the parameter block that is passed in: Table 11-2 Input and output parameters available to an indexer function Parameter Name Data Type Description...
Handling Extensible Match Filters How the Server Handles the Filter When the server processes a search request that has an extensible match filter, the server does the following: First, the server finds the plug-in associated with this OID, if an association between the OID and plug-in has already been made.
Handling Extensible Match Filters The server calls the filter matching function (which is specified in the parameter), passing in the filter SLAPI_PLUGIN_MR_FILTER_MATCH_FN object, the entry, and the attributes of the entry. If the entry does not match but the search request also specifies that the attributes in the DN should be searched, the server calls the filter matching function again, passing in the filter object, the entry, and the attributes in the DN.
Handling Extensible Match Filters If the query operator is , the server attempts to find the keys in SLAPI_OP_EQUAL the index that match the value specified in the search filter. In the case of the other query operators, the server attempts to find ranges of keys that match the value. Writing a Filter Factory Function The filter factory function takes a single argument.
Handling Extensible Match Filters Set the following parameters: Set the parameter to the official OID of the SLAPI_PLUGIN_MR_OID matching rule, if the value of that parameter is not the official OID (optional). Set the parameter to the filter object. SLAPI_PLUGIN_OBJECT Set the parameter to the filter index SLAPI_PLUGIN_MR_FILTER_INDEX_FN...
Handling Extensible Match Filters Input and Output Parameters Available to a Filter Factory Function (Continued) Table 11-4 Parameter Name Data Type Description (Input parameter) Pointer to any SLAPI_PLUGIN_PRIVATE void * private data originally specified in the initialization function. (See “Writing an Initialization Function”...
Handling Extensible Match Filters Set the parameter to the attribute type in the SLAPI_PLUGIN_MR_TYPE filter object. Set the parameter to the values in the filter SLAPI_PLUGIN_MR_VALUES object. Set the parameter to the query SLAPI_PLUGIN_MR_QUERY_OPERATOR operator that corresponds to this search filter. (See “Query Operators in Matching Rules”...
Handling Extensible Match Filters Input and Output Parameters Available to a Filter Index Function (Continued) Table 11-5 Parameter Name Data Type Description (Output parameter) Official SLAPI_PLUGIN_MR_OID char * matching rule OID (if any) specified in the extensible match filter. (Output parameter) Attribute type SLAPI_PLUGIN_MR_TYPE char * (if any) specified in the extensible...
Handling Sorting by Matching Rules Find the corresponding attribute in the attributes passed into the function. Make sure to check for subtypes of an attribute (for example, “cn;lang-ja”) in the filter and in the attributes specified by attrs You can call the function to compare the attribute in slapi_attr_type_cmp() the filter against the attributes passed in as arguments.
Writing a Destructor Function The server calls the indexer function (specified by the parameter). SLAPI_PLUGIN_MR_INDEXER_FN Next, the server gets the value of the parameter, SLAPI_PLUGIN_MR_KEYS which is an array of structures containing the keys corresponding berval to the values. The server compares the keys to sort the results. Writing a Destructor Function The server calls the destructor function to free any memory that you’ve allocated (for example, the indexer object or the filter object).
Page 144
Writing an Initialization Function In order to add your plug-in to that internal list, you need to write an initialization function. The initialization function takes a single argument. The Slapi_PBlock function should set the following parameters: parameter should be set to the •...
Registering Matching Rule Functions Input and Output Parameters Available to a Matching Rule Plug-In Initialization Function Table 11-7 Parameter Name Data Type Description (Output parameter) The “close” SLAPI_PLUGIN_CLOSE_FN void * function, which the server calls (function pointer) before shutting down. (Output parameter) Pointer to SLAPI_PLUGIN_PRIVATE void *...
Specifying Start and Close Functions plugin matchingrule on “my matching rule plugin” /usr/ns/myplugin.so my_init_fn Specifying Start and Close Functions For each matching rule operation plug-in, you can specify the name of a function to be called after the server starts and before the server is shut down. These functions take a single argument.
Chapter 12 Using the Custom Distribution Logic The distribution plug-in provided with Netscape Directory Server (Directory Server) distributes a flat namespace, allowing you to associate several databases with a single suffix. This document contains the following sections: • About Distributing Flat Namespaces •...
Creating a Distribution Function Because the number of users is too large, you decide to distribute the entries according to the first letter of each user’s last name, assigning each letter to a separate database. To do this, you need to create your own distribution function. Your function determines how each operation received by the suffix is ou=users...
Page 149
Creating a Distribution Function Each time the server gets a request for a suffix that contains the distribution function, the function is called. The function then decides which database (backend) processes the request. The decision made by the function is based on some piece of information present in the pblock at the time of the request (such as the entry DN, a hash function, the time of day, or the type of operation).
Adding the Distribution Function to Your Directory You can create the root entry in two ways: • Import the same LDIF file into each database using the command-line ldif2db utility. This LDIF file should contain the root entry as well as data that you want to distribute across the databases.
Adding the Distribution Function to Your Directory Adding Multiple Databases to a Single Suffix The following procedures describe adding multiple databases to a suffix using the console and the command-line. Using the Console In the Directory Server Console, select the Configuration tab. Expand the Data tree and select the suffix to which you want to add another database.
Adding the Distribution Function to Your Directory The entry added corresponds to a database named that contains the data for Datas the root suffix ou=people,dc=example,dc=com The database name, given in the DN attribute, must correspond with one of the attribute of the suffix entry. values in the nsslapd-backend Adding Distribution Logic to a Suffix...
Using the Distribution Logic Examples Using the Distribution Logic Examples The directory provides three distribution logic examples. The examples illustrate the following: • Distributing entries based on the first letter of their RDN (alpha_distribution). The example uses as many databases as you like to contain the data. For example, if you create 3 databases for a single suffix, entries starting with the letters A-I to database 0, entries starting with the letters J-R go to database 1, and entries starting with the letters S-Z go to database 2.
Custom Distribution Checklist Imagine you want to use the hash distribution function on a Solaris machine. First create a suffix. Then create several databases under that suffix. Next, import the suffix entry to each of the databases you created. Finally, add the following lines to the suffix: nsslapd-distribution-plugin: /plugin/distrib-plugin.so nsslapd-distribution-funct: hash_distribution...
Chapter 13 Data Type and Structure Reference This chapter summarizes the data types and structures that you can use when writing Netscape Directory Server (Directory Server) plug-in functions. Summary of Data Types and Structures The functions in the server plug-in API use the following data types and structures: •...
Page 158
Summary of Data Types and Structures • Slapi_Filter • Slapi_Mutex • Slapi_PBlock • Slapi_PluginDesc berval data structure represents binary data that is encoded using simplified berval Basic Encoding Rules (BER). The data and size of the data are included in a berval structure.
Page 159
Summary of Data Types and Structures Before the Directory Server sends an entry back to a client, it determines if any of the attributes are computed, generates the attributes, and includes the generated attributes in the entry. structure to As part of this process, the server creates a computed_attr_context pass relevant information to the functions generating the attribute values.
Page 160
Summary of Data Types and Structures LDAPMod is a type of structure that you use to specify changes to an attribute in an LDAPMod directory entry. Before you call the slapi_add_internal_pb() routines to add or modify an entry in the slapi_modify_internal_pb() directory, you need to fill structures with the attribute values that you...
Page 161
Summary of Data Types and Structures Pointer to a NULL-terminated array of berval structures for the mod_bvalues attribute. The following section of code sets up an structure to change the email LDAPMod address of a user’s entry to " ": bab@example.com Code Example 13-1 Sample Code for Changing the Email.
Page 162
Summary of Data Types and Structures Syntax #include “slapi-plugin.h” typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry* entry, Slapi_Attr* attrs); Parameters The function has the following parameters: Pointer to the filter structure created by your filter factory function. (For filter details, see “Writing a Filter Factory Function” on page 137.) Pointer to the Slapi_Entry structure representing the candidate entry entry being checked by the server.
Page 163
Summary of Data Types and Structures plugin_referral_entry_callback() This typedef is used for LDAP referral entry callback functions, which are plugin-defined functions that process LDAP references that may be generated by some internal searches. Syntax #include “slapi-plugin.h” typedef int (*plugin_referral_entry_callback) (char *referral, void *callback_data); Parameters The function takes the following parameters: The URL of a reference that is returned in response to an internal...
Page 164
Summary of Data Types and Structures Syntax #include “slapi-plugin.h” typedef void (*plugin_result_callback)(int rc, void *callback_data); Parameters The function takes the following parameters: The LDAP result code of the internal operation, for example, LDAP_SUCCESS. This value matches the callback_data pointer that was callback_data passed to the original internal operation function.
Page 165
Summary of Data Types and Structures This value matches the callback_data pointer that was callback_data passed to the original internal operation function. Returns This search entry callback function should return a 0 to continue the search, or -1 to end the search. Description A function that matches this typedef can be passed as the parameter of...
Page 166
Summary of Data Types and Structures Pointer to the array of berval structures used to collect LDAP referrals urls for LDAP v2 clients. Returns 0 if successful, or -1 if an error occurs. Description function is responsible for sending LDAP v3 slapi_send_ldap_result() referrals (search result references) back to the client.
Page 167
Summary of Data Types and Structures LDAP result code that you want sent back to the client (for example, LDAP_SUCCESS). When sending back an LDAP_NO_SUCH_OBJECT result code, use this matched argument to specify the portion of the target DN that could be matched.
Page 168
Summary of Data Types and Structures Syntax #include “slapi-plugin.h” typedef int (*send_ldap_search_entry_fn_ptr_t) ( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly ); Description function is responsible for sending slapi_send_ldap_search_entry() entries found by a search back to the client. You can replace the function that sends entries to the client with your own function.
Page 169
Summary of Data Types and Structures To do this... Call this function Determine if an entry contains a specific slapi_entry_attr_find() attribute Get the type of an attribute slapi_attr_get_type() Get the object identification (OID) of an slapi_attr_get_oid_copy() attribute Determine if an attribute has the slapi_attr_value_find() specified value Compare two values of an attribute...
Page 170
Summary of Data Types and Structures Slapi_CondVar Represents a condition variable in the server plug-in. Syntax #include slapi-plugin.h typedef struct slapi_condvar Slapi_CondVar; Description is the data type for an opaque structure that represents a Slapi_CondVar condition variable in the server plug-in. Slapi_Entry Represents an entry in the directory.
Page 171
Summary of Data Types and Structures To do this... Call this function Get the normalized string DN of an entry slapi_entry_get_ndn() Get the DN of the entry as a Slapi_DN slapi_entry_get_sdn() Get the DN of the entry as a Slapi_DN slapi_entry_get_sdn_const() * in a “const”...
Page 172
Summary of Data Types and Structures The following table summarizes the front-end API functions that you can call to work with filters. To do this... Call this function Determine if an entry matches a filter’s criteria slapi_filter_test() Get the filter type slapi_filter_get_choice() Get the attribute type and value used for slapi_filter_get_ava()
Page 173
Summary of Data Types and Structures Slapi_PBlock Contains name-value pairs that you can get or set for each LDAP operation. Syntax #include slapi-plugin.h typedef struct slapi_pblock Slapi_PBlock; Description contains name-value pairs that you can use to retrieve information Slapi_PBlock from the server and set information to be used by the server. For most types of plug-in functions, the server passes in a Slapi_PBlock structure that typically includes data relevant to the operation being processed.
Page 174
Summary of Data Types and Structures Slapi_PluginDesc represents information about a server plug-in. In your Slapi_PluginDesc initialization function, you specify information about your plug-in in this structure and call to put the structure in the slapi_pblock_set() parameter. SLAPI_PLUGIN_DESCRIPTION is defined as follows: Slapi_PluginDesc typedef struct slapi_plugindesc { char *spd_id;...
Chapter 14 Function Reference This chapter contains reference information on Netscape Directory Server (Directory Server) server plug-in API. The server plug-in API includes the following functions: • Distribution Routines • Functions for Access Control • Functions for Internal Operations and Plug-In Callback •...
Distribution Routines • Functions for LDAPMod Manipulation • Functions for Monitoring Operations • Functions for Managing Parameter Block • Functions for Handling Passwords • Functions for Managing RDN • Functions for Managing Roles • Functions for Managing DNs • Functions for Sending Entries and Results to the Client •...
Functions for Access Control Syntax #include “slapi-plugin.h” int distribution_plugin_entry_point (Slapi_PBlock *pb, Slapi_DN *target_dn, char **mtn_be_names, int be_count, Slapi_DN * node_dn); Parameters This function takes the following parameters: Pointer to the parameter block of the operation. Pointer to the target DN of the operation. target_dn Pointer to the list of names of backends declared for this node.
Page 178
Functions for Access Control Table 14-2 Access Control Routines Function Description slapi_access_allowed() 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 slapi_acl_check_mods() Determines if a user has the rights to perform the specified modifications on an entry.
Page 179
Functions for Access Control Permission to compare the specified values of an attribute in SLAPI_ACL_COMPARE an entry. Permission to delete a specified entry. SLAPI_ACL_DELETE Permission to read a specified attribute. SLAPI_ACL_READ Permission to search on a specified attribute or value. SLAPI_ACL_SEARCH Permission to write a specified attribute or value or SLAPI_ACL_WRITE...
Page 180
Functions for Access Control 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 pre-operation plug-in for the add operation.
Page 181
Functions for Access Control slapi_pblock_set( pb, SLAPI_BACKEND, be ); nAccessResult = slapi_access_allowed( pb, seObjectEntry, "*", bval, SLAPI_ACL_DELETE); slapi_acl_check_mods() Determines if a user has the rights to perform the specified modifications on an entry. Syntax #include “slapi-plugin.h” int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char **errbuf );...
Page 182
Functions for Access Control Invalid syntax was specified. LDAP_INVALID_SYNTAX This error can occur if the ACL associated with an entry, attribute, or value uses the wrong syntax. The DSA (this directory server) is unable to LDAP_UNWILLING_TO_PERFORM perform the specified operation. This error can occur if, for example, you are requesting write access to a read-only database.
Page 183
Functions for Access Control Memory Concerns You must free the buffer by calling when you are errbuf slapi_ch_free() finished using the error message. See Also slapi_access_allowed() slapi_ch_free() slapi_acl_verify_aci_syntax() Determines whether or not the access control items (ACIs) on an entry are valid. Syntax #include “slapi-plugin.h”...
Functions for Internal Operations and Plug-In Callback Functions for Internal Operations and Plug-In Callback This section contains reference information on routines for internal operations and plug-in callbacks—these functions can be used for internal operations based on DN as well as on unique ID. These functions should be used by all new plug-ins and preferably old plug-ins should be changed to use them to take advantage of new plug-in configuration capabilities and to use an extensible interface.
Page 185
Functions for Internal Operations and Plug-In Callback block that has been initialized using A parameter slapi_add_internal_set_pb() Returns This function returns one of the following values: • 0 if successful. • -1 if an error occurs. If -1 is returned, the field of SLAPI_PLUGIN_INTOP_RESULT the parameter block should be consulted to determine the precise LDAP result...
Page 186
Functions for Internal Operations and Plug-In Callback Returns This function returns one of the following values: • 0 if successful. • -1 if an error occurs. If -1 is returned, the field of SLAPI_PLUGIN_INTOP_RESULT the parameter block should be consulted to determine the precise LDAP result code.
Page 187
Functions for Internal Operations and Plug-In Callback slapi_modify_internal_pb() Performs an LDAP modify operation based on a parameter block to modify a directory entry. Syntax #include “slapi-plugin.h” int slapi_modify_internal_pb(Slapi_PBlock *pb); Parameters This function takes the following parameter: A parameter block that has been initialized using slapi_modify_internal_set_pb().
Page 188
Functions for Internal Operations and Plug-In Callback Parameters This function takes the following parameter: A parameter block that has been initialized using slapi_rename_internal_set_pb(). Returns This function returns one of the following values: • 0 if successful. • -1 if an error occurs. If -1 is returned, the field of SLAPI_PLUGIN_INTOP_RESULT the parameter block should be consulted to determine the precise LDAP result...
Page 189
Functions for Internal Operations and Plug-In Callback A parameter block that has been initialized using slapi_seq_internal_callback_set_pb(). A pointer to arbitrary plug-in or operation-specific data that you callback_data would like to pass to your callback functions. Callback function that the server calls to send result codes. The function must have the prototype specified by plugin_result_callback().
Page 190
Functions for Internal Operations and Plug-In Callback This function must have the prototype specified by . You specify this function in the plugin_search_entry_callback() psec argument of slapi_search_internal_callback_pb() • You can write a callback function that is invoked when the search operation normally sends LDAP v3 search result references.
Page 191
Functions for Internal Operations and Plug-In Callback The address of a Slapi_Entry pointer to receive the entry if it ret_entry is found. A plug-in or component identifier. This value can be obtained caller_identity from the SLAPI_PLUGIN_IDENTITY field of the parameter block that is passed to your plug-in initialization function.
Functions for Setting Internal Operation Flags Returns This function returns one of the following values: • 0 if successful. • -1 if an error occurs. If -1 is returned, the field of SLAPI_PLUGIN_INTOP_RESULT the parameter block should be consulted to determine the precise LDAP result code.
Page 193
Functions for Setting Internal Operation Flags Internal Operation Flag Routines (Continued) Table 14-4 Function Description slapi_seq_internal_callback_pb() Performs internal sequential access operation. slapi_seq_internal_set_pb() Sets up a parameter block for use by slapi_seq_internal_callback_pb() for an internal, sequential-access operation. slapi_add_entry_internal_set_pb() Sets up a parameter block so that it can be used by slapi_add_internal_pb() an internal add operation.
Page 194
Functions for Setting Internal Operation Flags Description This function populates parameters in the structure so that it can be used pblock for an internal add operation. slapi_add_internal_pb() slapi_add_internal_set_pb() Sets up a parameter block so that it can be used by slapi_add_internal_pb() an internal add operation.
Page 195
Functions for Setting Internal Operation Flags • set to DN of the new entry. SLAPI_TARGET_DN • set to request controls, if present. SLAPI_CONTROLS_ARG • set to to add. SLAPI_ADD_ENTRY Slapi_Entry Returns This function returns or one of the LDAP error codes if the entry LDAP_SUCCESS cannot be constructed from the specified attributes due to constraint violation.
Page 196
Functions for Setting Internal Operation Flags Plug-in identity, a cookie that identifies the plug-in to the plugin_identity Directory Server during an internal operation. This cookie is used by the server to retrieve the plug-in configuration in order to determine whether to allow the operation and which actions to take during the operation processing.
Page 197
Functions for Setting Internal Operation Flags Parameter block populated with modify parameters. DN of the entry to be modified. For unique ID operation, this parameter is used to select the correct backend. Modifications to be applied to the entry. mods List of controls associated with the operation.
Page 198
Functions for Setting Internal Operation Flags slapi_rename_internal_set_pb() Sets up a parameter block so that it can be used by slapi_modrdn_internal_pb() for an internal rename operation. Syntax #include “slapi-plugin.h” void slapi_rename_internal_set_pb(Slapi_PBlock *pb, const char *olddn, const char *newrdn, const char *newsuperior, int deloldrdn, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags);...
Page 199
Functions for Setting Internal Operation Flags Description This function populates with parameters for use by pblock for an internal rename operation. The function sets slapi_modrdn_internal_pb() the parameter block to contain the following data. For unique ID-based operation: • set to the DN that allows to select the right backend. SLAPI_TARGET_DN •...
Page 200
Functions for Setting Internal Operation Flags Search scope (LDAP_SCOPE_SUBTREE, etc.). scope Search filter. filter Attributes to be returned. attrs Flag specifying whether to return just attribute names or names attrsonly and values. List of controls associated with the operation. controls Non-NULL value indicates Unique identifier of the entry.
Page 201
Functions for Setting Internal Operation Flags • set to the search filter. SLAPI_SEARCH_STRFILTER • set to request controls, if present. SLAPI_CONTROLS_ARG • set to the list of attributes to return. SLAPI_SEARCH_ATTRS • indicates whether attribute values should be SLAPI_SEARCH_ATTRSONLY returned. slapi_seq_internal_callback_pb() Performs internal sequential access operation.
Page 202
Functions for Setting Internal Operation Flags slapi_seq_internal_set_pb() Sets up a parameter block for use by for an slapi_seq_internal_callback_pb() internal, sequential-access operation. Syntax #include “slapi-plugin.h” void slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase, int type, char *attrname, char *val, char **attrs, int attrsonly, LDAPControl **controls, Slapi_ComponentId *plugin_identity, int operation_flags);...
Functions for Handling Attributes Functions for Handling Attributes This section contains reference information on attribute routines. Table 14-5 Attribute Routines Function Description slapi_attr_add_value() Adds a value to an attribute. slapi_attr_basetype() Returns the base type of an attribute. slapi_attr_dup() Duplicates an attribute. slapi_attr_first_value() Gets the first value of an attribute.
Page 204
Functions for Handling Attributes Attribute Routines (Continued) Table 14-5 Function Description slapi_valueset_set_valueset() Initializes a Slapi_ValueSet structure from another Slapi_ValueSet structure. slapi_attr_add_value() Adds a value to an attribute. Syntax #include “slapi-plugin.h” int slapi_attr_add_value(Slapi_Attr *a, const Slapi_Value *v); Parameters This function takes the following parameters: The attribute that will contain the values.
Page 205
Functions for Handling Attributes Syntax #include “slapi-plugin.h” char *slapi_attr_basetype( char *type, char *buf, size_t bufsiz ); Parameters This function takes the following parameters: Attribute type from which you want to get the base type. type Buffer to hold the returned base type. Size of the buffer.
Page 206
Functions for Handling Attributes Parameters This function takes the following parameters: The attribute to be duplicated. attr Returns This function returns the newly created copy of the attribute. Description Use this function to make a copy of an attribute. Memory Concerns You must free the returned attribute using slapi_attr_free() See Also...
Page 207
Functions for Handling Attributes Returns This function returns one of the following values: • 0, which is the index of the first value. • -1 if NULL, or if the value is not found. hint Description Use this function to get the first value of an attribute. This is part of a set of functions to enumerate over an structure.
Page 208
Functions for Handling Attributes Returns This function returns one of the following values: • 1 if the specified flag is set. • 0 if the specified flag is not set. Description This function determines if certain flags are set for a particular attribute. These flags can identify an attribute as a single-valued attribute, an operational attribute, or as a read-only attribute.
Page 209
Functions for Handling Attributes Syntax #include “slapi-plugin.h” int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals ); Parameters This function takes the following parameters: Attribute that contains the desired values. Pointer to an array of berval structure pointers to hold the vals desired values.
Page 210
Functions for Handling Attributes Attribute for which you want to get the flags. attr When you call slapi_attr_get_flags(), this parameter is set to a flags pointer to the flags of the specified attribute. Do not free the flags; the flags are part of the actual data in the attribute, not a copy of the data. To determine which flags have been set, you can bitwise AND the value of the argument with one or more of the following: flags...
Page 211
Functions for Handling Attributes Attribute containing the values to be counted. Integer to hold the counted values. numValues Returns This function always returns 0. Description This function counts the number of values in an attribute and places that count in an integer.
Page 212
Functions for Handling Attributes Description This function replaces the deprecated function, . Use this slapi_attr_get_oid function to search the syntaxes for an attribute type’s OID. Memory Concerns You should free this string using slapi_ch_free() slapi_attr_get_type() Gets the name of the attribute type from a specified attribute. Syntax #include “slapi-plugin.h”...
Page 213
Functions for Handling Attributes Syntax #include “slapi-plugin.h” int slapi_attr_get_valueset(const Slapi_Attr *a, Slapi_ValueSet **vs); Parameters This function takes the following parameters: Attribute containing the values to be placed into a valueset. Receives values from the first parameter. Returns This function always returns See Also slapi_entry_add_valueset() slapi_valueset_new()
Page 214
Functions for Handling Attributes The empty attribute to be initialized. Attribute type to be initialized. type Returns This function returns the newly-initialized attribute. Description Use this function to initialize an empty attribute with an attribute type. See Also slapi_attr_new() slapi_attr_free() slapi_attr_dup() slapi_attr_new() Creates a new attribute.
Page 215
Functions for Handling Attributes slapi_attr_next_value() Gets the next value of an attribute. Syntax #include “slapi-plugin.h” int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v ); Parameters This function takes the following parameters: Attribute contained the desired value. Index of the value to be returned. hint Holds the value of the attribute.
Page 216
Functions for Handling Attributes Syntax #include “slapi-plugin.h” int slapi_attr_set_valueset(Slapi_Attr *a, const Slapi_ValueSet *vs); Parameters This function takes the following parameters: Pointer to the Slapi_Attr structure, the value set of which you wish to set. Pointer to the Slapi_ValueSet structure from which you want to extract the values.
Page 217
Functions for Handling Attributes Returns This function returns the copy of the desired normalized attribute, or a normalized copy of what was passed in. Description Use this function to search the syntaxes for an attribute type and return its normalized form. Memory Concerns You should free the returned string using slapi_ch_free()
Page 218
Functions for Handling Attributes See Also slapi_attr_get_type() slapi_attr_type_cmp() slapi_attr_types_equivalent() slapi_attr_basetype() slapi_attr_type_cmp() Compares two attribute types to determine if they are the same. Syntax #include “slapi-plugin.h” int slapi_attr_type_cmp( char *t1, char *t2, int opt ); Parameters This function takes the following parameters: Name of the first attribute type that you want to compare.
Page 219
Functions for Handling Attributes slapi_attr_get_type() slapi_attr_types_equivalent() slapi_attr_basetype() slapi_attr_types_equivalent() Compares two attribute names to determine if they represent the same attribute. Syntax #include “slapi-plugin.h” int slapi_attr_types_equivalent( const char *t1, const char *t2 ); Parameters This function takes the following parameters: Pointer to the first attribute type that you want to compare. Pointer to the second attributed type that you want to compare.
Page 220
Functions for Handling Attributes Syntax #include “slapi-plugin.h” int slapi_attr_value_cmp( Slapi_Attr *attr, struct berval *v1, struct berval *v2 ); Parameters This function takes the following parameters: Attribute used to determine how these values are compared (for attr example, if the attribute contains case-insensitive strings, the strings are compared without regard to case).
Page 221
Functions for Handling Attributes Parameters This function takes the following parameters: Attribute that you want to check. Pointer to the berval structure containing the value that you want to search for. Returns This function returns one of the following values: •...
Functions for Managing Backend Operations Description Use this function to create a valueset that contains the changes from smod See Also slapi_mods_init() slapi_mods_free() slapi_mods_done() Functions for Managing Backend Operations This section contains reference information on routines that help you deal with backends.
Page 223
Functions for Managing Backend Operations Backend Routines (Continued) Table 14-6 Function Description slapi_be_private() Verifies if the backend is private. slapi_be_select() Finds the backend that should be used to service the entry with the specified DN. slapi_be_select_by_instance_name() Find the backend used to service the database. slapi_be_set_flag() Sets the specified flag in the backend.
Page 224
Functions for Managing Backend Operations slapi_be_delete_onexit() Sets the flag to denote that the backend will be deleted on exiting. Syntax #include “slapi-plugin.h” void slapi_be_delete_onexit(Slapi_Backend *be); Parameters This function takes the following parameter: Pointer to the structure containing the backend configuration. slapi_be_exist() Checks if the backend that contains the specified DN exists.
Page 225
Functions for Managing Backend Operations Syntax #include “slapi-plugin.h” void slapi_be_free(Slapi_Backend **be); Parameters This function takes the following parameter: Pointer to the structure containing the backend configuration. slapi_be_get_instance_info() Gets the instance information of the specified backend. Syntax #include “slapi-plugin.h” void * slapi_be_get_instance_info(Slapi_Backend * be); Parameters This function takes the following parameter: Pointer to the structure containing the backend configuration.
Page 226
Functions for Managing Backend Operations Returns This function returns the name associated to the specified backend. Memory Concerns You should not free the returned pointer. slapi_be_get_readonly() Indicates if the database associated with the backend is in read-only mode. Syntax #include “slapi-plugin.h” int slapi_be_get_readonly(Slapi_Backend *be);...
Page 227
Functions for Managing Backend Operations Entry point in the backend. entrypoint Opaque pointer to store function address. ret_fnptr Pointer to the parameter block. Returns This function returns 0 if successful, -1 otherwise. slapi_be_getsuffix() Returns the +1 suffix associated with the specified backend. Syntax #include “slapi-plugin.h”...
Page 228
Functions for Managing Backend Operations slapi_be_gettype() Returns the type of the backend. Syntax #include “slapi-plugin.h” const char * slapi_be_gettype(Slapi_Backend *be);; Parameters This function takes the following parameter: Pointer to the structure containing the backend configuration. Returns This function returns the type of the backend. Memory Concerns You should not free the returned pointer.
Page 229
Functions for Managing Backend Operations • 1 if a flag is set in the backend configuration. slapi_be_issuffix() Verifies that the specified suffix matches a registered backend suffix. Syntax #include “slapi-plugin.h” int slapi_be_issuffix(const Slapi_Backend *be, const Slapi_DN *suffix ); Parameters This function takes the following parameters: Pointer to the structure containing the backend configuration.
Page 230
Functions for Managing Backend Operations Pointer to the structure containing the backend configuration. Returns This function returns one of the following values: • 0 if the changes applied to the specific backend should not be logged in the changelog. • 1 if the changes should be logged in the changelog.
Page 231
Functions for Managing Backend Operations Syntax #include “slapi-plugin.h” int slapi_be_private( Slapi_Backend *be ); Parameters This function takes the following parameter: Pointer to the structure containing the backend configuration. Returns This function returns one of the following values: • 0 if the backend is not hidden from the user. •...
Page 232
Functions for Managing Backend Operations See Also slapi_be_select_by_instance_name() slapi_be_select_by_instance_name() Find the backend used to service the database. Syntax #include “slapi-plugin.h” Slapi_Backend *slapi_be_select_by_instance_name( const char *name ); Parameters This function takes the following parameter: Pointer to the name of the backend of which you wish to get the name structure.
Page 233
Functions for Managing Backend Operations Syntax #include “slapi-plugin.h” void slapi_be_set_flag(Slapi_Backend * be, int flag); Parameters This function takes the following parameters: Pointer to the structure containing the backend configuration. Flag (bitmap) that needs to be set. flag slapi_be_set_instance_info() Sets the instance information of the specified backend with given data. Syntax #include “slapi-plugin.h”...
Page 234
Functions for Managing Backend Operations slapi_be_setentrypoint() Sets the entry point in the backend to the specified function. Syntax #include “slapi-plugin.h” int slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi_PBlock *pb); Parameters This function takes the following parameters: Pointer to the structure containing the backend configuration. Entry point in the backend.
Page 235
Functions for Managing Backend Operations Returns This function returns one of the following values: • A pointer to the backend structure of the first backend, and its index, in the parameter cookie • if there is no backend. NULL Description This function returns a pointer to the backend structure of the first backend.
Page 236
Functions for Managing Backend Operations 0 checks only for non-private suffixes. show_private 1 checks for both private and non-private suffixes. Returns This function returns the DN of the first root suffix. Description This function returns the first root suffix of the DIT. If you wish to iterate through all of the suffixes, use this function in conjunction with .
Page 237
Functions for Managing Backend Operations Returns This function returns one of the following values: • A pointer to the next backend, if it exists, and updates the parameter. cookie • Otherwise, it returns is not changed. NULL cookie Description This function returns a pointer to the next backend. If you wish to iterate through all of the backends, use this function in conjunction with .
Page 238
Functions for Managing Backend Operations Contains the returned valued, which is the DN of the next root node suffix of the DIT. Returns This function returns one of the following values: • The DN of the next root suffix of the DIT. •...
Functions for Dealing with Controls Returns This function returns one of the following values: • 0 if the DN is not a root suffix. • 1 if the DN is a root suffix. Functions for Dealing with Controls This section contains reference information on routines for dealing with controls. Table 14-7 Routines for Dealing with Controls Function...
Page 240
Functions for Dealing with Controls Parameters This function takes the following parameters: The OID (object identifier) for the control that is to be created. A BerElement that contains the control value. Pass NULL if the control has no value. The criticality flag. If non-zero, the control will be marked as iscritical critical.
Page 241
Functions for Dealing with Controls Syntax #include “slapi-plugin.h” int slapi_build_control_from_berval( char *oid, struct berval *bvp,char iscritical, LDAPControl **ctrlp ); Parameters This function takes the following parameters: The OID (object identifier) for the control that is to be created. A struct berval that contains the control value. Pass NULL if the control has no value.
Page 242
Functions for Dealing with Controls slapi_control_present() Determines whether or not the specified object identification (OID) identifies a control that is present in a list of controls. Syntax #include “slapi-plugin.h” int slapi_control_present( LDAPControl **controls, char *oid, struct berval **val, int *iscritical ); Parameters This function takes the following parameters: List of controls that you want to check.
Page 243
Functions for Dealing with Controls slapi_dup_control() Makes an allocated copy of an LDAPControl Syntax #include “slapi-plugin.h” LDAPControl * slapi_dup_control( LDAPControl *ctrl ) Parameters This function takes the following parameter: Pointer to an LDAPControl structure whose contents are to be ctrl duplicated.
Page 244
Functions for Dealing with Controls Syntax #include “slapi-plugin.h” int slapi_get_supported_controls_copy( char ***ctrloidsp, unsigned long **ctrlopsp ); Parameters This function takes the following parameters: Pointer to a character array that will receive the set of supported ctrloidsp control OIDs. Pass NULL for this parameter if you do not wish to receive the OIDs.
Page 245
Functions for Dealing with Controls See Also slapi_register_supported_control() slapi_ch_array_free() slapi_register_supported_control() Registers the specified control with the server. This function associates the control with an object identification (OID). When the server receives a request that specifies this OID, the server makes use of this information to determine if the control is supported by the server or its plug-ins.
Functions for Syntax Plug-In The specified control applies to the LDAP compare SLAPI_OPERATION_COMPARE operation. The specified control applies to the LDAP abandon SLAPI_OPERATION_ABANDON operation. The specified control applies to the LDAPv3 SLAPI_OPERATION_EXTENDED extended operation. The specified control applies to any LDAP operation. SLAPI_OPERATION_ANY The specified control applies to none of the LDAP SLAPI_OPERATION_NONE...
Page 247
Functions for Syntax Plug-In slapi_call_syntax_assertion2keys_ava_sv() When processing a search, calls the function (defined in the specified syntax plug-in) responsible for returning an array of values (specified by the search filter) to compare against the entries in the directory. This function applies to searches that use the filter types LDAP_FILTER_EQUALITY LDAP_FILTER_APPROX Syntax...
Page 248
Functions for Syntax Plug-In The function invokes the syntax plug-in specified by the argument. (This is the plug-in associated with the type of attribute used in the search. You can get this handle by calling the function.) slapi_attr_type2plugin() The syntax plug-in function invoked by this function is responsible for comparing the value specified by against the actual values of the attributes in the directory entries.
Page 249
Functions for Syntax Plug-In Returns This function returns one of the following values: • if successful. • if an error occurs; for example, if the corresponding function for the specified plug-in is not found. Description backend (the default backend database) calls this function when ldbm processing searches in which the filter type is LDAP_FILTER_SUBSTRINGS...
Functions for Managing Memory Returns This function returns one of the following values: • if successful. • if an error occurs (for example, if the corresponding function for the specified plug-in is not found). Description When adding or removing values from an index, the Directory Server calls the function (defined in the specified syntax plug-in) responsible for returning an array of keys matching the specified values.
Page 251
Functions for Managing Memory Syntax #include “slapi-plugin.h” void slapi_ch_array_free( char **arrayp ); Parameters This function takes the following parameter: Pointer to the array to be freed. This parameter can be NULL. arrayp Description This function frees the pointed to by char ** arrayp slapi_ch_bvdup()
Page 252
Functions for Managing Memory ber_bvfree() slapi_ch_bvecdup() Makes a copy of an array of existing structures. berval Syntax #include “slapi-plugin.h” extern struct berval** slapi_ch_bvecdup (const struct berval **v); Parameters This function takes the following parameters: Pointer to the array of berval structures that you want to copy. Returns This function returns a pointer to an array of the new copy of the berval...
Page 253
Functions for Managing Memory Parameters This function takes the following parameters: Number of elements for which you want to allocate memory. nelem Size, in bytes, of the element for which you want to allocate size memory. Returns This function returns a pointer to the newly allocated space of memory. If space cannot be allocated, for example, if no more virtual memory exists, the slapd program terminates.
Page 254
Functions for Managing Memory Parameters This function takes the following parameters: Address of the pointer to the block of memory that you want to free. If NULL, no action occurs. Memory Concerns passed to should be the address of a pointer that was slapi_ch_free() allocated using a call such as...
Page 255
Functions for Managing Memory slapi_ch_malloc() Allocates space in memory. Syntax #include “slapi-plugin.h” char * slapi_ch_malloc( unsigned long size ); Parameters This function takes the following parameters: Size of the space that you want to allocate memory for. size Returns This function returns a pointer to the newly allocated space of memory. If space cannot be allocated, for example, if no more virtual memory exists, the slapd program terminates.
Page 256
Functions for Managing Memory Parameters This function takes the following parameters: Pointer to an existing block of allocated memory. block New size of the block of memory you want allocated. size Returns This function returns a pointer to the reallocated space of memory. If space cannot be allocated, for example, if no more virtual memory exists, the program slapd...
Functions for Managing DNs Returns This function returns a pointer to a copy of the string. If space cannot be allocated, for example, if no more virtual memory exists, the program terminates. slapd Memory Concerns This function terminates the server with an “out of memory” error message slapd if memory cannot be allocated.
Page 258
Functions for Managing DNs slapi_dn_beparent() Gets a copy of the distinguished name (DN) of the parent of an entry, unless the specified entry’s DN is the suffix of the local database. If you don’t want to check if the entry’s DN is the suffix of the local database, call function instead.
Page 259
Functions for Managing DNs Parameters This function takes the following parameters: DN that you want to convert to lowercase. Returns The DN with lowercase characters. Note that variable passed in as the argument is also converted in-place. See Also slapi_dn_normalize() slapi_dn_isbesuffix() Determines whether or not the specified distinguished name (DN) is the suffix of the local database.
Page 260
Functions for Managing DNs slapi_dn_isparent() Determines whether or not a particular DN is the parent of another specified DN. Before calling this function, you should call slapi_dn_normalize_case() normalize the DNs and convert all characters to lowercase. Syntax #include “slapi-plugin.h” int slapi_dn_isparent( const char *parentdn, char *childdn ); Parameters This function takes the following parameters: Determine if this DN is the parent of childdn.
Page 261
Functions for Managing DNs DN that you want to check. Returns This function returns one of the following values: • 1 if the specified DN is the root DN of the local database. • 0 if the specified DN is not the root DN of the local database. See Also slapi_dn_isbesuffix() slapi_dn_issuffix()
Page 262
Functions for Managing DNs slapi_dn_normalize() Convert a distinguished name (DN) to canonical format (no leading or trailing spaces, no spaces between components, and no spaces around the equals sign). For example, given the following DN: cn = Moxie Cross , ou = Engineering , o = Example the function returns: cn=Moxie Cross,ou=Engineering,o=Example Syntax...
Page 263
Functions for Managing DNs Parameters This function takes the following parameters: DN that you want to normalize and convert to lowercase. Returns This function returns the normalized DN with all lowercase characters. Note that variable passed in as the argument is also converted in place. See Also slapi_dn_normalize() slapi_dn_ignore_case()
Page 264
Functions for Managing DNs Returns This function returns a pointer to the end of the that has been normalized. For example, if the RDN is and the DN is , the new DN will cn=Jane c=US,o=example cn=Jane,c=US,0=example See Also slapi_dn_normalize() slapi_dn_parent() Gets a copy of the distinguished name (DN) of the parent of an entry.
Functions for Managing Entries Syntax #include “slapi-plugin.h” char *slapi_dn_plus_rdn( const char *dn, const char *rdn); Parameters This function takes the following parameters: DN value to which a new RDN is to be added. RDN value that is to be added to the DN value in dn. Returns This function returns the new DN formed by adding the RDN value in to the...
Page 266
Functions for Managing Entries Table 14-11 Entry Routines (Continued) Function Description slapi_entry_attr_get_charptr() Gets the first value as a string. slapi_entry_attr_get_charray() Gets the values of a multi-valued attribute of an entry. slapi_entry_attr_get_int() Gets the first value as an integer. slapi_entry_attr_get_long() Gets the first value as a long. slapi_entry_attr_get_uint() Gets the first value as an unsigned integer.
Page 267
Functions for Managing Entries Table 14-11 Entry Routines (Continued) Function Description slapi_entry_next_attr() Finds the next attribute in an entry. slapi_entry_rdn_values_present() Checks if values present in an entry’s RDN are also present as attribute values. slapi_entry_schema_check() Determines if an entry complies with the schema for its object class. slapi_entry_set_dn() Sets the DN of an entry.
Page 268
Functions for Managing Entries Description This function generates an LDIF string value conforming to the following format: dn: <dn>\n [<attr>: <value>\n]* For example: dn: uid=jdoe, ou=People, o=example.com cn: Jane Doe sn: Doe To convert a string description in LDIF format to an entry of the data Slapi_Entry type, call the...
Page 269
Functions for Managing Entries The Options Parameter You can together any of the following options when you call this function: Flag Value Description This is only used internally by replication. This SLAPI_DUMP_STATEINFO allows access to the internal data used by multi-master replication.
Page 270
Functions for Managing Entries Memory Concerns When you no longer need to use the string, you should free it from memory by calling the function. slapi_ch_free() See Also slapi_entry2str() slapi_str2entry() slapi_entry_add_rdn_values() Adds the components in an entry’s relative distinguished name (RDN) to the entry as attribute values.
Page 271
Functions for Managing Entries slapi_entry_add_string() Adds a string value to an attribute in an entry. Syntax #include “slapi-plugin.h” int slapi_entry_add_string (Slapi_Entry *e, const char *type, const char *value); Parameters This function takes the following parameters: Entry to which you want to add a string value. Attribute to which you want to add a string value.
Page 272
Functions for Managing Entries Parameters This function takes the following parameters: Entry to which you want to add a value. Attribute to which you want to add a value. type The Slapi_value data value you want to add to the entry. value Returns This function returns...
Page 273
Functions for Managing Entries Returns This function returns one of the following values: • if the array is successfully added to the attribute. LDAP_SUCCESS Slapi_Value • if any values you are trying to add duplicate an LDAP_TYPE_OR_VALUE_EXISTS existing value in the attribute. •...
Page 274
Functions for Managing Entries Returns This function returns when successful; any other value returned signals failure. Description This function adds a set of values to an attribute in an entry. The values added are in the form of a data type. If the entry does not contain the Slapi_ValueSet attribute specified, it is created with the specified value.
Page 275
Functions for Managing Entries slapi_entry_attr_delete() Deletes an attribute (and all its associated values) from an entry. Syntax #include “slapi-plugin.h” int slapi_entry_attr_delete( Slapi_Entry *e, char *type ); Parameters This function takes the following parameters: Entry from which you want to delete the attribute. Attribute type that you want to delete.
Page 276
Functions for Managing Entries Returns This function returns one of the following values: • if the entry contains the specified attribute. • if the entry does not contain the specified attribute. Memory Concerns Do not free the returned . It is a pointer to the internal entry data structure. It attr is usually wise to make a copy of the returned , using...
Page 277
Functions for Managing Entries slapi_entry_attr_get_charray() Gets the values of a multi-valued attribute of an entry. Syntax #include “slapi-plugin.h” char ** slapi_entry_attr_get_charray( const Slapi_Entry* e, const char *type); Parameters This function takes the following parameters: Entry from which you want to get the values. Attribute type from which you want to get the values.
Page 278
Functions for Managing Entries See Also slapi_entry_attr_get_charptr() slapi_entry_attr_get_int() Gets the first value of an attribute in an entry as an integer. Syntax #include “slapi-plugin.h” int slapi_entry_attr_get_int(const Slapi_Entry* e, char *type); Parameters This function takes the following parameters: Entry from which you want to get the integer value. Attribute type from which you want to get the value.
Page 279
Functions for Managing Entries Returns This function returns one of the following values: • The first value in the attribute converted to a type. long • if the entry does not contain the attribute specified. slapi_entry_attr_get_uint() Gets the first value of an attribute in an entry as a unsigned integer data type. Syntax #include “slapi-plugin.h”...
Page 280
Functions for Managing Entries Parameters This function takes the following parameters: Entry from which you want to get the value. Attribute type from which you want to get the value. type Returns This function returns one of the following values: •...
Page 281
Functions for Managing Entries Description This function replaces the deprecated ) function slapi_entry_attr_hasvalue( and takes into consideration the syntax of the attribute type. slapi_entry_attr_merge_sv() Adds an array of data values to the existing attribute values in an Slapi_Value entry. If the attribute does not exist, it is created with the specified.
Page 282
Functions for Managing Entries Syntax #include “slapi-plugin.h” int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); Parameters This function takes the following parameters: Entry in which you want to replace values. Attribute type which will receive the replaced values. type Array containing the Slapi_Value values that should replace vals...
Page 283
Functions for Managing Entries Parameters This function takes the following parameters: Entry in which you want to set the value. Attribute type in which you want to set the value. type String value that you want to assign to the attribute. value Memory Concerns This function makes a copy of the parameter...
Page 284
Functions for Managing Entries slapi_entry_attr_set_long() Replaces the value or values of an attribute in an entry with a specified long data type value. Syntax #include “slapi-plugin.h” void slapi_entry_attr_set_long(Slapi_Entry* e, char *type, unsigned long l); Parameters This function takes the following parameters: Entry in which you want to set the value.
Page 285
Functions for Managing Entries Description This function will replace the value or values of an attribute with the unsigned value that you specify. If the attribute does not exist, it is created with the integer unsigned integer value you specify. slapi_entry_attr_set_ulong() Replaces the value or values of an attribute in an entry with a specified unsigned long data type value.
Page 286
Functions for Managing Entries Parameters This function takes the following parameters: Entry from which you want the string deleted. Attribute type from which you want the string deleted. type Value of string to delete. value Returns This function returns when successful; any other value returned signals failure. slapi_entry_delete_values_sv() Removes an array of data values from an attribute in an entry.
Page 287
Functions for Managing Entries If there is an operational error during the processing of this call (such as a duplicate value found), the function will return . If this occurs, LDAP_OPERATIONS_ERROR please report the problem to the Netscape Technical Support. Description This function removes an attribute/value set from an entry.
Page 288
Functions for Managing Entries Description This function returns a copy of an existing structure. You can call Slapi_Entry other front-end functions to change the DN and attributes of this entry. Memory Concerns When you are no longer using the entry, free it from memory by calling the function.
Page 289
Functions for Managing Entries slapi_entry_free() Frees an entry, its DN, and its attributes from memory. Syntax #include “slapi-plugin.h” void slapi_entry_free( Slapi_Entry *e ); Parameters This function takes the following parameter: Entry that you want to free. If NULL, no action occurs. Description Call this function to free an entry that you have allocated by using the function or the...
Page 290
Functions for Managing Entries Returns This function returns the DN of the entry. Note that this returns a pointer to the actual DN in the entry, not a copy of the DN. You should not free the DN unless you plan to replace it by calling slapi_entry_set_dn() Memory Concerns if you are replacing the DN with...
Page 291
Functions for Managing Entries slapi_entry_get_ndn() Returns the normalized from the entry that you specify. Syntax #include “slapi-plugin.h” char *slapi_entry_get_ndn( Slapi_Entry *e ); Parameters This function takes the following parameter: Entry from which you want to obtain the normalized DN. Returns This function returns the normalized from the entry that you specify.
Page 292
Functions for Managing Entries Memory Concerns Never free this value. If you need a copy, use slapi_sdn_dup() See Also slapi_sdn_dup() slapi_entry_get_sdn_const() Returns as a the value of the object from the entry that you const Slapi_DN specify. Syntax #include “slapi-plugin.h” const Slapi_DN *slapi_entry_get_sdn_const ( const Slapi_Entry *e );...
Page 293
Functions for Managing Entries Parameters This function takes the following parameter: Entry from which you want obtain the unique ID. Returns This function returns the unique ID value of the entry specified. Memory Concerns Never free this value. If you need a copy, use slapi_ch_strdup() See Also slapi_ch_strdup()
Page 294
Functions for Managing Entries Syntax #include “slapi-plugin.h” void slapi_entry_init(Slapi_Entry *e, char *dn, Slapi_Attr *a); Parameters This function takes the following parameters: The entry you want to initialize. The DN of the entry you are initializing. Initialization list of attribute value pairs, supplied as a Slapi_Attr data value.
Page 295
Functions for Managing Entries See Also slapi_entry_free() slapi_entry_alloc() slapi_ch_strdup() slapi_entry_merge_values_sv() Merges (adds) and array of data values to a specified attribute in an Slapi_Value entry. If the entry does not contain the attribute specified, the attribute is created with the value supplied. Syntax #include “slapi-plugin.h”...
Page 296
Functions for Managing Entries Note that if this function fails, it leaves the values for within a pointer to type an indeterminate state. The present value set may be truncated. rc = delete_values_sv_internal( e, type, vals, 1 /* Ignore Errors */ ); Memory Concerns This function makes a copy of can be...
Page 297
Functions for Managing Entries slapi_entry_rdn_values_present() Determines whether or not the values in an entry’s relative distinguished name (RDN) are also present as attribute values. (For example, if the entry’s RDN is , the function determines if the entry has the attribute with cn=Barbara Jensen the value...
Page 298
Functions for Managing Entries Returns The function returns one of the following values: • if the entry complies with the schema or if schema checking is turned off. The function also returns if the entry has additional attributes not allowed by the schema and has the object class extensibleObject •...
Page 299
Functions for Managing Entries A copy of should be passed, for example: char *dn = slapi_ch_strdup(some_dn): slapi_entry_set_dn(e, dn); The old will be freed as a result of this call. Do not pass in a value. NULL See Also slapi_entry_free() slapi_entry_get_dn() slapi_entry_set_sdn() Sets the value in an entry.
Page 300
Functions for Managing Entries Syntax #include “slapi-plugin.h” void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ); Parameters This function takes the following parameters: Entry for which you want to generate a description. The unique ID value to which you want to assign the entry. uniqueid Description This function replaces the unique ID value of the entry with the...
Page 301
Functions for Managing Entries Parameters This function takes the following parameter: Entry from which you want the size returned. Returns This function returns one of the following values: • The size of the entry, rounded to the nearest 1k. The value returned is a size_t data type, with is a value.
Page 302
Functions for Managing Entries Returns This function returns one of the following values: • is the root DSE. • is not the root DSE. slapi_str2entry() Converts an LDIF description of a directory entry (a string value) into an entry of type.
Functions Related to Entry Flags Description A directory entry can be described by a string in LDIF format (for details, see “Converting Between Entries and Strings” on page 61). function converts a string description in this Calling the slapi_str2entry() format to a structure, which you can pass to other API functions.
Page 304
Functions Related to Entry Flags Syntax #include “slapi-plugin.h” void slapi_entry_clear_flag( Slapi_Entry *e, unsigned char flag); Parameters This function takes the following parameters: Entry in which you want to clear the flag settings. Flag that you want to clear. flag Description In this release of Directory Server, the only external flag that can be set is .
Page 305
Functions Related to Entry Flags • 0 if the flag is not set. • The value of the flag if it is set. Description In this release of Directory Server, the only external flag that can be set is . This flag means that the entry is a tombstone SLAPI_ENTRY_FLAG_TOMBSTONE entry.
Functions for Dealing with Filters Functions for Dealing with Filters This section contains reference information on filter routines. Table 14-13 Filter Routines Function Description slapi_filter_apply() Applies a function to each simple filter component within a complex filter. slapi_filter_compare() Determines if two filters are identical. slapi_filter_dup() Duplicates the specified filter.
Page 307
Functions for Dealing with Filters Syntax #include “slapi-plugin.h” int slapi_filter_apply( struct slapi_filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code ); Parameters This function takes the following parameters: Filter on which the function is to be applied. Function to apply. Argument to the function (fn). Pointer to error code of , which can be accessed by error_code...
Page 308
Functions for Dealing with Filters Parameters This function takes the following parameters: First filter to compare. Second filter to compare. Returns This function returns one of the following values: • 0 if the two filters are identical. • A value other than 0 if the two filters are not identical. Description This function allows you to determine if two filters are identical, and/or are allowed to be in a different order.
Page 309
Functions for Dealing with Filters slapi_filter_free() Frees the specified filter and (optionally) the set of filters that comprise it (for example, the set of filters in an type filter). LDAP_FILTER_AND Syntax #include “slapi-plugin.h” void slapi_filter_free( Slapi_Filter *f, int recurse ); Parameters This function takes the following parameters: Filter that you want to free.
Page 310
Functions for Dealing with Filters Parameters This function takes the following parameters: Filter from which you wish to get the substring values. Pointer to the attribute type of the filter. type Returns This function returns the attribute type of the filter. Description This function gets the attribute type for all simple filter choices: •...
Page 311
Functions for Dealing with Filters slapi_filter_get_ava() (Applies only to filters of the types LDAP_FILTER_EQUALITY LDAP_FILTER_GE ) Gets the attribute type and the value LDAP_FILTER_LE LDAP_FILTER_APPROX from the filter. Syntax #include “slapi-plugin.h” int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval ); Parameters This function takes the following parameters: Filter that you want to get the attribute and value from.
Page 312
Functions for Dealing with Filters Memory Concerns The strings within the parameters are direct pointers to memory type bval inside the , and therefore should not be freed after usage. They will Slapi_Filter be freed when a server entity calls after usage of the slapi_filter_free() structure.
Page 313
Functions for Dealing with Filters • (substring filter) LDAP_FILTER_SUBSTRINGS For example: (ou=Account*Department) • (“greater than or equal to” filter) LDAP_FILTER_GE For example: (supportedLDAPVersion>=3) • (“less than or equal to” filter) LDAP_FILTER_LE For example: (supportedLDAPVersion<=2) • (presence filter) LDAP_FILTER_PRESENT For example: (mail=*) •...
Page 314
Functions for Dealing with Filters Pointer to the initial substring (“starts with”) of the filter. initial Pointer to an array of the substrings (“contains”) for the filter. Pointer to the final substring (“ends with”) of the filter. final Returns This function returns one of the following values: •...
Page 315
Functions for Dealing with Filters Parameters This function takes the following parameters: Filter that you want to get the substring values from. Pointer to the attribute type of the filter. type Returns This function returns one of the following values: •...
Page 316
Functions for Dealing with Filters Syntax #include “slapi-plugin.h” Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2 ); Parameters This function takes the following parameters: Type of composite filter you want to create. ftype First filter that you want to join. Second filter that you want to join.
Page 317
Functions for Dealing with Filters Syntax #include “slapi-plugin.h” Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f ); Parameters This function takes the following parameters: Filter that you want to get the first component of. Returns This function returns the first filter that makes up the specified filter Description To iterate through all filters that make up a specified filter, use this function in conjunction with the...
Page 318
Functions for Dealing with Filters Syntax #include “slapi-plugin.h” Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev ); Parameters This function takes the following parameters: Filter from which you want to get the next component (after fprev). Filter within the specified filter f. fprev Returns This function returns the next filter (after...
Page 319
Functions for Dealing with Filters Syntax #include “slapi-plugin.h” int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, int verify_access ); Parameters This function takes the following parameters: Parameter block. Entry that you want to test. Filter that you want to test the entry against. If 1, verifies that the current user has access rights to search the verify_access specified entry.
Page 320
Functions for Dealing with Filters Parameters This function takes the following parameters: pblock from which the user is extracted. The entry on which filter matching must be verified. The filter used for filter matching. 0 when access checking is not to be done. verify_access 1 when access checking must be done.
Page 321
Functions for Dealing with Filters Parameters This function takes the following parameters: Entry that you wish to test. Filter to match the entry against. Returns This function returns one of the following values: • 0 if the entry matched the filter, or if the specified filter is NULL. •...
Page 322
Functions for Dealing with Filters Returns This function returns a pointer to the matching right parenthesis in the specified string. slapi_str2filter() Converts a string description of a search filter into a filter of the Slapi_Filter type. Syntax #include “slapi-plugin.h” Slapi_Filter *slapi_str2filter( char *str ); Parameters This function takes the following parameters: String description of a search filter.
Page 323
Functions for Dealing with Filters Parameters This function takes the following parameters: Parameter block containing information about the filter. Entry against which the filter is to be tested. Filter against which the entry is to be tested. Access control: verify_access •...
Functions Specific to Extended Operation Functions Specific to Extended Operation This section contains reference information on routines for dealing with extended operations. Table 14-14 Extended Operation Routines Function Description slapi_get_supported_extended_ops_copy() Gets a copy of the object IDs (OIDs) of the extended operations.
Functions Specific to Bind Methods slapi_ch_array_free() Functions Specific to Bind Methods This section contains reference information on bind routines, including SASL. Table 14-15 Bind Routines Function Description slapi_get_supported_saslmechanisms_copy() Gets an array of the names of the supported Simple Authentication and Security Layer (SASL) methods. slapi_register_supported_saslmechanism() Registers the specified Simple Authentication and Security Layer (SASL) method with the server.
Functions for Thread-Safe LDAP Connections Parameters This function takes the following parameters: Name of the SASL mechanism. mechanism See Also “Functions for Managing DNs,” on page 405. Functions for Thread-Safe LDAP Connections This section contains reference information on functions for thread-safe LDAP connections.
Page 327
Functions for Thread-Safe LDAP Connections Parameters This function takes the following parameters: Space-delimited list of one or more host names (or IP address in ldaphost dotted notation, such as "141.211.83.36") of the LDAP servers that you want to connect to. The names can be in hostname:portnumber format (in which case, portnumber overrides the port number specified by the ldapport argument).
Page 328
Functions for Thread-Safe LDAP Connections If you specify a non-zero value for the argument, this function installs the shared server’s threading functions and allows multiple threads to share this session (the returned structure). Note that the Directory Server processes each request in LDAP a separate thread.
Functions for Logging Syntax #include “slapi-plugin.h” void slapi_ldap_unbind( LDAP *ld ); Parameters This function takes the following parameters: Connection handle, which is a pointer to an LDAP structure containing information about the connection to the LDAP server. Description This function unbinds from another LDAP server. Call this function if you initialized the LDAP session with the function.
Page 330
Functions for Logging Parameters This function takes the following parameters: Level of severity of the message. In combination with the severity severity level specified by the administrator, this determines whether or not the message is written to the log. Name of the subsystem in which this function is called. The subsystem string that you specify here appears in the error log in the following format:...
Page 331
Functions for Logging Written to the error log if the Log Level setting “Config file SLAPI_LOG_CONFIG processing” is selected. Written to the error log if the Log Level setting “Access SLAPI_LOG_ACL control list processing” is selected. Written to the error log if the Log Level setting “Log SLAPI_LOG_SHELL communications with shell back-ends”...
Functions for Handling Matching Rules Returns The function returns one of the following values: • 0 if is not selected as log level settings. loglevel • 1 if is selected as log level setting. loglevel Description To specify the level of logging used by the Directory Server, the administrator can use the Server Console, or set the attribute.
Page 333
Functions for Handling Matching Rules Syntax #include “slapi-plugin.h” int slapi_berval_cmp (const struct berval *L, const struct berval *R); Parameters This function takes the following parameters: Pointer to the first berval structure that you want to compare. Pointer to the second structure that you want to compare. Returns This function returns one of the following values: •...
Page 334
Functions for Handling Matching Rules Description This function frees a structure (and, optionally, its Slapi_MatchingRuleEntry members) from memory. Call this function when you are done working with the structure. slapi_matchingrule_get() Gets information about a matching rule. Syntax #include “slapi-plugin.h” int slapi_matchingrule_get(SlPi_MatchingRuleEntry *mr, int arg, void *value);...
Page 335
Functions for Handling Matching Rules Returns This function returns one of the following values: • 0 if the information was successfully retrieved. • -1 if an error occurred (for example, if an invalid argument was specified). Description This function gets information about a matching rule from the structure.
Page 336
Functions for Handling Matching Rules Parameters This function takes the following parameters: Slapi_MatchingRuleEntry structure representing the mrEntry matching rule that you want to register. Returns This function returns one of the following values: • 0 if the matching rule was successfully registered. •...
Page 337
Functions for Handling Matching Rules argument can have one of the following values: Data Type Description of the value Argument Name of the matching rule. SLAPI_MATCHINGRULE_NAME char * OID of the matching rule. SLAPI_MATCHINGRULE_OID char * Description of the matching rule. SLAPI_MATCHINGRULE_DESC char * Syntax supported by the matching...
Page 338
Functions for Handling Matching Rules Parameters This function takes the following parameters: Pointer to a Slapi_Filter structure, representing the extensible match filter for which you want to find the indexer function. Parameter block containing information about the extensible match filter. Returns This function returns the result code returned by the indexer function.
Page 339
Functions for Handling Matching Rules Parameters This function takes the following parameters: Parameter block containing information about the matching rule and attribute type to be used in indexing or sorting. Returns This function returns the result code returned by the indexer factory function. Description This function calls the indexer factory function for the plug-in responsible for handing a specified matching rule.
Functions for LDAPMod Manipulation • should specify the name of the function SLAPI_PLUGIN_DESTROY_FN responsible for freeing any memory allocated by this indexer factory function (for example, memory allocated for a structure that you pass to the indexer function using SLAPI_PLUGIN_OBJECT For more information on filter index functions and indexer functions, see Chapter 11, “Writing Matching Rule Plug-Ins.”...
Page 341
Functions for LDAPMod Manipulation Table 14-19 LDAPMod Manipulation Routines (Continued) Description Function slapi_mod_new() Allocates a new Slapi_Mod structure. slapi_mod_remove_value() Removes the value at the current Slapi_Mod iterator position. slapi_mod_set_operation() Sets the operation type of a Slapi_Mod structure. slapi_mod_set_type() Sets the attribute type of a Slapi_Mod. slapi_mods2entry() Creates a Slapi_Entry from an array of LDAPMod.
Page 342
Functions for LDAPMod Manipulation Table 14-19 LDAPMod Manipulation Routines (Continued) Description Function slapi_mods_insert_after() Inserts an LDAPMod into a Slapi_Mods structure after the current iterator position. slapi_mods_insert_at() Inserts an LDAPMod anywhere in a Slapi_Mods. slapi_mods_insert_before() Inserts an LDAPMod into a Slapi_Mods structure before the current iterator position.
Page 343
Functions for LDAPMod Manipulation Description This function creates an array of of type from a LDAPMod LDAP_MOD_ADD Slapi_Entry See Also slapi_mods2entry() slapi_mod_add_value() Adds a value to a structure. Slapi_Mod Syntax #include “slapi-plugin.h” void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mod.
Page 344
Functions for LDAPMod Manipulation Description This function frees the internals of a , leaving it in the uninitialized state. Slapi_Mod Memory Concerns Use this function on a stack-allocated when you have finished with it, Slapi_Mod or want to reuse it. See Also slapi_mod_init() slapi_mod_init_byval()
Page 345
Functions for LDAPMod Manipulation Syntax #include “slapi-plugin.h” void slapi_mod_free(Slapi_Mod **smod); Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mod. smod Description This function frees a structure that was allocated Slapi_Mod by slapi_mod_new() See Also slapi_mod_new() slapi_mod_get_first_value() Initializes a iterator and returns the first attribute value.
Page 346
Functions for LDAPMod Manipulation See Also slapi_mod_get_next_value() slapi_mod_get_ldapmod_byref() Gets a reference to the in a structure. LDAPMod Slapi_Mod Syntax #include “slapi-plugin.h” const LDAPMod *slapi_mod_get_ldapmod_byref(const Slapi_Mod *smod); Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mod. smod Returns This function returns a pointer to a read-only owned by the LDAPMod...
Page 347
Functions for LDAPMod Manipulation Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mod. smod Returns This function returns a pointer to an owned by the caller. LDAPMod Description Use this function to get the out of a LDAPMod Slapi_Mod Memory Concerns...
Page 348
Functions for LDAPMod Manipulation Description Use this function with to iterate through the slapi_mods_get_first_mod() attribute values in a Slapi_Mod See Also slapi_mods_get_first_mod() slapi_mod_get_num_values() Gets the number of values in a structure. Slapi_Mod Syntax #include “slapi-plugin.h” int slapi_mod_get_num_values(const Slapi_Mod *smod); Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mod.
Page 349
Functions for LDAPMod Manipulation Returns This function returns one of LDAP_MOD_ADD LDAP_MOD_DELETE , combined using the bitwise or operator with LDAP_MOD_REPLACE LDAP_MOD_BYVALUES See Also slapi_mod_set_operation() slapi_mod_get_type() Gets the attribute type of a structure. Slapi_Mod Syntax #include “slapi-plugin.h” const char *slapi_mod_get_type(const Slapi_Mod *smod); Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mod.
Page 350
Functions for LDAPMod Manipulation Parameters This function takes the following parameters: Pointer to an uninitialized Slapi_Mod. smod Suggested number of attribute values for which to make room. initCount Minimum value is 0. Description This function initializes a so that it is empty, but initially has room for Slapi_Mod the given number of attribute values.
Page 351
Functions for LDAPMod Manipulation Description This function initializes a containing a reference to an . Use this Slapi_Mod LDAPMod function when you have an and would like the convenience of the LDAPMod functions to access it. Slapi_Mod See Also slapi_mod_done() slapi_mod_init() slapi_mod_init_byval() slapi_mod_init_passin()
Page 352
Functions for LDAPMod Manipulation Syntax #include “slapi-plugin.h” void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod); Parameters This function takes the following parameters: Pointer to an uninitialized Slapi_Mod. smod Pointer to an LDAPMod. Description This function initializes a by passing in an . Use this function to Slapi_Mod LDAPMod convert an...
Page 353
Functions for LDAPMod Manipulation Returns This function returns one of the following values: • 1 if the is valid. Slapi_Mod • 0 if the is not valid. Slapi_Mod Description Use this function to verify that the contents of are valid. It is considered Slapi_Mod valid if the operation type is one of LDAP_MOD_ADD...
Page 354
Functions for LDAPMod Manipulation Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mod. smod See Also slapi_mod_get_first_value() slapi_mod_get_next_value() slapi_mod_set_operation() Sets the operation type of a structure. Slapi_Mod Syntax #include “slapi-plugin.h” void slapi_mod_set_operation(Slapi_Mod *smod, int op); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mod.
Page 355
Functions for LDAPMod Manipulation Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mod. smod An attribute type. type Description Sets the attribute type of the to a copy of the given value. Slapi_Mod See Also slapi_mod_get_type() slapi_mods2entry() Creates a from an array of Slapi_Entry...
Page 356
Functions for LDAPMod Manipulation Description This function creates a from a copy of an array of of type Slapi_Entry LDAPMod LDAP_MODD_ADD See Also slapi_entry2mods() slapi_mods_add() Appends a new with a single attribute value to structure. Slapi_Mods Syntax #include “slapi-plugin.h” void slapi_mods_add( Slapi_Mods *smods, int modtype, const char *type, unsigned long len, const char *val);...
Page 357
Functions for LDAPMod Manipulation slapi_mods_add_string() slapi_mods_add_ldapmod() Appends an to a structure. LDAPMod Slapi_Mods Syntax #include “slapi-plugin.h” void slapi_mods_add_ldapmod(Slapi_Mods *smods, LDAPMod *mod); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods Pointer to a the LDAPMod to be appended. Description Appends an to a...
Page 358
Functions for LDAPMod Manipulation Syntax #include “slapi-plugin.h” void slapi_mods_add_mod_values( Slapi_Mods *smods, int modtype, const char *type, Slapi_Value **va );; Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods One of LDAP_MOD_ADD, LDAP_MOD_DELETE, modtype LDAP_MOD_REPLACE. The LDAP attribute type. type A null-terminated array of Slapi_Value representing the attribute values.
Page 359
Functions for LDAPMod Manipulation Syntax #include “slapi-plugin.h” void slapi_mods_add_modbvps( Slapi_Mods *smods, int modtype, const char *type, struct berval **bvps ); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods One of LDAP_MOD_ADD, LDAP_MOD_DELETE, modtype LDAP_MOD_REPLACE. The LDAP attribute type. type A null-terminated array of berval representing the attribute bvps...
Page 360
Functions for LDAPMod Manipulation Syntax #include “slapi-plugin.h” void slapi_mods_add_string( Slapi_Mods *smods, int modtype, const char *type, const char *val); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods One of LDAP_MOD_ADD, LDAP_MOD_DELETE, modtype LDAP_MOD_REPLACE. The LDAP attribute type. type The attribute value represented as a null-terminated string.
Page 361
Functions for LDAPMod Manipulation Parameters This function takes the following parameter: Pointer to a Slapi_Mods. smod Description This function frees the internals of a , leaving it in the uninitialized Slapi_Mods state. Use this function on a stack-allocated when you are finished Slapi_Mods with it, or when you wish to reuse it.
Page 362
Functions for LDAPMod Manipulation slapi_mods_free() Frees a structure. Slapi_Mods Syntax #include “slapi-plugin.h” void slapi_mods_free(Slapi_Mods **smods); Parameters This function takes the following parameter: Pointer to an allocated Slapi_Mods. smods Description This function frees a that was allocated by Slapi_Mods slapi_mods_new() See Also slapi_mods_new() slapi_mods_get_first_mod() Initializes a...
Page 363
Functions for LDAPMod Manipulation slapi_mods_get_first_smod() Initializes a iterator and returns the first wrapped in a Slapi_Mods structure. Slapi_Mods Syntax #include “slapi-plugin.h” Slapi_Mod *slapi_mods_get_first_smod(Slapi_Mods *smods, Slapi_Mod *smod); Parameters This function takes the following parameters: A pointer to a an initialized Slapi_Mods. smods Pointer to a Slapi_Mods that will be used to hold the mod.
Page 364
Functions for LDAPMod Manipulation Parameters This function takes the following parameter: Pointer to an initialized Slapi_Mods. smods Returns This function returns a null-terminated array of owned by the LDAPMod Slapi_Mods Description Use this function to get direct access to the array of contained in a LDAPMod Slapi_Mods...
Page 365
Functions for LDAPMod Manipulation Description Gets the array of out of a . Responsibility for the array LDAPMod Slapi_Mods transfers to the caller. The is left in the uninitialized state. Slapi_Mods See Also slapi_mods_get_ldapmods_byref() slapi_mods_get_next_mod() Increments the iterator and returns the next Slapi_Mods LDAPMod Syntax...
Page 366
Functions for LDAPMod Manipulation Syntax #include “slapi-plugin.h” Slapi_Mod *slapi_mods_get_next_smod(Slapi_Mods *smods, Slapi_Mod *smod); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods Pointer to a Slapi_Mods that will be used to hold the mod. smod Returns This function returns a pointer to the , wrapping the next , or Slapi_Mod...
Page 367
Functions for LDAPMod Manipulation Returns This function returns the number of mods in Slapi_Mods slapi_mods_init() Initializes a Slapi_Mods Syntax #include “slapi-plugin.h” void slapi_mods_init(Slapi_Mods *smods, int initCount); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods Suggested number of mods for which to make room. The initCount minimum value is 0.
Page 368
Functions for LDAPMod Manipulation Parameters This function takes the following parameters: Pointer to an uninitialized Slapi_Mods. smods A null-terminated array of LDAPMod. mods Description Initializes a containing a reference to an array of . This Slapi_Mods LDAPMod function provides the convenience of using functions to access Slapi_Mods array items.
Page 369
Functions for LDAPMod Manipulation Memory Concerns The responsibility for the array and its elements is transferred to the Slapi_Mods The array and its elements are destroyed when the is destroyed. Slapi_Mods See Also slapi_mods_done() slapi_mods_insert_after() Inserts an into a structure after the current iterator position. LDAPMod Slapi_Mods Syntax...
Page 370
Functions for LDAPMod Manipulation slapi_mods_insert_at() Inserts an anywhere in a LDAPMod Slapi_Mods Syntax #include “slapi-plugin.h” void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos); Parameters This function takes the following parameters: Pointer to an initialized Slapi_Mods. smods Pointer to the LDAPMod to be inserted. Position at which to insert the new mod.
Page 371
Functions for LDAPMod Manipulation Pointer to the LDAPMod to be inserted. Description Inserts an into a immediately before the current position of LDAPMod Slapi_Mods iterator. The iterator position is unchanged. Slapi_Mods Memory Concerns The responsibility for the is transferred to the .
Page 372
Functions for LDAPMod Manipulation slapi_mods_new() Allocates a new uninitialized structure. Slapi_Mods Syntax #include “slapi-plugin.h” Slapi_Mods* slapi_mods_new( void ); Parameters This function takes no parameters. Returns This function returns a pointer to an allocated uninitialized Slapi_Mods Description This function allocates a new initialized Slapi_Mods Memory Concerns Use this function when you need a...
Functions for Monitoring Operations See Also slapi_mods_get_first_mod() sslapi_mods_get_next_mod() slapi_mods_get_first_smod() slapi_mods_get_next_smod() Functions for Monitoring Operations This section contains reference information on operation routines. Table 14-20 Operation Routines Function Description slapi_op_abandoned() Determines if the client has abandoned the current operation. slapi_op_get_type() Gets the type of a Slapi_Operation. slapi_op_abandoned() Determines whether or not the client has abandoned the current operation (the operation that passes in the parameter block).
Page 374
Functions for Monitoring Operations Returns This function returns one of the following values: • 1 if the operation has been abandoned. • 0 if the operation has not been abandoned. slapi_op_get_type() Gets the type of a Slapi_Operation Syntax #include “slapi-plugin.h” unsigned long slapi_op_get_type(Slapi_Operation * op);...
Functions for Managing Parameter Block • SLAPI_OPERATION_COMPARE • SLAPI_OPERATION_ABANDON • SLAPI_OPERATION_EXTENDED See Also slapi_pblock_get() Functions for Managing Parameter Block This section contains reference information on parameter block routines. Table 14-21 Parameter Block Routines Function Description slapi_pblock_destroy() Frees a pblock from memory. slapi_pblock_get() Gets the value from a pblock.
Page 376
Functions for Managing Parameter Block Memory Concerns The parameter block that you wish to free must have been created using . Use of this function with allocated on the stack (for slapi_pblock_new() pblocks example, ;), or using another memory allocator, is not supported Slapi_PBlock pb and may lead to memory errors and memory leaks.
Page 377
Functions for Managing Parameter Block Returns This function returns one of the following values: • 0 if successful. • -1 if an error occurs (for example, if an invalid ID is specified). Memory Concerns The void argument should always be a pointer to the type of value you are *value retrieving: int connid = 0;...
Page 378
Functions for Managing Parameter Block slapi_pblock_get(pb, SOME_PARAM, &someparam); slapi_pblock_set(pb, SOME_PARAM, NULL); /* make sure no one else can reference this parameter */ slapi_ch_free_string(&someparam); Some internal functions may change the value passed in, so it is recommended to to retrieve the value again, rather than relying on a slapi_pblock_get() potential dangling pointer.
Page 379
Functions for Managing Parameter Block Parameters This function takes the following parameters: Parameter block. ID of the name-value pair that you want to set. For a list of IDs that you can specify, see Chapter 15, “Parameter Block Reference.” Pointer to the value that you want to set in the parameter block. value Returns This function returns one of the following values:...
Functions for Handling Passwords When setting parameters to register a plug-in, the plug-in type must always be set first, since many of the plug-in parameters depend on the type. For example, set the to extended operation before setting the list of extended SLAPI_PLUGIN_TYPE operation OIDs for the plug-in.
Page 381
Functions for Handling Passwords Pointer to the Slapi_Value structure containing the password that you wish to check (for example, you can get this value from the SLAPI_BIND_CREDENTIALS parameter in the parameter block and create the Slapi_Value using slapi_value_init_berval()). Returns This function returns one of the following values: •...
Page 382
Functions for Handling Passwords Returns This function returns one of the following values: • if the value is encoded. • if the value is not encoded. See Also slapi_pw_find_sv() slapi_encode() slapi_encode() Encodes a value with the specified algorithm. Syntax #include “slapi-plugin.h” char* slapi_encode(char *value, char *alg);...
Functions for Managing RDN See Also slapi_pw_find_sv() slapi_is_encoded() Functions for Managing RDN This section contains reference information on RDN routines. Table 14-23 RDN Routines Function Description slapi_rdn_add() Adds a new RDN to an existing RDN structure. slapi_rdn_compare() Compares two RDNs. slapi_rdn_contains() Checks if a Slapi_RDN structure holds any RDN matching a give type/value pair.
Page 384
Functions for Managing RDN Table 14-23 RDN Routines (Continued) Function Description slapi_rdn_new_dn() Creates a new Slapi_RDN structure. slapi_rdn_new_rdn() Creates a new Slapi_RDN structure and sets an RDN value. slapi_rdn_new_sdn() Creates a new Slapi_RDN structure and sets an RDN value taken from the DN contained in a given Slapi_RDN structure.
Page 385
Functions for Managing RDN Description This function adds a new type/value pair to an existing RDN, or sets the type/value pair as the new RDN if is empty. This function resets the flags, which means that the RDN array within the structure FLAG_RDNS Slapi_RDN...
Page 386
Functions for Managing RDN Syntax #include “slapi-plugin.h” int slapi_rdn_contains(Slapi_RDN *rdn, const char *type, const char *value,size_t length); Parameters This function takes the following parameters: The Slapi_RDN structure containing the RDN value(s). The type (cn, o, ou, etc.) of the RDN searched. type The value of the RDN searched.
Page 387
Functions for Managing RDN Parameters This function takes the following parameters: The Slapi_RDN structure containing the RDN value(s). Type (cn, o, ou, etc.) of the RDN searched. type Repository that will hold the value of the first RDN whose type value matches the content of the parameter type.
Page 388
Functions for Managing RDN Description This function clears the contents of a structure. It frees both the RDN Slapi_RDN value and the array of split RDNs. Those pointers are then set to NULL See Also slapi_rdn_free() slapi_rdn_init() slapi_rdn_free() Frees a structure.
Page 389
Functions for Managing RDN Parameters This function takes the following parameters: The Slapi_RDN structure containing the RDN value(s). Repository that will hold the type of the first RDN. If this type parameter is NULL at the return of the function, it means rdn is empty.
Page 390
Functions for Managing RDN Parameters This function takes the following parameters: The Slapi_RDN structure containing the RDN value(s). Type (cn, o, ou, etc.) of the RDN that is searched. type Value of the RDN searched. value Gives the length of value that should be taken into account for length the string comparisons when searching for the RDN.
Page 391
Functions for Managing RDN Parameters This function takes the following parameters: The Slapi_RDN structure containing the RDN value(s). Type (cn, o, ou, etc.) of the RDN searched. type Repository that will hold the value of the first RDN whose type value matches the content of the parameter type.
Page 392
Functions for Managing RDN Indicates the position of the RDN the precedes the currently index desired RDN. Repository that will hold the type (cn, o, ou, etc.) of the next type (index+1) RDN. If this parameter is NULL at the return of the function, the RDN does not exist.
Page 393
Functions for Managing RDN Returns This function returns the number of RDN type/value pairs present in See Also slapi_rdn_add() slapi_rdn_get_rdn() Gets the RDN from a structure. Slapi_RDN Syntax #include “slapi-plugin.h” const char *slapi_rdn_get_rdn(const Slapi_RDN *rdn); Parameters This function takes the following parameter: The Slapi_RDN structure holding the RDN value.
Page 394
Functions for Managing RDN Description This function initializes a given structure with values (both the Slapi_RDN NULL RDN value and the array of split RDNs are set to NULL See Also slapi_rdn_new() slapi_rdn_free() slapi_rdn_done() slapi_rdn_init_dn() Initializes a structure with an RDN value taken from a given DN. Slapi_RDN Syntax #include “slapi-plugin.h”...
Page 395
Functions for Managing RDN Syntax #include “slapi-plugin.h” void slapi_rdn_init_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn); Parameters This function takes the following parameters: The Slapi_RDN structure to be initialized. The RDN value to be set in the new Slapi_RDN structure. fromrdn Description This function initializes a given structure with the RDN value in Slapi_RDN fromrdn...
Page 396
Functions for Managing RDN Description This function initializes a given structure with the RDN value taken Slapi_RDN from the DN passed within the structure of the parameter. Slapi_DN See Also slapi_rdn_init_dn() slapi_rdn_init_rdn() slapi_rdn_isempty() Checks whether an RDN value is stored in a structure.
Page 397
Functions for Managing RDN Syntax #include “slapi-plugin.h” Slapi_RDN * slapi_rdn_new(); Parameters This function takes no parameters. Returns This function returns a pointer to the newly allocated, and still empty, Slapi_RDN structure. Description This function creates a new structure by allocating the necessary Slapi_RDN memory and initializing both the RDN value and the array of split RDNs to NULL...
Page 398
Functions for Managing RDN Description This function creates a new structure and initializes its RDN with the Slapi_RDN value taken from the DN passed in the parameter. Memory Concerns The memory is allocated by the function itself. See Also slapi_rdn_new_sdn() slapi_rdn_new_rdn() slapi_rdn_new_rdn() Creates a new...
Page 399
Functions for Managing RDN slapi_rdn_new_sdn() Creates a new structure and sets an RDN value taken from the DN Slapi_RDN contained in a given structure. Slapi_RDN Syntax #include “slapi-plugin.h” vSlapi_RDN *slapi_rdn_new_sdn(const Slapi_DN *sdn); Parameters This function takes the following parameter: Slapi_RDN structure containing the DN value whose RDN will be used to initialize the new Slapi_RDN structure.
Page 400
Functions for Managing RDN Parameters This function takes the following parameters: The target Slapi_RDN structure. Type (cn, o, ou, etc.) of the RDN searched. type The value of the RDN searched. value Gives the length of value that should be taken into account for length the string comparisons when searching for the RDN.
Page 401
Functions for Managing RDN Returns This function returns one of the following values: • if the RDN is removed from • if no RDN is removed. Description This function removes the first RDN from that matches the given type. See Also slapi_rdn_remove() slapi_rdn_remove_index() slapi_rdn_remove_index()
Page 402
Functions for Managing RDN See Also slapi_rdn_remove() slapi_rdn_remove_attr() slapi_rdn_set_dn() Sets an RDN value in a structure. Slapi_RDN Syntax #include “slapi-plugin.h” void slapi_rdn_set_dn(Slapi_RDN *rdn,const char *dn); Parameters This function takes the following parameters: The target Slapi_RDN structure. The DN value whose RDN will be set in rdn. Description This function sets an RDN value in a structure.
Page 403
Functions for Managing RDN Parameters This function takes the following parameters: The target Slapi_RDN structure. The RDN value to be set in rdn. fromrdn Description This function sets an RDN value in a structure. The structure is freed Slapi_RDN from memory and freed of any previous content before setting the new RDN. See Also slapi_rdn_set_dn() slapi_rdn_set_sdn()
Functions for Managing Roles slapi_rdn_set_rdn() Functions for Managing Roles This section contains reference information on routines that help you deal with roles. Table 14-24 Routines for Roles Function Description slapi_role_check() Checks if the entry pointed to by entry_to_check contains the role indicated by role_dn.
Functions for Managing DNs Returns This function returns one of the following values: • 0 for success; if is present in is set to 0. role_dn entry_to_check present • A non-zero value (error condition) if the presence of the role is undetermined. slapi_register_role_check() Allows registering of another function, other than the default, to use in .
Page 406
Functions for Managing DNs Table 14-25 DN Routines (Continued) Function Description slapi_sdn_get_dn() Gets the DN from a Slapi_DN structure. slapi_sdn_get_ndn() Gets the normalized DN of a Slapi_DN structure. slapi_sdn_get_ndn_len() Gets the length of the normalized DN of a Slapi_DN structure. slapi_sdn_get_parent() Get the parent DN of a given Slapi_DN structure.
Page 407
Functions for Managing DNs Syntax #include “slapi-plugin.h” char * slapi_moddn_get_newdn(Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn); Parameters This function takes the following parameters: The old DN value. dn_olddn The new RDN value. newrdn If not NULL, will be the DN of the future superior entry of the newsuperordn new DN, which will be worked out by adding the value in newrdn in front of the content of this parameter.
Page 408
Functions for Managing DNs Parameters This function takes the following parameters: Slapi_DN structure containging the value to which a new RDN is to be added. Slapi_RDN structure containing the RDN value that is to be added to the DN value. Returns This function returns the structure with the new DN formed by adding...
Page 409
Functions for Managing DNs Description This function compares two DNs, . The comparison is case sensitive. sdn1 sdn2 slapi_sdn_copy() Makes a copy of a DN. Syntax #include “slapi-plugin.h” void slapi_sdn_copy(const Slapi_DN *from, Slapi_DN *to); Parameters This function takes the following parameters: The original DN.
Page 410
Functions for Managing DNs Parameters This function takes the following parameter: Pointer to the structure to clear. Description This function clears the contents of a structure. It frees both the DN and Slapi_DN the normalized DN, if any, and sets those pointers to NULL See Also slapi_sdn_free()
Page 411
Functions for Managing DNs Syntax #include “slapi-plugin.h” void slapi_sdn_free(Slapi_DN **sdn); Parameters This function takes the following parameter: Pointer tot he pointer of the Slapi_DN structure to be freed. Description This function frees the structure and its contents pointed to by the Slapi_DN contents of See Also...
Page 412
Functions for Managing DNs Returns This function gets the parent DN of an entry within a given backend. The parent DN is returned is , unless is empty or is a suffix of the backend sdn_parent itself. In this case, is empty.
Page 413
Functions for Managing DNs slapi_sdn_get_ndn() Gets the normalized DN of a structure. Slapi_DN Syntax #include “slapi-plugin.h” const char * slapi_sdn_get_ndn(const Slapi_DN *sdn); Parameters This function takes the following parameter: The Slapi_DN structure containing the DN value. Returns This function returns the normalized DN value. Description This function retrieves the normalized DN (in a canonical format and lower case) from a...
Page 414
Functions for Managing DNs Returns This function returns the length of the normalized DN. Description This function contains the length of the normalized DN and normalizes if it has not already been normalized. slapi_sdn_get_parent() Gets the parent DN of a given structure.
Page 415
Functions for Managing DNs Parameters This function takes the following parameters: Pointer to the Slapi_DN structure containing the DN. Pointer to the Slapi_RDN structure where the RDN is returned. Description This function takes the DN stored in the structure pointed to by Slapi_DN retrieves its returned RDN within the structure pointed to by...
Page 416
Functions for Managing DNs See Also slapi_sdn_done() slapi_sdn_isgrandparent() Checks whether a DN is the parent of the parent of a given DN. Syntax #include “slapi-plugin.h” int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child ); Parameters This function takes the following parameters: Pointer to the Slapi_DN structure containing the DN which parent claims to be the grandparent DN of the DN in child.
Page 417
Functions for Managing DNs Syntax #include “slapi-plugin.h” int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child ); Parameters This function takes the following parameters: Pointer to the Slapi_DN structure containing the DN which parent claims to be the parent of the DN in child. Pointer to the Slapi_DN structure containing the DN of the child supposed child of the DN in the structure pointed to by parent.
Page 418
Functions for Managing DNs Returns This function returns one of the following values: • 1 if the DN is is the suffix of suffixsdn • 0 if the DN in is not a suffix of suffixsdn See Also slapi_sdn_isparent() slapi_sdn_new() Allocates a new structure and initializes it to Slapi_DN...
Page 419
Functions for Managing DNs Parameters This function takes the following parameter: The DN value to be set in the new Slapi_DN structure. Returns This function returns a pointer to the new structure with a DN value set Slapi_DN to the content of Description This function creates anew structure and initializes its DN with the value...
Page 420
Functions for Managing DNs Returns This function returns a pointer to the new structure with a DN value set Slapi_DN to the content of Description This function creates anew structure and initializes its DN with the value Slapi_DN . The DN of the new structure will point to a copy of the string pointed to by (the DN value is passed in to the parameter by value).
Page 421
Functions for Managing DNs Memory Concerns The memory is allocated by the function itself. See Also slapi_sdn_new_dn_byval() slapi_sdn_new_ndn_byref() slapi_sdn_new_ndn_byref() Creates a new structure and sets a normalized DN val Slapi_DN Syntax #include “slapi-plugin.h” Slapi_DN *slapi_sdn_new_ndn_byref(const char *ndn); Parameters This function takes the following parameter: The normalized DN value to be set in the new Slapi_DN structure.
Page 422
Functions for Managing DNs slapi_sdn_new_ndn_byval() Creates a new structure and sets a normalized DN value. Slapi_DN Syntax #include “slapi-plugin.h” Slapi_DN *slapi_sdn_new_ndn_byval(const char *ndn); Parameters This function takes the following parameter: The normalized DN value to be set in the new Slapi_DN structure.
Page 423
Functions for Managing DNs Parameters This function takes the following parameters: The DN of the entry subject of scope test. The base DN to which dn is going to be tested against. base The scope tested. This parameter can take one of the following scope levels: •...
Page 424
Functions for Managing DNs Parameters This function takes the following parameters: The target Slapi_DN structure. The DN value to be set in sdn. Returns This function returns a pointer to the structure containing the new DN Slapi_DN value. Description This function sets a DN value in a structure.
Page 425
Functions for Managing DNs Returns This function returns a pointer to the structure containing the new DN Slapi_DN value. Description This function sets a DN value in a structure. The DN of the new structure Slapi_DN will point to a copy of the string pointed to by (the DN value is passed into the parameter by value).
Page 426
Functions for Managing DNs slapi_sdn_set_dn_byref() slapi_sdn_set_ndn_byref() Sets a normalized DN in a structure. Slapi_DN Syntax #include “slapi-plugin.h” Slapi_DN *slapi_sdn_set_ndn_byref(Slapi_DN *sdn, const char *ndn); Parameters This function takes the following parameters: The target Slapi_DN structure. Normalized DN value to be set in sdn. Returns This function returns a pointer to the structure containing the new...
Page 427
Functions for Managing DNs Parameters This function takes the following parameters: The target Slapi_DN structure. The normalized DN value to be set in sdn. Returns This function returns a pointer to the structure containing the new Slapi_DN normalized DN value. Description This function sets a normalized DN value in a structure.
Page 428
Functions for Managing DNs Returns The function returns a pointer to the structure that contains the DN of Slapi_DN the entry after the new parent DN has been set. Description This function sets a new parent for an entry. This is done by keeping the RDN of the original DN of the entry and by adding the DN of its new parent (the value of ) to it.
Functions for Sending Entries and Results to the Client Functions for Sending Entries and Results to the Client This section contains reference information on routines for sending entries and results to the client. Table 14-26 Routines for Sending Entries and Results to Clients Function Description slapi_send_ldap_referral()
Page 430
Functions for Sending Entries and Results to the Client Returns This function returns one of the following values: • 0 if successful. • -1 if an error occurs. Description When you call this function, the server processes the LDAP referrals specified in argument.
Page 431
Functions for Sending Entries and Results to the Client slapi_send_ldap_result() Sends an LDAP result code back to the client. Syntax #include “slapi-plugin.h” void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls ); Parameters This function takes the following parameters: Parameter block.
Page 432
Functions for Sending Entries and Results to the Client and the database contains entries for “c=US” and “o=Example, c=US”, but no entry for “ou=Product Division, o=Example, c=US”, you should set the parameter to: matched o=Example, c=US • urls When sending an result code back to an LDAP v2 LDAP_PARTIAL_RESULTS client or an...
Page 433
Functions for Sending Entries and Results to the Client Parameters This function takes the following parameters: Parameter block. Pointer to the Slapi_Entry structure representing the entry that you want to send back to the client. Pointer to the array of LDAPControl structures representing ectrls the controls associated with the search request.
Functions Related to UTF-8 If you want to define your own function for sending entries, write a function complies with the type definition and set the send_ldap_search_entry_fn_ptr_t parameter in the parameter block to the name of SLAPI_PLUGIN_DB_ENTRY_FN your function. See Also slapi_str2filter() slapi_send_ldap_search_entry() Functions Related to UTF-8...
Page 435
Functions Related to UTF-8 slapi_has8thBit() Checks if a string has an 8-bit character. Syntax #include “slapi-plugin.h” int slapi_has8thBit(unsigned char *s); Parameters This function takes the following parameter: Pointer to the null-terminated string to test. Returns This function returns one of the following values: •...
Page 436
Functions Related to UTF-8 • if the two string are identical, ignoring case. • A negative number if is after Description The function takes two UTF-8 strings (s0, s1 ) of unsigned char to be compared. The comparison rules are as follows: •...
Page 437
Functions Related to UTF-8 Parameters This function takes the following parameters: A null-terminated UTF-8 string. A null-terminated UTF-8 string. Returns This function returns one of the following values: • A positive number if is after • if the two string are identical, ignoring case. •...
Page 438
Functions Related to UTF-8 slapi_utf8ncasecmp() Makes case-insensitive string comparison of first n characters of two UTF-8 strings. Syntax #include “slapi-plugin.h” int slapi_utf8ncasecmp(unsigned char *s0, unsigned char *s1, int n); Parameters This function takes the following parameters: A null-terminated UTF-8 string. A null-terminated UTF-8 string.
Page 439
Functions Related to UTF-8 Parameters This function takes the following parameters: A null-terminated UTF-8 string. A null-terminated UTF-8 string. The number of UTF-8 characters (not bytes) from s0 and s1 to compare. Returns This function returns one of the following values: •...
Page 440
Functions Related to UTF-8 slapi_utf8isLower() Verifies if a UTF-8 character is a lower-case letter. Syntax #include “slapi-plugin.h” int slapi_utf8isLower(unsigned char *s); This function takes the following parameter: Pointer to a single UTF-8 character (could be multiple bytes). Returns This function returns one of the following values: •...
Page 441
Functions Related to UTF-8 slapi_utf8isUpper() Verifies if a UTF-8 character is an upper-case letter. Syntax #include “slapi-plugin.h” int slapi_utf8isUpper(unsigned char *s); Parameters This function takes the following parameter: A single UTF-8 character (could be multiple bytes) Returns This function returns one of the following values: •...
Page 442
Functions Related to UTF-8 slapi_utf8StrToLower() Converts upper case characters in a UTF-8 string to lower-case characters. Syntax #include “slapi-plugin.h” unsigned char *slapi_utf8StrToLower(unsigned char *s); Parameters This function takes the following parameter: A null-terminated UTF-8 string to be converted to lower case. Returns This function returns one of the following values: •...
Page 443
Functions Related to UTF-8 Parameters This function takes the following parameter: A null-terminated UTF-8 string to be converted to lower case. Returns This function returns one of the following values: • A pointer to a null-terminated UTF-8 string whose characters are converted to lower case.
Page 444
Functions Related to UTF-8 Returns This function returns one of the following values: • A null-terminated UTF-8 string whose characters are converted to upper case; characters that are not lower case are copied as is. • if the string is not considered to be a UTF-8 string. Null Description This function converts a string of multiple UTF-8 characters, not a single character...
Page 445
Functions Related to UTF-8 slapi_utf8ToLower() Converts an upper-case UTF-8 character to a lower-case character. Syntax #include “slapi-plugin.h” void slapi_utf8ToLower(unsigned char *s, unsigned char *d, int *ssz, int *dsz); Parameters This function takes the following parameters: A single UTF-8 character (could be multiple bytes). Pointer to the lower case form of s.
Page 446
Functions Related to UTF-8 Returns the length in bytes of the output character. slapi_utf8ToUpper() Converts a lower-case UTF-8 character to an upper-case character. Syntax #include “slapi-plugin.h” void slapi_utf8ToUpper(unsigned char *s, unsigned char *d, int *ssz, int *dsz); Parameters This function takes the following parameters: Pointer to a single UTF-8 character (could be multiple bytes).
Functions for Handling Values Pointer to the upper case version of s. The memory for this must be allocated by the caller before calling the function. Returns the length in bytes of the input character. Returns the length in bytes of the output character. Functions for Handling Values This section contains reference information on value routines.
Page 448
Functions for Handling Values Table 14-28 Value Routines (Continued) Function Description slapi_value_set() Sets the value. slapi_value_set_berval() Copies the value from a berval structure into a Slapi_Value structure. slapi_value_set_int() Sets the integer value of a Slapi_Value structure. slapi_value_set_string() Copies a string into the value. slapi_value_set_string_passin() Sets the value.
Page 449
Functions for Handling Values Description This function compares two using the matching rule associated to Slapi_Values the attribute This function replaces the deprecated function used in slapi_attr_value_cmp() previous releases, and uses the attribute values instead of the Slapi_Value berval attribute values. slapi_value_dup() Duplicates a value.
Page 450
Functions for Handling Values Parameters This function takes the following parameter: Address of the pointer to the Slapi_Value you wish to free. value Description This function frees the structure and its members (if it is not Slapi_Value NULL and sets the pointer to NULL Memory Concerns Call this function when you are finished working with the structure.
Page 451
Functions for Handling Values slapi_value_get_int() Converts the value to an integer. Syntax #include “slapi-plugin.h” slapi_value_get_int(const Slapi_Value *value); Parameters This function takes the following parameter: Pointer to the Slapi_Value that you with to get as an integer. value Returns This function returns one of the following values: •...
Page 452
Functions for Handling Values Returns This function returns one of the following values: • The length of the value contained in Slapi_Value • 0 if there is no value. Description This function returns the actual length of a value contained in the Slapi_Value structure.
Page 453
Functions for Handling Values slapi_value_get_string() Returns the value as a string. Syntax #include “slapi-plugin.h” slapi_value_get_string(const Slapi_Value *value); Parameters This function takes the following parameter: Pointer to the value you wish to get as a string. value Returns This function returns one of the following values: •...
Page 454
Functions for Handling Values Returns This function returns one of the following values: • An unsigned integer which corresponds to the value stored in the structure. Slapi_Value • if there is no value. Description Converts the value contained in into an unsigned integer. Slapi_Value See Also slapi_value_get_int()
Page 455
Functions for Handling Values See Also slapi_value_get_long() slapi_value_get_int() slapi_value_get_uint() slapi_value_init() Initializes a structure with no value. Slapi_Value Syntax #include “slapi-plugin.h” slapi_value_init(Slapi_Value *v); Parameters This function takes the following parameter: Pointer to the value to be initialized. The pointer must not be NULL.
Page 456
Functions for Handling Values Parameters This function takes the following parameters: Pointer to the value to initialize. The pointer must not be NULL. Pointer to the berval structure to be used to initialize the value. bval Returns This function returns a pointer to the initialized structure (itself).
Page 457
Functions for Handling Values slapi_value_init_string_passin() Initializes a structure with value contained in the string. Slapi_Value Syntax #include “slapi-plugin.h” Slapi_Value * slapi_value_init_string_passin (Slapi_value *v, char *s); Parameters This function takes the following parameters: Pointer to the value to initialize. The pointer must not be NULL. NULL terminated string used to initialize the value.
Page 458
Functions for Handling Values Parameters This function does not take any parameters. Returns This function returns a pointer to the newly allocated structure. If Slapi_Value space cannot be allocated (for example, if no more virtual memory exists), the program terminates. slapd Description This function returns an empty...
Page 459
Functions for Handling Values Description This function returns a structure containing a value duplicated from Slapi_Value structure passed as the parameter. berval Memory Concerns When you are no longer using the value, you should free it from memory by calling slapi_value_free() See Also slapi_value_new()
Page 460
Functions for Handling Values Memory Concerns When you are no longer using the value, you should free it from memory by calling slapi_value_free() See Also slapi_value_new() slapi_value_new_berval() slapi_value_free() slapi_value_dup() slapi_value_new_string_passin() Allocates a new structure and initializes it from a string. Slapi_Value Syntax #include “slapi-plugin.h”...
Page 461
Functions for Handling Values slapi_value_dup() slapi_value_new() slapi_value_new_value() Allocates a new structure and initializes it from another Slapi_Value structure. Slapi_Value Syntax #include “slapi-plugin.h” slapi_value_new_value(const Slapi_Value *v); Parameters This function takes the following parameter: Pointer to the Slapi_Value structure used to initialize the newly allocated Slapi_Value.
Page 462
Functions for Handling Values slapi_value_set() Sets the value in a structure. Slapi_Value Syntax #include “slapi-plugin.h” slapi_value_set( Slapi_Value *value, void *val, unsigned long len); Parameters This function takes the following parameters: Pointer to the Slapi_Value in which to set the value. value Pointer to the value.
Page 463
Functions for Handling Values Syntax #include “slapi-plugin.h” slapi_value_set_berval( Slapi_Value *value, const struct berval *bval ); Parameters This function takes the following parameters: Pointer to the Slapi_Value structure in which to set the value. value Pointer to the berval value to be copied. bval Returns This function returns one of the following values:...
Page 464
Functions for Handling Values Parameters This function takes the following parameters: Pointer to the Slapi_Value structure in which to set the value integer value. The integer containing the value to set. intVal Returns This function returns one of the following values: •...
Page 465
Functions for Handling Values The string containing the value to set. strVal Returns This function returns one of the following: • if value is set. • if the pointer to the Slapi_Value NULL Description This function sets the value of the structure by duplicating the string Slapi_Value strVal...
Page 466
Functions for Handling Values Returns This function returns one of the following values: • if the value is set. • if the pointer to the structure is Slapi_Value NULL Description This function sets the value of structure with the string .
Functions for Handling Valueset Memory Concerns If the pointer to the , nothing is done and the function returns Slapi_Value NULL . If the already contains a value, it is freed from before the new NULL Slapi_Value one is set. When you are no longer using the structure, you should free it from Slapi_Value...
Page 468
Functions for Handling Valueset slapi_valueset_add_value() Adds a in the structure. Slapi_Value Slapi_ValueSet Syntax #include “slapi-plugin.h” void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval); Parameters This function takes the following parameters: Pointer to the Slapi_ValueSet structure to which to add the value. Pointer to the Slapi_Value to add to the Slapi_ValueSet. addval Description This function adds a value in the form of a...
Page 469
Functions for Handling Valueset Parameters This function takes the following parameter: Pointer to the Slap_ValueSet structure of which you wish to get the count. Returns This function returns the number of values contained in the Slapi_ValueSet structure. slapi_valueset_done() Frees the values contained in the structure.
Page 470
Functions for Handling Valueset Parameters This function takes the following parameters: Pointer to the attribute. This is used to determine the syntax of the values and how to match them. Pointer to the Slapi_ValueSet structure from which you wish to get the value. Address of the pointer to the Slapi_Value structure for the returned value.
Page 471
Functions for Handling Valueset Returns This function returns one of the following values: • The index of the value in the Slapi_ValueSet • if there was no value. Description Call this function when you wish to get the first value of a , or you Slapi_ValueSet wish to iterate through all of the values.
Page 472
Functions for Handling Valueset slapi_valueset_init() Resets a structure to no values. Slapi_ValueSet Syntax #include “slapi-plugin.h” void slapi_valueset_init(Slapi_ValueSet *vs); Parameters This function takes the following parameter: Pointer to the Slapi_ValueSet to replace. Description This function returns the values contained in the structure (sets Slapi_ValueSet them to 0).
Page 473
Functions for Handling Valueset Returns This function returns a a pointer to the newly allocated structure. Slapi_ValueSet If no space could be allocated (for example, if no more virtual memory exists), the program terminates. slapd Description This function returns an empty structure.
Page 474
Functions for Handling Valueset • The index of the value in the Slapi_ValueSet • if there was no more value or the input index is incorrect. Description Call this function when you wish to get the next value of a , after Slapi_ValueSet having first called...
Page 475
Functions for Handling Valueset Memory Concerns This function does not verify that the structure already contains Slapi_ValueSet values, so it is your responsibility to verify that there are no values prior to calling this function. If you do not verify this, the allocated memory space will leak. You can free existing values by calling slapi_valueset_done() See Also...
Functions Specific to Virtual Attribute Service Functions Specific to Virtual Attribute Service This section contains reference information on routines that are specific to virtual attribute services. Table 14-30 Virtual Attribute Service Routines Function Description slapi_vattr_value_compare() Compares attribute type and name in an given entry. slapi_vattr_values_free() Frees the valueset and type names.
Page 477
Functions Specific to Virtual Attribute Service • (type not recognized by any and not a real SLAPI_VIRTUAL_NOT_FOUND vattr in entry). attr • (memory error). ENOMEM Description There is no need to call after calling this function. slapi_vattr_values_free() slapi_vattr_values_free() Frees the valueset and type names. Syntax #include “slapi-plugin.h”...
Page 478
Functions Specific to Virtual Attribute Service Syntax #include “slapi-plugin.h” int slapi_vattr_values_get_ex(Slapi_Entry *e, char *type, Slapi_ValueSet*** results, int **type_name_disposition, char ***actual_type_name, int flags, int *buffer_flags, int *subtype_count); Parameters This function takes the following parameters: Entry from which to get the values. Attribute type name.
Functions for Managing Locks and Synchronization • contains the number of subtypes matched. subtype_count Otherwise, this function returns the following • (failed to evaluate a SLAPI_VIRTUALATTRS_LOOP_DETECTED vattr • (type not recognized by any and not a real SLAPI_VIRTUAL_NOT_FOUND vattr in entry). attr •...
Page 480
Functions for Managing Locks and Synchronization Table 14-31 Locks and Synchronization Routines (Continued) Function Description slapi_wait_condvar() Waits on a condition variable. slapi_destroy_condvar() Frees a structure from memory. Slapi_CondVar Syntax #include “slapi-plugin.h” void slapi_destroy_condvar( Slapi_CondVar *cvar ); Parameters This function takes the following parameters: Pointer to the Slapi_CondVar structure that you want to free from memory.
Page 481
Functions for Managing Locks and Synchronization Description This function frees a structure from memory. The calling function Slapi_Mutex must ensure that no thread is currently in a lock-specific function. Locks do not provide self-referential protection against deletion. slapi_lock_mutex() Locks the specified mutex. Syntax #include “slapi-plugin.h”...
Page 482
Functions for Managing Locks and Synchronization Pointer to an Slapi_Mutex structure representing the mutex mutex that you want used to protect this condition variable. Returns This function returns one of the following values: • A pointer to the new structure. Slapi_CondVar •...
Page 483
Functions for Managing Locks and Synchronization When you are done working with the mutex, you can free the Slapi_Mutex structure by calling the function. slapi_destroy_mutex() slapi_notify_condvar() Notifies a thread that is waiting on the specified condition variable. Syntax #include “slapi-plugin.h” int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );...
Page 484
Functions for Managing Locks and Synchronization Parameters This function takes the following parameters: Pointer to an Slapi_Mutex structure representing the mutex mutex that you want to unlock. Returns This function returns one of the following values: • A non-zero value if the mutex was successfully unlocked. •...
Functions for Manipulating Bits • 0 if an error occurs (for example, if the condition variable is NULL or if the mutex associated with the condition variable is not locked). Description This function waits on the condition variable until it receives notification (see the function).
Page 486
Functions for Manipulating Bits Returns This function returns one of the following values: • if the specified bit is set. • if the specified bit is not set. See Also slapi_setbit_int() slapi_unsetbit_int() slapi_isbitset_uchar() Checks whether a particular bit is set in the specified character. #include “slapi-plugin.h”...
Page 487
Functions for Manipulating Bits Syntax #include “slapi-plugin.h” unsigned int slapi_setbit_int(unsigned int f,unsigned int bitnum); Parameters This function takes the following parameters: The integer in which a bit is to be set. The bit number that needs to be set in the integer. bitnum Returns This function returns the integer with the specified bit set.
Page 488
Functions for Manipulating Bits See Also slapi_isbitset_uchar() slapi_unsetbit_uchar() slapi_unsetbit_int() Unsets the specified bit in an integer. Syntax #include “slapi-plugin.h” unsigned int slapi_unsetbit_int(unsigned int f,unsigned int bitnum); Parameters This function takes the following parameters: The integer in which a bit is to be unset. The bit number that needs to be unset in the integer.
Functions for Registering Object Extensions Parameters This function takes the following parameters: The character in which a bit is to be unset. The bit number that needs to be unset in the character. bitnum Returns This function returns the character with the specified bit unset. See Also slapi_isbitset_uchar() slapi_setbit_uchar()
Page 490
Functions for Registering Object Extensions Syntax #include “slapi-plugin.h” void *slapi_get_object_extension(int objecttype, void *object, int extensionhandle); Parameters This function takes the following parameters: The object type handle that was returned from the objecttype slapi_register_object_extension() call. A pointer to the core server object from which the extension is to object be retrieved.
Page 491
Functions for Registering Object Extensions Syntax #include “slapi-plugin.h” int slapi_register_object_extension( const char *pluginname, const char *objectname, slapi_extension_constructor_fnptr constructor, slapi_extension_destructor_fnptr destructor, int *objecttype, int *extensionhandle); Parameters This function takes the following parameters: Plug-in name. pluginname The name of the core server object to be extended. Objects that objectname can be extended (possible values for the objectname parameter):...
Page 492
Functions for Registering Object Extensions created; this is why the registration must happen during plug-in initialization. In return, the plug-in will receive two handles, one for the object type and another one for the object extension; these only have meaning for the function.
Chapter 15 Parameter Block Reference This chapter describes the parameters available in the parameter Slapi_PBlock block, the type of data associated with each parameter, and the plug-in functions in which those parameters are accessible. To get the values of these parameters, call the function.
Parameters for Registering Plug-In Functions Parameters for Registering Plug-In Functions The parameters listed in this section identify plug-in functions recognized by the server. To register your plug-in function, set the value of the appropriate parameter to the name of your function. NOTE With the exception of the parameters for matching rule plug-in functions, you do not need to get the value of any of these...
Parameters for Registering Plug-In Functions Parameter ID Description This function is called before an LDAP search operation is SLAPI_PLUGIN_PRE_SEARCH_FN completed. This function is called before an LDAP compare operation is SLAPI_PLUGIN_PRE_COMPARE_FN completed. This function is called before an LDAP modify operation is SLAPI_PLUGIN_PRE_MODIFY_FN completed.
Parameters for Registering Plug-In Functions Parameter ID Description This function is called after an LDAP search operation is SLAPI_PLUGIN_POST_SEARCH_FN completed. This function is called after an LDAP compare operation is SLAPI_PLUGIN_POST_COMPARE_FN completed. This function is called after an LDAP modify operation is SLAPI_PLUGIN_POST_MODIFY_FN completed.
Parameters Accessible to All Plug-Ins Parameter ID Data Type Description This function is called after the server starts up. SLAPI_PLUGIN_START_FN void * You can specify a start function for each extended operation plug-in. This function is called before the server shuts SLAPI_PLUGIN_CLOSE_FN void * down.
Parameters Accessible to All Plug-Ins • Information About the Connection • Information About the Operation • Notes in the Access Log • Information About the Plug-In Information About the Database The parameters listed below specify information about the back-end database. These parameters are available for all types of plug-ins.
Parameters Accessible to All Plug-Ins Information About the Connection The parameters listed below specify information about the connection. These parameters are available for all types of plug-ins. Parameter ID Data Type Description Information about the current client connection. SLAPI_CONNECTION Slapi_Connection * ID identifying the current connection.
Parameters Accessible to All Plug-Ins Parameter ID Data Type Description IP address that the client is connecting to. You SLAPI_CONN_SERVERIP struct in_addr might want to use this parameter if, for example, your server accepts connections on multiple IP addresses.This parameter has been replaced by SLAPI_CONN_SERVERADDR, but is provided here for backward compatibility IP address of the client requesting the operation.
Parameters Accessible to All Plug-Ins Parameter ID Data Type Description Specifies whether or not the user SLAPI_REQUESTOR_ISROOT requesting the operation is the “root DN”. • 1 means that the “root DN” is requesting the operation. • 0 means that the user requesting the operation is not the “root DN.”...
Parameters Accessible to All Plug-Ins Parameter ID Data Type Description Flags specifying the notes that you want appended to SLAPI_OPERATION_NOTES unsigned int access log entries. You can set this parameter to the following value: • SLAPI_OP_NOTE_UNINDEXED specifies that you want the string “Notes=U” appended to access log entries.
Parameters Accessible to All Plug-Ins Parameter ID Data Type Description Reserved for internal use only - used with filter SLAPI_PLUGIN_OBJECT void * processing. Reserved for internal use only - used with filter SLAPI_PLUGIN_DESTROY_FN void * processing. Types of Plug-Ins parameter can have one of the following values, which SLAPI_PLUGIN_TYPE identifies the type of the current plug-in: Defined Constant...
Parameters for the Configuration Function Defined Constant Description Version 1 of the plug-in interface, which is SLAPI_PLUGIN_VERSION_01 supported by the Directory Server 3.x and subsequent releases (including 4.0) Version 2 of the plug-in interface, which is SLAPI_PLUGIN_VERSION_02 supported by the Directory Server 4.x release but not by previous releases Version 3 of the plug-in interface, which is SLAPI_PLUGIN_VERSION_03...
Parameters for the Search Function Parameter ID Data Type Description Authentication method used (for example, SLAPI_BIND_METHOD LDAP_AUTH_SIMPLE or LDAP_AUTH_SASL). Credentials from the bind request. SLAPI_BIND_CREDENTIALS struct berval * Credentials that you want sent back to the SLAPI_BIND_RET_SASLCREDS struct berval * client.
Page 506
Parameters for the Search Function Parameter ID Data Type Description Method for handling aliases in a search. This SLAPI_SEARCH_DEREF method can be one of the following values: • LDAP_DEREF_NEVER • LDAP_DEREF_SEARCHING • LDAP_DEREF_FINDING • LDAP_DEREF_ALWAYS Maximum number of entries to return in the search SLAPI_SEARCH_SIZELIMIT results.
Parameters for the Add Function Parameter ID Data Type Description Array of the URLs to other LDAP SLAPI_SEARCH_REFERRALS struct berval ** servers that the current server is referring the client to See “Processing an LDAP Search Operation” on page 80 and “Iterating Through Candidates”...
Parameters for the Compare Function Parameter ID Data Type Description Internal only - used by the SLAPI_ADD_EXISTING_UNIQUEID_ENTRY Slapi_Entry * multimaster replication resolution procedure code. If adding an entry that already exists, this is the entry which has the same unique ID. See “Processing an LDAP Add Operation”...
Parameters for the Modify Function Parameter ID Data Type Description DN of the entry to delete. SLAPI_DELETE_TARGET char * Internal only - used by the SLAPI_DELETE_EXISTING_ENTRY Slapi_Entry * multimaster replication resolution procedure code. See “Processing an LDAP Delete Operation” on page 89 for more information on these parameters.
Parameters for the Modify RDN Function Parameters for the Modify RDN Function The following table lists the parameters in the parameter block passed to the database modify RDN function. If you are writing a pre-operation, database, or post-operation modify RDN function, you can get these values by calling the function.
Parameters for the Abandon Function See “Processing an LDAP Modify RDN Operation” on page 87 for more information on these parameters. Parameters for the Abandon Function The following table lists the parameters in the parameter block passed to the database abandon function. If you are writing a pre-operation, database, or post-operation abandon function, you can get these values by calling the function.
Parameters for Internal LDAP Operations Parameters for Internal LDAP Operations The parameters listed below are used in conjunction with functions that you can call to perform LDAP operations from a plug-in (these internal operations do not return any data to a client). Parameter ID Data Type Description...
Glossary This glossary defines terms commonly used when working with LDAP. base DN The distinguished name (DN) that identifies the starting point of a search. For example, if you want to search all of the entries that under the “ou=People,o=example.com” subtree of the directory, “ou=People,o=example.com”...
Page 514
operational attributes Attributes that are used by servers for administering the directory. For example, is an operational attribute that specifies the creatorsName DN of the user who added the entry. Operational attributes are not returned in any search results unless you specify the attribute by name in the search request. referral Refers an LDAP client to another LDAP server.
Page 515
subschema entry Entry containing all the schema definitions (definitions of object classes, attributes, matching rules, and so on) used by entries in part of a directory tree. Glossary...
Page 516
Netscape Directory Server Plug-In Programmer’s Guide • May 2002...
Need help?
Do you have a question about the NETSCAPE DIRECTORY SERVER 6.02 - PLUG-IN and is the answer not in the manual?
Questions and answers