### Build ppm Module with Custom Options Source: https://gitlab.com/openldap/openldap/-/blob/master/contrib/slapd-modules/ppm/INSTALL.md Example of building the ppm module while overriding default options such as source directory, installation prefix, and library directory. ```bash make clean make LDAP_SRC=../../.. prefix=/usr/local libdir=/usr/local/lib make test LDAP_SRC=../../.. make doc prefix=/usr/local make install prefix=/usr/local libdir=/usr/local/lib ``` -------------------------------- ### OpenLDAP Overlay Configuration Examples Source: https://context7.com/openldap/openldap/llms.txt Loads and configures overlay modules to extend OpenLDAP functionality. Ensure the overlay modules are installed and accessible. ```conf # Load overlay modules moduleload memberof moduleload refint moduleload ppolicy database mdb suffix "dc=example,dc=com" # ... database configuration ... # MemberOf Overlay - automatically maintains memberOf attribute overlay memberof memberof-group-oc groupOfNames memberof-member-ad member memberof-memberof-ad memberOf memberof-dangling ignore memberof-refint TRUE # Referential Integrity Overlay - maintains referential integrity overlay refint refint_attributes member memberOf manager owner # Password Policy Overlay overlay ppolicy ppolicy_default "cn=default,ou=Policies,dc=example,dc=com" ppolicy_hash_cleartext ppolicy_use_lockout ``` -------------------------------- ### Example Password Policy Configuration Source: https://gitlab.com/openldap/openldap/-/blob/master/contrib/slapd-modules/ppm/ppm.md A comprehensive example demonstrating multiple policy constraints applied simultaneously. ```text minQuality 4 forbiddenChars .?, checkRDN 1 checkAttributes mail class-upperCase ABCDEFGHIJKLMNOPQRSTUVWXYZ 0 5 0 class-lowerCase abcdefghijklmnopqrstuvwxyz 0 12 0 class-digit 0123456789 0 1 0 class-special <>,?;.:/!§ù%*µ^¨$£²&é~"#'{([-|è`_\ç^à@)]°=}+ 0 1 0 class-myClass :) 1 1 0 ``` -------------------------------- ### Example documentSeries Entry Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4524.txt An example LDIF entry for a documentSeries object. ```LDIF dn: cn=RFC,dc=Example,dc=COM objectClass: documentSeries cn: Request for Comments cn: RFC description: a series of memos about the Internet ``` -------------------------------- ### Example Entries Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-howard-rfc2307bis-xx.txt Illustrative examples of different object classes within the LDAP NameService Schema. ```APIDOC ## Example Entries ### Description Examples of various object classes in the LDAP NameService Schema. ### posixAccount Example ``` dn: uid=lester,ou=people,dc=aja,dc=com objectClass: top objectClass: account objectClass: posixAccount uid: lester cn: Lester the Nightfly gecos: Lester uidNumber: 10 gidNumber: 10 loginShell: /bin/csh userPassword: {crypt}$X5/DBrWPOQQaI homeDirectory: /home/lester ``` ### ipHost Example ``` dn: cn=josie.aja.com,ou=hosts,dc=aja,dc=com objectClass: top objectClass: device objectClass: ipHost objectClass: bootableDevice objectClass: ieee802Device cn: josie.aja.com cn: www.aja.com ipHostNumber: 10.0.0.1 macAddress: 00:00:92:90:ee:e2 bootFile: mach bootParameter: root=dan.aja.com:/nfsroot/peg bootParameter: swap=dan.aja.com:/nfsswap/peg bootParameter: dump=dan.aja.com:/nfsdump/peg ``` ### nisNetgroup Example ``` dn: cn=nightfly,ou=netgroup,dc=aja,dc=com objectClass: top objectClass: nisNetgroup cn: nightfly nisNetgroupTriple: (charlemagne,peg,dunes.aja.com) nisNetgroupTriple: (lester,-,) memberNisNetgroup: kamakiriad ``` ### nisObject Example ``` dn: nisMapName=tracks,dc=dunes,dc=aja,dc=com objectClass: top objectClass: nisMap nisMapName: tracks dn: cn=Maxine,nisMapName=tracks,dc=dunes,dc=aja,dc=com objectClass: top objectClass: nisObject cn: Maxine nisMapName: tracks nisMapEntry: Nightfly$4 ``` ``` -------------------------------- ### Example account Entry Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4524.txt An example LDIF entry for an account object. ```LDIF dn: uid=kdz,cn=Accounts,dc=Example,dc=COM objectClass: account uid: kdz seeAlso: cn=Kurt D. Zeilenga,cn=Persons,dc=Example,dc=COM ``` -------------------------------- ### LDAP ipHost Entry Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-howard-rfc2307bis-xx.txt Example of an ipHost entry representing a host with multiple aliases and boot parameters. ```LDIF dn: cn=josie.aja.com,ou=hosts,dc=aja,dc=com objectClass: top objectClass: device objectClass: ipHost objectClass: bootableDevice objectClass: ieee802Device cn: josie.aja.com cn: www.aja.com ipHostNumber: 10.0.0.1 macAddress: 00:00:92:90:ee:e2 bootFile: mach bootParameter: root=dan.aja.com:/nfsroot/peg bootParameter: swap=dan.aja.com:/nfsswap/peg bootParameter: dump=dan.aja.com:/nfsdump/peg ``` -------------------------------- ### LDAP nisObject Entry Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-howard-rfc2307bis-xx.txt Example of a nisMap and a corresponding nisObject entry. ```LDIF dn: nisMapName=tracks,dc=dunes,dc=aja,dc=com objectClass: top objectClass: nisMap nisMapName: tracks dn: cn=Maxine,nisMapName=tracks,dc=dunes,dc=aja,dc=com objectClass: top objectClass: nisObject cn: Maxine nisMapName: tracks nisMapEntry: Nightfly$4 ``` -------------------------------- ### LDAP posixAccount Entry Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-howard-rfc2307bis-xx.txt Example of a posixAccount entry and its corresponding UNIX password file format. ```LDIF dn: uid=lester,ou=people,dc=aja,dc=com objectClass: top objectClass: account objectClass: posixAccount uid: lester cn: Lester the Nightfly gecos: Lester uidNumber: 10 gidNumber: 10 loginShell: /bin/csh userPassword: {crypt}$X5/DBrWPOQQaI homeDirectory: /home/lester ``` ```text lester:X5/DBrWPOQQaI:10:10:Lester:/home/lester:/bin/sh ``` -------------------------------- ### Example O/R Address Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc2294.txt An example of an O/R Address string, commonly used in X.400 messaging. ```text PRMD=UK.AC, ADMD=Gold 400, C=GB ``` -------------------------------- ### Example API Version Definitions Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-ldap-c-api-xx.txt Example macro definitions for a specific LDAP API version, demonstrating how to define API version, minimum and maximum supported LDAP protocol versions, and vendor-specific information. ```c #define LDAP_API_VERSION 88888 /* RFC 88888 compliant */ #define LDAP_VERSION_MIN 2 #define LDAP_VERSION_MAX 3 #define LDAP_VENDOR_NAME "Netscape Communications Corp." #define LDAP_VENDOR_VERSION 400 /* version 4.0 */ ``` -------------------------------- ### Starting a Transaction Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc5805.txt Details the process of initiating a new transaction using a Start Transaction Request. ```APIDOC ## Starting a Transaction ### Description A client initiates a transaction by sending a Start Transaction Request. The server responds with a Start Transaction Response, either indicating success with a transaction identifier or failure with an appropriate error code. ### Request - **Method**: Extended Operation (LDAPMessage of CHOICE extendedReq) - **Request Name**: 1.3.6.1.1.21.1 (or similar, indicating start transaction) ### Response - **Type**: Start Transaction Response (LDAPMessage) - **Success Response**: Contains a transaction identifier and a success (0) resultCode. - **Failure Response**: Contains a non-success resultCode indicating the reason for failure. ``` -------------------------------- ### API Version Check Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-ldap-c-api-xx.txt A preprocessor directive example showing how an application can test the C LDAP API version level to conditionally use features supported in specific RFC versions or later. ```c #if (LDAP_API_VERSION >= 88888) /* use features supported in RFC 88888 or later */ #endif ``` -------------------------------- ### Build ppm Module Source: https://gitlab.com/openldap/openldap/-/blob/master/contrib/slapd-modules/ppm/INSTALL.md Standard commands to clean, build, test, document, and install the ppm module. ```bash make clean make make test make doc make install ``` -------------------------------- ### Example document Entry Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4524.txt An example LDIF entry for a document object. ```LDIF dn: documentIdentifier=RFC 4524,cn=RFC,dc=Example,dc=COM objectClass: document documentIdentifier: RFC 4524 documentTitle: COSINE LDAP/X.500 Schema documentAuthor: cn=Kurt D. Zeilenga,cn=Persons,dc=Example,dc=COM documentLocation: http://www.rfc-editor.org/rfc/rfc4524.txt documentPublisher: Internet Engineering Task Force description: A collection of schema elements for use in LDAP description: Obsoletes RFC 1274 seeAlso: documentIdentifier=RFC 4510,cn=RFC,dc=Example,dc=COM seeAlso: documentIdentifier=RFC 1274,cn=RFC,dc=Example,dc=COM ``` -------------------------------- ### Evaluation Example 5: Minimal Permissions for Entry Creation Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-acl-model-xx.txt Demonstrates using the 'm' (make) permission to limit attributes allowed during entry creation. ```LDIF dn: o=XYZ, c=US ldapACI: subtree#grant:m#OID.attr5 #authzID-dn:cn=jsmith,o=ABC,c=US ldapACI: subtree#grant:m#OID.cn #authzID-dn:cn=jsmith,o=ABC,c=US ldapACI: subtree#grant:m#OID.sn #authzID-dn:cn=jsmith,o=ABC,c=US ldapACI: subtree#grant:a#[entry] #authzID-dn:#cn=jsmith,o=ABC,c=US ``` -------------------------------- ### Initialize and Bind to LDAP Server Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-ldap-c-api-xx.txt Opens an LDAP session and performs a simple bind. Ensure the host and port are correctly specified. Authentication is done as 'nobody' in this example. ```c #include #include main() { LDAP *ld; LDAPMessage *res, *e; int i, rc; char *a, *dn; BerElement *ptr; char **vals; /* open an LDAP session */ if ( (ld = ldap_init( "dotted.host.name", LDAP_PORT )) == NULL ) return 1; /* authenticate as nobody */ if (( rc = ldap_simple_bind_s( ld, NULL, NULL )) != LDAP_SUCCESS ) { fprintf( stderr, "ldap_simple_bind_s: %s\n", ldap_err2string( rc )); ldap_unbind( ld ); return 1; } ``` -------------------------------- ### BerkeleyDB Basic Operations in C Source: https://gitlab.com/openldap/openldap/-/blob/master/libraries/liblmdb/sample-bdb.txt Demonstrates initializing a database environment, performing a transactional put operation, and iterating through records using a cursor. Error checking is omitted for brevity. ```c /* sample-bdb.txt - BerkeleyDB toy/sample * * Do a line-by-line comparison of this and sample-mdb.txt */ /* * Copyright 2012-2021 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in the file LICENSE in the * top-level directory of the distribution or, alternatively, at * . */ #include #include #include int main(int argc,char * argv[]) { int rc; DB_ENV *env; DB *dbi; DBT key, data; DB_TXN *txn; DBC *cursor; char sval[32], kval[32]; /* Note: Most error checking omitted for simplicity */ #define FLAGS (DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_INIT_MPOOL|DB_CREATE|DB_THREAD) rc = db_env_create(&env, 0); rc = env->open(env, "./testdb", FLAGS, 0664); rc = db_create(&dbi, env, 0); rc = env->txn_begin(env, NULL, &txn, 0); rc = dbi->open(dbi, txn, "test.bdb", NULL, DB_BTREE, DB_CREATE, 0664); memset(&key, 0, sizeof(DBT)); memset(&data, 0, sizeof(DBT)); key.size = sizeof(int); key.data = sval; data.size = sizeof(sval); data.data = sval; sprintf(sval, "%03x %d foo bar", 32, 3141592); rc = dbi->put(dbi, txn, &key, &data, 0); rc = txn->commit(txn, 0); if (rc) { fprintf(stderr, "txn->commit: (%d) %s\n", rc, db_strerror(rc)); goto leave; } rc = env->txn_begin(env, NULL, &txn, 0); rc = dbi->cursor(dbi, txn, &cursor, 0); key.flags = DB_DBT_USERMEM; key.data = kval; key.ulen = sizeof(kval); data.flags = DB_DBT_USERMEM; data.data = sval; data.ulen = sizeof(sval); while ((rc = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) { printf("key: %p %.*s, data: %p %.*s\n", key.data, (int) key.size, (char *) key.data, data.data, (int) data.size, (char *) data.data); } rc = cursor->c_close(cursor); rc = txn->abort(txn); leave: rc = dbi->close(dbi, 0); rc = env->close(env, 0); return rc; } ``` -------------------------------- ### Add New Entry with ldap_add_ext_s Source: https://context7.com/openldap/openldap/llms.txt Demonstrates creating a new LDAP entry by defining an array of LDAPMod structures and calling ldap_add_ext_s. Ensure the LDAP connection is initialized and bound before execution. ```c #include #include #include #include int main() { LDAP *ld = NULL; int rc; int version = LDAP_VERSION3; struct berval cred; /* Initialize and bind */ ldap_initialize(&ld, "ldap://localhost:389"); ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); cred.bv_val = "secret"; cred.bv_len = strlen(cred.bv_val); ldap_sasl_bind_s(ld, "cn=admin,dc=example,dc=com", LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); /* Define the new entry */ const char *dn = "uid=newuser,ou=People,dc=example,dc=com"; /* objectClass attribute */ char *objectclass_vals[] = {"inetOrgPerson", "posixAccount", NULL}; LDAPMod objectclass_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "objectClass", .mod_vals.modv_strvals = objectclass_vals }; /* cn attribute */ char *cn_vals[] = {"New User", NULL}; LDAPMod cn_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "cn", .mod_vals.modv_strvals = cn_vals }; /* sn attribute */ char *sn_vals[] = {"User", NULL}; LDAPMod sn_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "sn", .mod_vals.modv_strvals = sn_vals }; /* uid attribute */ char *uid_vals[] = {"newuser", NULL}; LDAPMod uid_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "uid", .mod_vals.modv_strvals = uid_vals }; /* uidNumber and gidNumber for posixAccount */ char *uidnum_vals[] = {"10001", NULL}; LDAPMod uidnum_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "uidNumber", .mod_vals.modv_strvals = uidnum_vals }; char *gidnum_vals[] = {"10001", NULL}; LDAPMod gidnum_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "gidNumber", .mod_vals.modv_strvals = gidnum_vals }; char *homedir_vals[] = {"/home/newuser", NULL}; LDAPMod homedir_mod = { .mod_op = LDAP_MOD_ADD, .mod_type = "homeDirectory", .mod_vals.modv_strvals = homedir_vals }; /* Build modification array */ LDAPMod *mods[] = { &objectclass_mod, &cn_mod, &sn_mod, &uid_mod, &uidnum_mod, &gidnum_mod, &homedir_mod, NULL }; /* Add the entry */ rc = ldap_add_ext_s(ld, dn, mods, NULL, NULL); if (rc == LDAP_SUCCESS) { printf("Entry added successfully: %s\n", dn); } else { fprintf(stderr, "ldap_add_ext_s failed: %s\n", ldap_err2string(rc)); } ldap_unbind_ext_s(ld, NULL, NULL); return (rc == LDAP_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE; } ``` -------------------------------- ### ber_scanf Decoding Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-ldap-c-api-xx.txt An example demonstrating the use of ber_scanf for decoding a complex ASN.1 structure. ```APIDOC ## Decoding Example2Request ### Description This example shows how to decode an ASN.1 `Example2Request` structure using `ber_scanf` and other BER utility functions. ### ASN.1 Definition ```asn Example2Request ::= SEQUENCE { dn OCTET STRING, -- must be printable scope ENUMERATED { b (0), s (1), w (2) }, ali ENUMERATED { n (0), s (1), f (2), a (3) }, size INTEGER, time INTEGER, tonly BOOLEAN, attrs SEQUENCE OF OCTET STRING, -- must be printable [0] SEQUENCE OF SEQUENCE { type OCTET STRING -- must be printable, crit BOOLEAN DEFAULT FALSE, value OCTET STRING } OPTIONAL } ``` ### C Code Example ```c #define TAG_CONTROL_LIST 0xA0U /* context specific cons 0 */ int decode_example2(struct berval *bv) { BerElement *ber; ber_len_t len; ber_tag_t res; ber_int_t scope, ali, size, time, tonly; char *dn = NULL, **attrs = NULL; int i,rc = 0; ber = ber_init(bv); if (ber == NULL) { fputs("ERROR ber_init failed\n", stderr); return -1; } res = ber_scanf(ber,"{aiiiib{v}",&dn,&scope,&ali, &size,&time,&tonly,&attrs); if (res == LBER_ERROR) { fputs("ERROR ber_scanf failed\n", stderr); ber_free(ber,1); return -1; } /* *** use dn */ ldap_memfree(dn); for (i = 0; attrs != NULL && attrs[i] != NULL; i++) { /* *** use attrs[i] */ ldap_memfree(attrs[i]); } ldap_memfree((char *)attrs); if (ber_peek_tag(ber,&len) == TAG_CONTROL_LIST) { char *opaque; ber_tag_t tag; for (tag = ber_first_element(ber,&len,&opaque); tag != LBER_DEFAULT; tag = ber_next_element(ber,&len,opaque)) { /* Process elements within the optional sequence */ } } ber_free(ber,1); return 0; } ``` ### Parameters - **bv** (*struct berval*) - Pointer to the BER encoded data. ### Return Value - **int** - 0 on success, -1 on failure. ``` -------------------------------- ### LDAP SearchResultReference Example 2 Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4511.txt Example of SearchResultReference responses from a server for a singleLevel search. ```LDAP Protocol SearchResultEntry for CN=Manager,DC=Example,DC=NET SearchResultReference { ldap://hostb/OU=People,DC=Example,DC=NET??base ldap://hostc/OU=People,DC=Example,DC=NET??base } SearchResultReference { ldap://hostd/OU=Roles,DC=Example,DC=NET??base } SearchResultDone (success) ``` -------------------------------- ### LDAP SearchResultReference Example 1 Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4511.txt Example of SearchResultReference responses from a server when searching a subtree. ```LDAP Protocol SearchResultEntry for OU=People,DC=Example,DC=NET SearchResultReference { ldap://hoste/OU=Managers,OU=People,DC=Example,DC=NET??sub } SearchResultReference { ldap://hostf/OU=Consultants,OU=People,DC=Example,DC=NET??sub } SearchResultDone (success) ``` -------------------------------- ### Configure slapd.conf for OpenLDAP 2.6 Source: https://gitlab.com/openldap/openldap/-/blob/master/contrib/slapd-modules/ppm/ppm.md Example configuration for enabling the ppolicy overlay and specifying the ppm module path in slapd.conf. ```text overlay ppolicy ppolicy_default "cn=default,ou=policies,dc=my-domain,dc=com" ppolicy_check_module /usr/local/openldap/libexec/openldap/ppm.so #ppolicy_use_lockout # for having more infos about the lockout ``` -------------------------------- ### LMDB Basic Operations in C Source: https://gitlab.com/openldap/openldap/-/blob/master/libraries/liblmdb/sample-mdb.txt Demonstrates initializing an environment, performing a write transaction, and iterating through records with a cursor. Error checking is omitted for brevity. ```c /* sample-mdb.txt - MDB toy/sample * * Do a line-by-line comparison of this and sample-bdb.txt */ /* * Copyright 2012-2021 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in the file LICENSE in the * top-level directory of the distribution or, alternatively, at * . */ #include #include "lmdb.h" int main(int argc,char * argv[]) { int rc; MDB_env *env; MDB_dbi dbi; MDB_val key, data; MDB_txn *txn; MDB_cursor *cursor; char sval[32]; /* Note: Most error checking omitted for simplicity */ rc = mdb_env_create(&env); rc = mdb_env_open(env, "./testdb", 0, 0664); rc = mdb_txn_begin(env, NULL, 0, &txn); rc = mdb_dbi_open(txn, NULL, 0, &dbi); key.mv_size = sizeof(int); key.mv_data = sval; data.mv_size = sizeof(sval); data.mv_data = sval; sprintf(sval, "%03x %d foo bar", 32, 3141592); rc = mdb_put(txn, dbi, &key, &data, 0); rc = mdb_txn_commit(txn); if (rc) { fprintf(stderr, "mdb_txn_commit: (%d) %s\n", rc, mdb_strerror(rc)); goto leave; } rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn); rc = mdb_cursor_open(txn, dbi, &cursor); while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { printf("key: %p %.*s, data: %p %.*s\n", key.mv_data, (int) key.mv_size, (char *) key.mv_data, data.mv_data, (int) data.mv_size, (char *) data.mv_data); } mdb_cursor_close(cursor); mdb_txn_abort(txn); leave: mdb_dbi_close(env, dbi); mdb_env_close(env); return 0; } ``` -------------------------------- ### LDAP nisNetgroup Entry Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-howard-rfc2307bis-xx.txt Example of a nisNetgroup entry containing triples and member references. ```LDIF dn: cn=nightfly,ou=netgroup,dc=aja,dc=com objectClass: top objectClass: nisNetgroup cn: nightfly nisNetgroupTriple: (charlemagne,peg,dunes.aja.com) nisNetgroupTriple: (lester,-,) memberNisNetgroup: kamakiriad ``` -------------------------------- ### Define defaultServerList attribute Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-joslin-config-schema-xx.txt Example of a defaultServerList attribute containing multiple host and port configurations. ```text defaultServerList: 192.168.169.170 ldap1.mycorp.com ldap2:1389 [1080::8:800:200C:417A]:5912 ``` -------------------------------- ### Example dcObject Entry Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc2247.txt An example LDIF entry demonstrating the use of the 'dcObject' class, suitable for an organization. ```ldif dn: dc=critical-angle,dc=com objectClass: top objectClass: organization objectClass: dcObject dc: critical-angle o: Critical Angle Inc. ``` -------------------------------- ### Evaluation Example 4: authzID vs Subtree Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-acl-model-xx.txt Shows that authzID-dn takes precedence over subtree-based access. ```LDIF dn: o=XYZ, c=US ldapACI: subtree#grant:w#attr4 #authzID-dn:cn=jsmith,ou=ABC,o=XYZ,c=US ldapACI: subtree#grant:r#attr4#subtree:ou=ABC,ou=XYZ,c=US ``` -------------------------------- ### Simple LDIF File with Multiple Entries Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc2849.txt A basic example of an LDIF file defining two directory entries with various attributes and object classes. ```text version: 1 dn: cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com objectclass: top objectclass: person objectclass: organizationalPerson cn: Barbara Jensen cn: Barbara J Jensen cn: Babs Jensen sn: Jensen uid: bjensen telephonenumber: +1 408 555 1212 description: A big sailing fan. dn: cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com objectclass: top objectclass: person objectclass: organizationalPerson cn: Bjorn Jensen sn: Jensen telephonenumber: +1 408 555 1212 ``` -------------------------------- ### Evaluation Example 1: authzID vs Group Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-ietf-ldapext-acl-model-xx.txt Demonstrates that authzID-dn has higher precedence than group-based access. ```LDIF dn: o=XYZ, c=US ldapACI: subtree#grant:r#attr1 #authzID-dn:cn=jsmith,ou=ABC,o=XYZ,c=US ldapACI: subtree#grant:w#attr1 #group:cn=G1,ou=ABC,o=XYZ,c=US ``` -------------------------------- ### Example ChangeSequenceNumber Value Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-sermersheim-ldap-csn-xx.txt An example of a value for the ChangeSequenceNumber syntax, illustrating the format for time, timeCount, replicaID, and changeCount. ```LDAP { time "196701160315-0700", timeCount 0, replicaID "DSA666", changeCount 1 } ``` -------------------------------- ### LDAP SearchResultDone Referral Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4511.txt Example of a SearchResultDone response containing a referral when the server does not hold the base object. ```LDAP Protocol SearchResultDone (referral) { ldap://hostg/DC=Example,DC=ORG??sub } ``` -------------------------------- ### Initialize LDAP Connection Handle Source: https://context7.com/openldap/openldap/llms.txt Use ldap_initialize to create an LDAP session handle. Requires linking with -lldap and -llber. ```c #include #include #include int main() { LDAP *ld = NULL; int rc; int version = LDAP_VERSION3; /* Initialize LDAP connection */ rc = ldap_initialize(&ld, "ldap://localhost:389"); if (rc != LDAP_SUCCESS) { fprintf(stderr, "ldap_initialize failed: %s\n", ldap_err2string(rc)); return EXIT_FAILURE; } /* Set protocol version to LDAPv3 */ rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); if (rc != LDAP_OPT_SUCCESS) { fprintf(stderr, "ldap_set_option failed: %s\n", ldap_err2string(rc)); ldap_unbind_ext_s(ld, NULL, NULL); return EXIT_FAILURE; } /* Set network timeout */ struct timeval timeout = {10, 0}; /* 10 seconds */ ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &timeout); printf("LDAP connection initialized successfully\n"); /* Cleanup */ ldap_unbind_ext_s(ld, NULL, NULL); return EXIT_SUCCESS; } /* Compile: gcc -o ldap_init ldap_init.c -lldap -llber */ ``` -------------------------------- ### Example domain Entry Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc2247.txt An example LDIF entry for the 'domain' object class, used as a placeholder entry with SRV records. ```ldif dn: dc=tcp,dc=critical-angle,dc=com objectClass: top objectClass: domain dc: tcp description: a placeholder entry used with SRV records ``` -------------------------------- ### LDAP Search Result Example (NoSuchObject) Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc3088.txt An example of an LDAP search result indicating no such object was found, with the matched DN specified. ```ldap s: searchResult { noSuchObject matchedDN="DC=example,DC=net" } ``` -------------------------------- ### LDAP Entry for Ordered Siblings Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-chu-ldap-xordered-xx.txt An example entry demonstrating ordered siblings configuration. ```LDIF dn: olcDatabase={0}config,cn=config olcDatabase: {0}config objectClass: olcDatabaseConfig olcSuffix: {0}cn=config ``` -------------------------------- ### LDAP Dereference Control - Example Usage Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/drafts/draft-masarati-ldap-deref-xx.txt Provides an example of how the Dereference Control is used in a search request and the corresponding response structure. ```APIDOC ## Example Usage ### Scenario Searching for a group and dereferencing its members' attributes. ### Request Example Performing a search for the group `cn=Test Group,ou=groups,dc=example,dc=org` with a Dereference Control requesting the `member` attribute and the `uid` attribute for dereferenced entries. ``` Control Value: { member, uid } ``` ### Response Example An example of the response control value when the `cn=Test Group` entry is returned, showing dereferenced `member` entries with their `uid` attribute values. ``` Response Control Value: { member, cn=Howard Chu,ou=people,dc=example,dc=org, { { uid, [hyc] } } }, { member, cn=Pierangelo Masarati,ou=people,dc=example,dc=org, { { uid, [ando] } } } ``` ``` -------------------------------- ### LDAP 'room' Entry Example Source: https://gitlab.com/openldap/openldap/-/blob/master/doc/rfc/rfc4524.txt An example LDIF entry for a 'room' object class. It includes the common name and telephone number attributes. ```ldif dn: cn=conference room,dc=example,dc=com objectClass: room cn: conference room telephoneNumber: +1 755 555 1111 ``` -------------------------------- ### Initialize UCData Library Source: https://gitlab.com/openldap/openldap/-/blob/master/libraries/liblunicode/ucdata/api.txt Initializes the UCData library by loading specified data files from given paths. Call this before using other UCData functions. ```c void ucdata_load(char *paths, int masks) ```