ldap_str2syntax, ldap_syntax2str, ldap_syntax2name, ldap_syntax_free, ldap_str2matchingrule, ldap_matchingrule2str, ldap_matchingrule2name, ldap_matchingrule_free, ldap_str2attributetype, ldap_attributetype2str, ldap_attributetype2name, ldap_attributetype_free, ldap_str2objectclass, ldap_objectclass2str, ldap_objectclass2name, ldap_objectclass_free, ldap_scherr2str − Schema definition handling routines


OpenLDAP LDAP (libldap, −lldap)


#include <ldap.h>
#include <ldap_schema.h>

LDAPSyntax * ldap_str2syntax(s, code, errp, flags)
const char * s;
int * code;
const char ** errp;
const int flags;

char * ldap_syntax2str(syn)
const LDAPSyntax * syn;

const char * ldap_syntax2name(syn)
LDAPSyntax * syn;

LDAPSyntax * syn;

LDAPMatchingRule * ldap_str2matchingrule(s, code, errp, flags)
const char * s;
int * code;
const char ** errp;
const int flags;

char * ldap_matchingrule2str(mr);
const LDAPMatchingRule * mr;

const char * ldap_matchingrule2name(mr)
LDAPMatchingRule * mr;

LDAPMatchingRule * mr;

LDAPAttributeType * ldap_str2attributetype(s, code, errp, flags)
const char * s;
int * code;
const char ** errp;
const int flags;

char * ldap_attributetype2str(at)
const LDAPAttributeType * at;

const char * ldap_attributetype2name(at)
LDAPAttributeType * at;

LDAPAttributeType * at;

LDAPObjectClass * ldap_str2objectclass(s, code, errp, flags)
const char * s;
int * code;
const char ** errp;
const int flags;

char * ldap_objectclass2str(oc)
const LDAPObjectClass * oc;

const char * ldap_objectclass2name(oc)
LDAPObjectClass * oc;

LDAPObjectClass * oc;

char * ldap_scherr2str(code)
int code;


These routines are used to parse schema definitions in the syntax defined in RFC 4512 into structs and handle these structs. These routines handle four kinds of definitions: syntaxes, matching rules, attribute types and object classes. For each definition kind, four routines are provided.

ldap_str2xxx() takes a definition in RFC 4512 format in argument s as a NUL-terminated string and returns, if possible, a pointer to a newly allocated struct of the appropriate kind. The caller is responsible for freeing the struct by calling ldap_xxx_free() when not needed any longer. The routine returns NULL if some problem happened. In this case, the integer pointed at by argument code will receive an error code (see below the description of ldap_scherr2str() for an explanation of the values) and a pointer to a NUL-terminated string will be placed where requested by argument errp , indicating where in argument s the error happened, so it must not be freed by the caller. Argument flags is a bit mask of parsing options controlling the relaxation of the syntax recognized. The following values are defined:

strict parsing according to RFC 4512.


permit definitions that do not contain an initial OID.


permit quotes around some items that should not have them.


permit a descr instead of a numeric OID in places where the syntax expect the latter.


permit that the initial numeric OID contains a prefix in descr format.


be very liberal, include all options.

The structures returned are as follows:

typedef struct ldap_schema_extension_item {

char *lsei_name;

/* Extension name */

char **lsei_values;

/* Extension values */

} LDAPSchemaExtensionItem;

typedef struct ldap_syntax {

char *syn_oid;

/* OID */

char **syn_names;

/* Names */

char *syn_desc;

/* Description */

LDAPSchemaExtensionItem **syn_extensions; /* Extension */

} LDAPSyntax;

typedef struct ldap_matchingrule {

char *mr_oid;

/* OID */

char **mr_names;

/* Names */

char *mr_desc;

/* Description */

int mr_obsolete;

/* Is obsolete? */

char *mr_syntax_oid;

/* Syntax of asserted values */

LDAPSchemaExtensionItem **mr_extensions; /* Extensions */

} LDAPMatchingRule;

typedef struct ldap_attributetype {

char *at_oid;

/* OID */

char **at_names;

/* Names */

char *at_desc;

/* Description */

int at_obsolete;

/* Is obsolete? */

char *at_sup_oid;

/* OID of superior type */

char *at_equality_oid;

/* OID of equality matching rule */

char *at_ordering_oid;

/* OID of ordering matching rule */

char *at_substr_oid;

/* OID of substrings matching rule */

char *at_syntax_oid;

/* OID of syntax of values */

int at_syntax_len;

/* Suggested minimum maximum length */

int at_single_value;

/* Is single-valued? */

int at_collective;

/* Is collective? */

int at_no_user_mod;

/* Are changes forbidden through LDAP? */

int at_usage;

/* Usage, see below */

LDAPSchemaExtensionItem **at_extensions; /* Extensions */

} LDAPAttributeType;

