Skip Navigation Links | |
Exit Print View | |
Oracle Directory Server Enterprise Edition Developer's Guide 11 g Release 1 (11.1.1.5.0) |
Part I Directory Server Plug-In API Guide
1. Before You Start Writing Plug-Ins
2. Changes to the Plug-In API Since Directory Server 5.2
3. Getting Started With Directory Server Plug-Ins
4. Working With Entries Using Plug-Ins
Converting To and From LDIF Representations
Converting an LDIF String to a Slapi_Entry Structure
Converting a Slapi_Entry Structure to an LDIF String
Getting Entry Attributes and Attribute Values
Verifying Schema Compliance for an Entry
Handling Entry Distinguished Names
Getting the Parent and Suffix DNs
Determining Whether a Suffix Is Served Locally
Is the User the Directory Manager?
5. Extending Client Request Handling Using Plug-Ins
6. Handling Authentication Using Plug-Ins
7. Performing Internal Operations With Plug-Ins
8. Writing Entry Store and Entry Fetch Plug-Ins
9. Writing Extended Operation Plug-Ins
10. Writing Matching Rule Plug-Ins
11. Writing Password Storage Scheme Plug-Ins
12. Writing Password Quality Check Plug-Ins
13. Writing Computed Attribute Plug-Ins
Part II Directory Server Plug-In API Reference
14. Data Type and Structure Reference
15. Function Reference, Part I
16. Function Reference, Part II
This section demonstrates how to add and remove attributes and their values.
If the attribute name and value are strings, you might be able to use slapi_entry_add_string(). The following example builds an entry first by setting the DN, then by adding attributes with string values.
Example 4-5 Adding String Attribute Values (entries.c)
#include "slapi-plugin.h" int test_create_entry() { Slapi_Entry * entry = NULL; /* Original entry */ entry = slapi_entry_alloc(); slapi_entry_set_dn(entry, slapi_ch_strdup("dc=example,dc=com")); slapi_entry_add_string(entry, "objectclass", "top"); slapi_entry_add_string(entry, "objectclass", "domain"); slapi_entry_add_string(entry, "dc", "example"); /* Add code using the entry you created..... */ slapi_entry_free(entry); return (0); }
When working with values that already exist or with values that are not strings, you can use the following functions
Use slapi_entry_add_values_sv() to add new values to an attribute of an entry. This function returns an error when duplicates of the new values already exist.
Use slapi_entry_attr_merge_sv() to add new values to the existing values of a multivalued attribute. This function does not return an error when duplicates of the new values already exist.
The following example demonstrates slapi_entry_attr_merge_sv().
Example 4-6 Merging Attribute Values (entries.c)
#include "slapi-plugin.h" int test_ldif() { Slapi_Entry * entry = NULL; /* Entry to hold LDIF */ Slapi_Value * values[2]; /* Attribute values */ entry = slapi_entry_alloc(); /* Add code to transform an LDIF representation into an entry.*/ /* Add a description by setting the value of the attribute. * Although this is overkill when manipulating string values, * it can be handy when manipulating binary values. */ values[0] = slapi_value_new_string("Description for the entry."); values[1] = NULL; if (slapi_entry_attr_merge_sv(entry,"description",values) != 0) /* Merge did not work if processing arrives here. */ ; slapi_entry_free(entry); return (0); }
If the attribute exists in the entry, slapi_entry_attr_merge_sv() merges the specified values into the set of existing values. If the attribute does not exist, slapi_entry_attr_merge_sv() adds the attribute with the specified values.
Remove attribute values with slapi_entry_delete_string() or slapi_entry_delete_values_sv().