typedef struct ldap_objectclass {

char *oc_oid;

/* OID */

char **oc_names;

/* Names */

char *oc_desc;

/* Description */

int oc_obsolete;

/* Is obsolete? */

char **oc_sup_oids;

/* OIDs of superior classes */

int oc_kind;

/* Kind, see below */

char **oc_at_oids_must;

/* OIDs of required attribute types */

char **oc_at_oids_may;

/* OIDs of optional attribute types */

LDAPSchemaExtensionItem **oc_extensions; /* Extensions */

} LDAPObjectClass;

Some integer fields (those described with a question mark) have a truth value, for these fields the possible values are:

The answer to the question is no.


The answer to the question is yes.

For attribute types, the following usages are possible:

the attribute type is non-operational.


the attribute type is operational and is pertinent to the directory itself, i.e. it has the same value on all servers that master the entry containing this attribute type.


the attribute type is operational and is pertinent to replication, shadowing or other distributed directory aspect. TBC.


the attribute type is operational and is pertinent to the directory server itself, i.e. it may have different values for the same entry when retrieved from different servers that master the entry.

Object classes can be of three kinds:

the object class is abstract, i.e. there cannot be entries of this class alone.


the object class is structural, i.e. it describes the main role of the entry. On some servers, once the entry is created the set of structural object classes assigned cannot be changed: none of those present can be removed and none other can be added.


the object class is auxiliary, i.e. it is intended to go with other, structural, object classes. These can be added or removed at any time if attribute types are added or removed at the same time as needed by the set of object classes resulting from the operation.

Routines ldap_xxx2name() return a canonical name for the definition.

Routines ldap_xxx2str() return a string representation in the format described by RFC 4512 of the struct passed in the argument. The string is a newly allocated string that must be freed by the caller. These routines may return NULL if no memory can be allocated for the string.

ldap_scherr2str() returns a NUL-terminated string with a text description of the error found. This is a pointer to a static area, so it must not be freed by the caller. The argument code comes from one of the parsing routines and can adopt the following values:

Out of memory.


Unexpected token.


Missing opening parenthesis.


Missing closing parenthesis.


Expecting digit.


Expecting a name.


Bad description.


Bad superiors.


Duplicate option.


Unexpected end of data.




OpenLDAP Software is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>. OpenLDAP Software is derived from University of Michigan LDAP 3.3 Release.

More Linux Commands

Tcl_NewDictObj(3) - manipulate Tcl objects as dictionaries
Tcl dictionary objects have an internal representation that supports efficient mapping from keys to values and which guarantees that the particular ordering of

glNormal3f(3gl) - set the current normal vector (Man Page)
The current normal is set to the given coordinates whenever glNormal is issued. Byte, short, or integer arguments are converted to floating-point with a linear

pkeyutl(1ssl) public key algorithm utility - Linux man page
The pkeyutl command can be used to perform public key operations using any supported algorithm. COMMAND OPTIONS -in filename This specifies the input filename t

pg_config.1pg91 (Manual - Linux man page)..................
The pg_config utility prints configuration parameters of the currently installed version of PostgreSQL. It is intended, for example, to be used by software pack

sprintf(3) - formatted output conversion - Linux man page...
The functions in the printf() family produce output according to a format as described below. The functions printf() and vprintf() write output to stdout, the s

glDepthMask(3gl) - enable or disable writing into the depth
glDepthMask specifies whether the depth buffer is enabled for writing. If flag is GL_FALSE, depth buffer writing is disabled. Otherwise, it is enabled. Initiall

FcCharSetCopy(3) - Copy a charset - Linux manual page.......
Makes a copy of src; note that this may not actually do anything more than increment the reference count on src. VERSION Fontconfig version 2.8.0 FcCharSetCopy.

vfs_btrfs(8) Utilize features provided by the Btrfs filesyst
This VFS module is part of the samba(8) suite. The vfs_btrfs VFS module exposes Btrfs specific features for use by Samba. Btrfs allows for multiple files to sha

getpass(3) - get a password (Library - Linux man page)......
This function is obsolete. Do not use it. If you want to read input without terminal echoing enabled, see the description of the ECHO flag in termios(3). The ge

ovdb_stat(8) - Display information from the ovdb database...
ovdb_stat displays information from the ovdb database: Berkeley DB statistics, newsgroup data, and overview records; and optionally outputs in HTML format. OPTI

localectl(1) Control the system locale and keyboard layout s
localectl may be used to query and change the system locale and keyboard layout settings. The system locale controls the language settings of system services an

mkfifo(3) - make a FIFO special file (a named pipe).........
mkfifo() makes a FIFO special file with name pathname. mode specifies the FIFOs permissions. It is modified by the processs umask in the usual way: the permissi

We can't live, work or learn in freedom unless the software we use is free.