include/ldb.h(3)

πŸ“¦
version 4.24.7 Β· 4 versions
, in fedora 44

✨ NAME ✨

include/ldb.h β€” Samba's ldb database, bestie. That's the whole name. It lives in the Library Functions Manual, section 3, so it's giving C library header energy. 🫢


🌸 SYNOPSIS 🌸

okay so before you can even look at the structs, you gotta pull in the headers. No cap, these are the includes:

#include <stdbool.h>
#include <talloc.h>
#include <tevent.h>
#include <ldb_version.h>
#include <ldb_errors.h>

and then, boom, data structures. The header says:

πŸ¦‹ Data Structures πŸ¦‹

  • struct ldb_val β€” a result value. that's the whole job. πŸ’…
  • struct ldb_message_element β€” results are given back as arrays of ldb_message_element, so this is how you get your result pieces. ✨
  • struct ldb_message β€” a ldb_message represents all or part of a record. main character behavior, honestly. πŸ‘‘
  • struct ldb_ldif β€” LDIF record. exactly what it sounds like. πŸŽ€
  • struct ldb_parse_tree β€” no blurb in the header, it's just out here being mysterious. πŸ’€
  • struct ldb_schema_syntax β€” no extra text, just the struct name and vibes. 🌈
  • struct ldb_schema_attribute β€” again, no description, but it's in the lineup. πŸ’œ
  • struct ldb_dn_extended_syntax β€” header doesn't explain it, it just exists. πŸ¦‹
  • struct ldb_sd_flags_control β€” no little description here, just the struct. ⭐
  • struct ldb_search_options_control β€” same deal: no blurb, only struct. πŸ”₯
  • struct ldb_paged_control β€” no description in this part, but it's here. πŸ“
  • struct ldb_extended_dn_control β€” no blurb, it's just listed. πŸ’–
  • struct ldb_server_sort_control β€” no description, but iconic name. πŸ’…
  • struct ldb_sort_resp_control β€” no blurb in the header. ✨
  • struct ldb_asq_control β€” no description, just the struct. 🌸
  • struct ldb_dirsync_control β€” no blurb, still in the data structures list. 🧚
  • struct ldb_vlv_req_control β€” no description, just hanging out. 🫢
  • struct ldb_vlv_resp_control β€” no blurb, but it's here. πŸ’œ
  • struct ldb_verify_name_control β€” no description, just the struct name. 🌈
  • struct ldb_control β€” no blurb in the header, but it's a control, iykyk. πŸ‘‘
  • struct ldb_extended β€” no description, just the struct. ⭐
  • struct ldb_seqnum_request β€” no blurb, but it's in the list. πŸŽ€
  • struct ldb_seqnum_result β€” no description, still part of the squad. ✨
  • struct ldb_result β€” no blurb, just the struct. πŸ’–
  • struct ldb_reply β€” no description, but it's here. πŸ¦‹
  • struct ldb_search β€” no blurb, just the struct. πŸ”₯
  • struct ldb_add β€” no description, still listed. πŸ“
  • struct ldb_modify β€” no blurb, just the struct. πŸ’…
  • struct ldb_delete β€” no description, but it's in the lineup. 🌸
  • struct ldb_rename β€” no blurb, just the struct. 🧚
  • struct ldb_register_control β€” no description, still here. 🫢
  • struct ldb_register_partition β€” no blurb, just the struct. πŸ’œ
  • struct ldb_request β€” no description in the header, but it's the last one in this list. 🌈

✨ Macros ✨

okay bestie, welcome to the macro section of include/ldb.h. these are the little #define spells you'll see all over LDB. some have descriptions, some are just vibes. we're going through every single one, no skips. periodt. πŸ’…

  • #define LDB_FLAG_MOD_MASK 0x3 β€” There are a whole bunch of flags that get used with ldap_modify() in the ldb_message_element.flags fields. This is the mask for the mod part. ✨
  • #define LDB_FLAG_MOD_TYPE(flags) β€” Use this to extract the mod type (enum) from the operation. slay.
  • #define LDB_FLAG_MOD_ADD 1 β€” The value used in ldap_modify() to say "we're adding attributes". πŸ’–
  • #define LDB_FLAG_MOD_REPLACE 2 β€” The value used in ldap_modify() to say "we're replacing attributes". πŸ¦‹
  • #define LDB_FLAG_MOD_DELETE 3 β€” The value used in ldap_modify() to say "we're deleting attributes". πŸ’€
  • #define LDB_FLAG_FORCE_NO_BASE64_LDIF 4 β€” Flag value used in ldb_ldif_write_trace() to enforce binary encoded attribute values per attribute. no cap.
  • #define LDB_FLAG_INTERNAL_MASK 0xFFFFFFF0 β€” Flag bits on an element that are usable only by the internal implementation. πŸ‘‘
  • #define LDB_OID_COMPARATOR_AND '1.2.840.113556.1.4.803' β€” OID for logic AND comparison. iconic.
  • #define LDB_OID_COMPARATOR_OR '1.2.840.113556.1.4.804' β€” OID for logic OR comparison. πŸ’…
  • #define LDB_DEBUG_ALWAYS_LOG LDB_DEBUG_FATAL β€” (no description, just vibes)
  • #define LDB_FLG_RDONLY 1 β€” Flag value for database connection mode. 🌸
  • #define LDB_FLG_NOSYNC 2 β€” Flag value for database connection mode. ✨
  • #define LDB_FLG_RECONNECT 4 β€” Flag value to specify autoreconnect mode. πŸ”₯
  • #define LDB_FLG_NOMMAP 8 β€” Flag to tell backends not to use mmap. πŸ™ˆ
  • #define LDB_FLG_SHOW_BINARY 16 β€” Flag to tell ldif handlers not to force encoding of binary structures in base64. πŸŽ€
  • #define LDB_FLG_ENABLE_TRACING 32 β€” Flags to enable ldb tracing. πŸ‘‘
  • #define LDB_FLG_DONT_CREATE_DB 64 β€” Flags to tell LDB not to create a new database file: πŸ’œ
  • #define LDB_FLG_PRIVATE_MASK 0xff000000 β€” Allow DB create time flags that have meaning only to our calling application or modules. 🌈
  • #define LDB_ATTR_FLAG_HIDDEN (1<<0) β€” The attribute is not returned by default. lowkey sneaky.
  • #define LDB_ATTR_FLAG_ALLOCATED (1<<1) β€” (no description, just vibes)
  • #define LDB_ATTR_FLAG_FIXED (1<<2) β€” The attribute is supplied by the application and should not be removed. periodt.
  • #define LDB_ATTR_FLAG_UNIQUE_INDEX (1<<3) β€” (no description, just vibes)
  • #define LDB_ATTR_FLAG_SINGLE_VALUE (1<<4) β€” (no description, just vibes)
  • #define LDB_ATTR_FLAG_FORCE_BASE64_LDIF (1<<5) β€” (no description, just vibes)
  • #define LDB_ATTR_FLAG_FROM_DB (1<<6) β€” (no description, just vibes)
  • #define LDB_ATTR_FLAG_INDEXED (1<<7) β€” (no description, just vibes)
  • #define LDB_SYNTAX_DN '1.3.6.1.4.1.1466.115.121.1.12' β€” LDAP attribute syntax for a DN. πŸ’–
  • #define LDB_SYNTAX_DIRECTORY_STRING '1.3.6.1.4.1.1466.115.121.1.15' β€” LDAP attribute syntax for a Directory String. πŸ¦‹
  • #define LDB_SYNTAX_INTEGER '1.3.6.1.4.1.1466.115.121.1.27' β€” LDAP attribute syntax for an integer. πŸ”’
  • #define LDB_SYNTAX_ORDERED_INTEGER 'LDB_SYNTAX_ORDERED_INTEGER' β€” Custom attribute syntax for an integer whose index is lexicographically ordered by attribute value in the database. fancy.
  • #define LDB_SYNTAX_BOOLEAN '1.3.6.1.4.1.1466.115.121.1.7' β€” LDAP attribute syntax for a boolean. βœ…
  • #define LDB_SYNTAX_OCTET_STRING '1.3.6.1.4.1.1466.115.121.1.40' β€” LDAP attribute syntax for an octet string. 🧚
  • #define LDB_SYNTAX_UTC_TIME '1.3.6.1.4.1.1466.115.121.1.53' β€” LDAP attribute syntax for UTC time. ⏰
  • #define LDB_SYNTAX_GENERALIZED_TIME '1.3.6.1.4.1.1466.115.121.1.24' β€” (no description, just vibes)
  • #define LDB_SYNTAX_OBJECTCLASS 'LDB_SYNTAX_OBJECTCLASS' β€” (no description, just vibes)
  • #define LDB_CONTROL_BYPASS_OPERATIONAL_OID '1.3.6.1.4.1.7165.4.3.13' β€” OID for getting and manipulating attributes from the ldb without interception in the operational module. πŸ’…
  • #define LDB_CONTROL_BYPASS_OPERATIONAL_NAME 'bypassoperational' β€” (no description, just vibes)
  • #define LDB_CONTROL_RECALCULATE_RDN_OID '1.3.6.1.4.1.7165.4.3.30' β€” OID for recalculate RDN (rdn attribute and 'name') control. ✨
  • #define LDB_CONTROL_RECALCULATE_SD_OID '1.3.6.1.4.1.7165.4.3.5' β€” OID for recalculate SD control. 🌸
  • #define LDB_CONTROL_RECALCULATE_SD_NAME 'recalculate_sd' β€” (no description, just vibes)
  • #define LDB_CONTROL_REVEAL_INTERNALS '1.3.6.1.4.1.7165.4.3.6' β€” REVEAL_INTERNALS is used to reveal internal attributes and DN components which are not normally shown to the user. πŸ‘€
  • #define LDB_CONTROL_REVEAL_INTERNALS_NAME 'reveal_internals' β€” (no description, just vibes)
  • #define LDB_CONTROL_AS_SYSTEM_OID '1.3.6.1.4.1.7165.4.3.7' β€” LDB_CONTROL_AS_SYSTEM is used to skip access checks on operations that are performed by the system, but with a user's credentials, e.g. 😈
  • #define LDB_CONTROL_PROVISION_OID '1.3.6.1.4.1.7165.4.3.16' β€” LDB_CONTROL_PROVISION_OID is used to skip some constraint checks. πŸ¦‹
  • #define LDB_CONTROL_PROVISION_NAME 'provision' β€” (no description, just vibes)
  • #define LDB_CONTROL_PAGED_RESULTS_OID '1.2.840.113556.1.4.319' β€” OID for the paged results control. πŸ“„
  • #define LDB_CONTROL_PAGED_RESULTS_NAME 'paged_results' β€” (no description, just vibes)
  • #define LDB_CONTROL_SD_FLAGS_OID '1.2.840.113556.1.4.801' β€” OID for specifying the returned elements of the ntSecurityDescriptor. πŸ”
  • #define LDB_CONTROL_SD_FLAGS_NAME 'sd_flags' β€” (no description, just vibes)
  • #define LDB_CONTROL_DOMAIN_SCOPE_OID '1.2.840.113556.1.4.1339' β€” OID for specifying an advanced scope for the search (one partition). 🎯
  • #define LDB_CONTROL_DOMAIN_SCOPE_NAME 'domain_scope' β€” (no description, just vibes)
  • #define LDB_CONTROL_SEARCH_OPTIONS_OID '1.2.840.113556.1.4.1340' β€” OID for specifying an advanced scope for a search. πŸ”
  • #define LDB_CONTROL_SEARCH_OPTIONS_NAME 'search_options' β€” (no description, just vibes)
  • #define LDB_CONTROL_NOTIFICATION_OID '1.2.840.113556.1.4.528' β€” OID for notification. πŸ””
  • #define LDB_CONTROL_NOTIFICATION_NAME 'notification' β€” (no description, just vibes)
  • #define LDB_CONTROL_TREE_DELETE_OID '1.2.840.113556.1.4.805' β€” OID for performing subtree deletes. 🌳
  • #define LDB_CONTROL_TREE_DELETE_NAME 'tree_delete' β€” (no description, just vibes)
  • #define LDB_CONTROL_SHOW_DELETED_OID '1.2.840.113556.1.4.417' β€” OID for getting deleted objects. πŸ’€
  • #define LDB_CONTROL_SHOW_DELETED_NAME 'show_deleted' β€” (no description, just vibes)
  • #define LDB_CONTROL_SHOW_RECYCLED_OID '1.2.840.113556.1.4.2064' β€” OID for getting recycled objects. ♻️
  • #define LDB_CONTROL_SHOW_RECYCLED_NAME 'show_recycled' β€” (no description, just vibes)
  • #define LDB_CONTROL_SHOW_DEACTIVATED_LINK_OID '1.2.840.113556.1.4.2065' β€” OID for getting deactivated linked attributes. πŸ”—
  • #define LDB_CONTROL_SHOW_DEACTIVATED_LINK_NAME 'show_deactivated_link' β€” (no description, just vibes)
  • #define LDB_CONTROL_EXTENDED_DN_OID '1.2.840.113556.1.4.529' β€” OID for extended DN. 🧬
  • #define LDB_CONTROL_EXTENDED_DN_NAME 'extended_dn' β€” (no description, just vibes)
  • #define LDB_CONTROL_SERVER_SORT_OID '1.2.840.113556.1.4.473' β€” OID for LDAP server sort result extension. πŸ“Š
  • #define LDB_CONTROL_SERVER_SORT_NAME 'server_sort' β€” (no description, just vibes)
  • #define LDB_CONTROL_SORT_RESP_OID '1.2.840.113556.1.4.474' β€” OID for LDAP server sort result response extension. πŸ“ˆ
  • #define LDB_CONTROL_SORT_RESP_NAME 'server_sort_resp' β€” (no description, just vibes)
  • #define LDB_CONTROL_ASQ_OID '1.2.840.113556.1.4.1504' β€” OID for LDAP Attribute Scoped Query extension. πŸ”Ž
  • #define LDB_CONTROL_ASQ_NAME 'asq' β€” (no description, just vibes)
  • #define LDB_CONTROL_DIRSYNC_OID '1.2.840.113556.1.4.841' β€” OID for LDAP Directory Sync extension. πŸ”„
  • #define LDB_CONTROL_DIRSYNC_NAME 'dirsync' β€” (no description, just vibes)
  • #define LDB_CONTROL_DIRSYNC_EX_OID '1.2.840.113556.1.4.2090' β€” (no description, just vibes)
  • #define LDB_CONTROL_DIRSYNC_EX_NAME 'dirsync_ex' β€” (no description, just vibes)
  • #define LDB_CONTROL_VLV_REQ_OID '2.16.840.1.113730.3.4.9' β€” OID for LDAP Virtual List View Request extension. πŸ‘οΈ
  • #define LDB_CONTROL_VLV_REQ_NAME 'vlv' β€” (no description, just vibes)
  • #define LDB_CONTROL_VLV_RESP_OID '2.16.840.1.113730.3.4.10' β€” OID for LDAP Virtual List View Response extension. πŸ“‹
  • #define LDB_CONTROL_VLV_RESP_NAME 'vlv_resp' β€” (no description, just vibes)
  • #define LDB_CONTROL_PERMISSIVE_MODIFY_OID '1.2.840.113556.1.4.1413' β€” OID to let modifies don't give an error when adding an existing attribute with the same value or deleting an nonexisting one attribute. chill mode. 😌
  • #define LDB_CONTROL_PERMISSIVE_MODIFY_NAME 'permissive_modify' β€” (no description, just vibes)
  • #define LDB_CONTROL_SERVER_LAZY_COMMIT '1.2.840.113556.1.4.619' β€” OID to allow the server to be more 'fast and loose' with the data being added. πŸƒ
  • #define LDB_CONTROL_RODC_DCPROMO_OID '1.2.840.113556.1.4.1341' β€” Control for RODC join -see [MS-ADTS] section 3.1.1.3.4.1.23. πŸ“š
  • #define LDB_CONTROL_RODC_DCPROMO_NAME 'rodc_join' β€” (no description, just vibes)
  • #define LDB_CONTROL_RELAX_OID '1.3.6.1.4.1.4203.666.5.12' β€” OID for the allowing client to request temporary relaxed enforcement of constraints of the x.500 model. 😎
  • #define LDB_CONTROL_RELAX_NAME 'relax' β€” (no description, just vibes)
  • #define LDB_CONTROL_VERIFY_NAME_OID '1.2.840.113556.1.4.1338' β€” OID for the allowing some kind of relax check for attributes with DNs. βœ…
  • #define LDB_CONTROL_VERIFY_NAME_NAME 'verify_name' β€” (no description, just vibes)
  • #define LDB_EXTENDED_SEQUENCE_NUMBER '1.3.6.1.4.1.7165.4.4.3' β€” OID for LDAP Extended Operation SEQUENCE_NUMBER. πŸ”’
  • #define LDB_EXTENDED_PASSWORD_CHANGE_OID '1.3.6.1.4.1.4203.1.11.1' β€” OID for LDAP Extended Operation PASSWORD_CHANGE. πŸ”‘
  • #define LDB_EXTENDED_FAST_BIND_OID '1.2.840.113556.1.4.1781' β€” OID for LDAP Extended Operation FAST_BIND. ⚑
  • #define LDB_EXTENDED_START_TLS_OID '1.3.6.1.4.1.1466.20037' β€” OID for LDAP Extended Operation START_TLS. πŸ”’
  • #define LDB_EXTENDED_DYNAMIC_OID '1.3.6.1.4.1.1466.101.119.1' β€” OID for LDAP Extended Operation DYNAMIC_REFRESH. πŸ”„
  • #define LDB_EXTENDED_WHOAMI_OID '1.3.6.1.4.1.4203.1.11.3' β€” OID for RFC4532 WhoAmI"extendedoperation. πŸͺž
  • #define LDB_CONTROL_POLICY_HINTS_OID '1.2.840.113556.1.4.2239' β€” OID used to enforce password history length constraints in password reset. πŸ“œ
  • #define LDB_CONTROL_POLICY_HINTS_NAME 'policy_hints' β€” (no description, just vibes)
  • #define LDB_CONTROL_POLICY_HINTS_DEPRECATED_OID '1.2.840.113556.1.4.2066' β€” Another OID used to enforce password history length constraints in password reset. πŸ‘΅
  • #define LDB_CONTROL_POLICY_HINTS_DEPRECATED_NAME 'policy_hints_deprecated' β€” (no description, just vibes)
  • #define LDB_SEARCH_OPTION_DOMAIN_SCOPE 0x00000001 β€” (no description, just vibes)
  • #define LDB_SEARCH_OPTION_PHANTOM_ROOT 0x00000002 β€” (no description, just vibes)
  • #define LDB_SEQ_GLOBAL_SEQUENCE 0x01 β€” (no description, just vibes)
  • #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 β€” (no description, just vibes)
  • #define ldb_attr_cmp(a, b) β€” Compare two attributes. πŸ”
  • #define discard_const(ptr) β€” (no description, just vibes)
  • #define LDB_TYPESAFE_QSORT(base, numel, opaque, comparison) β€” (no description, just vibes)
  • #define TYPESAFE_QSORT(base, numel, comparison) β€” (no description, just vibes)
  • #define NUMERIC_CMP(a, b) β€” (no description, just vibes)
  • #define LDB_REQ_SET_LOCATION(req) β€” (no description, just vibes)

✨ Typedefs ✨

and now the typedefs, bestie. these are the function pointer types that make LDB go round. no descriptions here, just the exact signatures. copy them with love. πŸ’–

  • typedef int(* ldb_attr_handler_t) (struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, struct ldb_val *)
  • typedef int(* ldb_attr_comparison_t) (struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, const struct ldb_val *)
  • typedef int(* ldb_attr_operator_t) (struct ldb_context *, enum ldb_parse_op operation, const struct ldb_schema_attribute *a, const struct ldb_val *, const struct ldb_val *, bool *matched)
  • typedef int(* ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque)
  • typedef int(* ldb_request_callback_t) (struct ldb_request *, struct ldb_reply *)

✨ Enumerations ✨

okay so now we're at the enum part and honestly? this is where ldb.h really starts cooking πŸ”₯. These are all the named integer constants the header hands you, and every single one of them is here β€” nothing skipped, nothing summarised, periodt. Let's take them one at a time, bestie. πŸ’…


πŸ¦‹ enum ldb_changetype

enum ldb_changetype { LDB_CHANGETYPE_NONE =0, LDB_CHANGETYPE_ADD,
    LDB_CHANGETYPE_DELETE, LDB_CHANGETYPE_MODIFY, LDB_CHANGETYPE_MODRDN
    }
  • LDB_CHANGETYPE_NONE β€” parked at =0, the "nothing to see here" one.
  • LDB_CHANGETYPE_ADD β€” the add one, going by the name.
  • LDB_CHANGETYPE_DELETE β€” and this is the delete one.
  • LDB_CHANGETYPE_MODIFY β€” modify energy.
  • LDB_CHANGETYPE_MODRDN β€” the mod-RDN one, which is literally what the identifier spells out.

🌸 enum ldb_scope

enum ldb_scope { LDB_SCOPE_DEFAULT =-1, LDB_SCOPE_BASE =0,
    LDB_SCOPE_ONELEVEL =1, LDB_SCOPE_SUBTREE =2 }
  • LDB_SCOPE_DEFAULT β€” -1, the "you pick for me" value.
  • LDB_SCOPE_BASE β€” 0.
  • LDB_SCOPE_ONELEVEL β€” 1.
  • LDB_SCOPE_SUBTREE β€” 2.

those are your four scope values, all spelled out in the declaration, no guessing required πŸ’–

πŸŽ€ enum ldb_debug_level

enum ldb_debug_level { LDB_DEBUG_FATAL, LDB_DEBUG_ERROR,
    LDB_DEBUG_WARNING, LDB_DEBUG_TRACE }
  • LDB_DEBUG_FATAL
  • LDB_DEBUG_ERROR
  • LDB_DEBUG_WARNING
  • LDB_DEBUG_TRACE

no explicit numbers written next to these ones, so that's exactly how the header lists them β€” in that order, top to bottom. 🫢

🧚 enum ldb_parse_op

enum ldb_parse_op { LDB_OP_AND =1, LDB_OP_OR =2, LDB_OP_NOT =3,
    LDB_OP_EQUALITY =4, LDB_OP_SUBSTRING =5, LDB_OP_GREATER =6,
    LDB_OP_LESS =7, LDB_OP_PRESENT =8, LDB_OP_APPROX =9, LDB_OP_EXTENDED
    =10 }
  • LDB_OP_AND β€” =1
  • LDB_OP_OR β€” =2
  • LDB_OP_NOT β€” =3
  • LDB_OP_EQUALITY β€” =4
  • LDB_OP_SUBSTRING β€” =5
  • LDB_OP_GREATER β€” =6
  • LDB_OP_LESS β€” =7
  • LDB_OP_PRESENT β€” =8
  • LDB_OP_APPROX β€” =9
  • LDB_OP_EXTENDED β€” =10

ten ops, numbered 1 through 10, and yes we listed every single one because that's the whole assignment πŸ’…

🌈 enum ldb_request_type

enum ldb_request_type { LDB_SEARCH, LDB_ADD, LDB_MODIFY, LDB_DELETE,
    LDB_RENAME, LDB_EXTENDED, LDB_REQ_REGISTER_CONTROL,
    LDB_REQ_REGISTER_PARTITION }
  • LDB_SEARCH
  • LDB_ADD
  • LDB_MODIFY
  • LDB_DELETE
  • LDB_RENAME
  • LDB_EXTENDED
  • LDB_REQ_REGISTER_CONTROL
  • LDB_REQ_REGISTER_PARTITION

eight request types, in that exact order, no explicit values written in the declaration. πŸ‘‘

⭐ enum ldb_reply_type

enum ldb_reply_type { LDB_REPLY_ENTRY, LDB_REPLY_REFERRAL,
    LDB_REPLY_DONE }
  • LDB_REPLY_ENTRY
  • LDB_REPLY_REFERRAL
  • LDB_REPLY_DONE

three reply types, done and dusted. πŸŽ€

πŸ’œ enum ldb_wait_type

enum ldb_wait_type { LDB_WAIT_ALL, LDB_WAIT_NONE }
  • LDB_WAIT_ALL
  • LDB_WAIT_NONE

just the two of them, living their best lives.

πŸ“ enum ldb_state

enum ldb_state { LDB_ASYNC_INIT, LDB_ASYNC_PENDING, LDB_ASYNC_DONE }
  • LDB_ASYNC_INIT
  • LDB_ASYNC_PENDING
  • LDB_ASYNC_DONE

the async state trio, in that order, exactly as written.

πŸ¦‹ enum ldb_sequence_type

enum ldb_sequence_type { LDB_SEQ_HIGHEST_SEQ, LDB_SEQ_HIGHEST_TIMESTAMP,
    LDB_SEQ_NEXT }
  • LDB_SEQ_HIGHEST_SEQ
  • LDB_SEQ_HIGHEST_TIMESTAMP
  • LDB_SEQ_NEXT

and that's the last one β€” three sequence types, no explicit values given, and we are not skipping any of them. iykyk 🌸


lowkey important bestie: all ten of these enums are listed with exactly the members and exactly the values the header declares. If you're writing code against ldb.h, use the identifiers, not the raw numbers β€” the numbers are just what they happen to be set to. πŸ’–

✨ FUNCTIONS ✨

okay bestie, this is the function buffet and it is long. grab a snack, hydrate, and let's get into it πŸ’… every single signature is here, no skips, no cuts, periodt.


  • struct ldb_parse_tree * ldb_parse_tree (TALLOC_CTX *mem_ctx, const char *s) β€” no extra notes in the source, just the signature, bestie.
  • char * ldb_filter_from_tree (TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tree) β€” same, just the signature.
  • char * ldb_binary_encode (TALLOC_CTX *mem_ctx, struct ldb_val val) β€” Encode a binary blob.
  • char * ldb_binary_encode_string (TALLOC_CTX *mem_ctx, const char *string) β€” Encode a string.
  • const struct ldb_schema_attribute * ldb_schema_attribute_by_name (struct ldb_context *ldb, const char *name) β€” just the signature.
  • const struct ldb_dn_extended_syntax * ldb_dn_extended_syntax_by_name (struct ldb_context *ldb, const char *name) β€” just the signature.
  • int ldb_request (struct ldb_context *ldb, struct ldb_request *request) β€” just the signature.
  • int ldb_request_done (struct ldb_request *req, int status) β€” just the signature.
  • bool ldb_request_is_done (struct ldb_request *req) β€” just the signature.
  • int ldb_modules_wait (struct ldb_handle *handle) β€” just the signature.
  • int ldb_wait (struct ldb_handle *handle, enum ldb_wait_type type) β€” just the signature.
  • int ldb_set_timeout (struct ldb_context *ldb, struct ldb_request *req, int timeout) β€” just the signature.
  • int ldb_set_timeout_from_prev_req (struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq) β€” just the signature.
  • void ldb_set_create_perms (struct ldb_context *ldb, unsigned int perms) β€” just the signature.
  • void ldb_set_modules_dir (struct ldb_context *ldb, const char *path) β€” just the signature.
  • void ldb_set_event_context (struct ldb_context *ldb, struct tevent_context *ev) β€” just the signature.
  • struct tevent_context * ldb_get_event_context (struct ldb_context *ldb) β€” just the signature.
  • int ldb_global_init (void) β€” Initialise ldbs' global information.
  • struct ldb_context * ldb_init (TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx) β€” Initialise an ldb context.
  • int ldb_connect (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]) β€” Connect to a database.
  • struct ldb_dn * ldb_get_root_basedn (struct ldb_context *ldb) β€” just the signature.
  • struct ldb_dn * ldb_get_config_basedn (struct ldb_context *ldb) β€” just the signature.
  • struct ldb_dn * ldb_get_schema_basedn (struct ldb_context *ldb) β€” just the signature.
  • struct ldb_dn * ldb_get_default_basedn (struct ldb_context *ldb) β€” just the signature.
  • int ldb_search_default_callback (struct ldb_request *req, struct ldb_reply *ares) β€” The default async search callback function.
  • int ldb_op_default_callback (struct ldb_request *req, struct ldb_reply *ares) β€” The default async extended operation callback function.
  • int ldb_modify_default_callback (struct ldb_request *req, struct ldb_reply *ares) β€” just the signature.
  • int ldb_build_search_req (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char *const *attrs, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” Helper function to build a search request.
  • int ldb_build_search_req_ex (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char *const *attrs, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” just the signature.
  • int ldb_build_add_req (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” Helper function to build an add request.
  • int ldb_build_mod_req (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” Helper function to build a modify request.
  • int ldb_build_del_req (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” Helper function to build a delete request.
  • int ldb_build_rename_req (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn *olddn, struct ldb_dn *newdn, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” Helper function to build a rename request.
  • int ldb_request_add_control (struct ldb_request *req, const char *oid, bool critical, void *data) β€” Add a ldb_control to a ldb_request.
  • int ldb_request_replace_control (struct ldb_request *req, const char *oid, bool critical, void *data) β€” replace a ldb_control in a ldb_request
  • struct ldb_control * ldb_controls_get_control (struct ldb_control **controls, const char *oid) β€” check if a control with the specified oid"existandreturnit
  • struct ldb_control * ldb_request_get_control (struct ldb_request *req, const char *oid) β€” check if a control with the specified oid"existandreturnit
  • struct ldb_control * ldb_reply_get_control (struct ldb_reply *rep, const char *oid) β€” check if a control with the specified oid"existandreturnit
  • int ldb_search (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, struct ldb_dn *base, enum ldb_scope scope, const char *const *attrs, const char *exp_fmt,...) PRINTF_ATTRIBUTE(7 β€” Search the database.
  • int int ldb_add (struct ldb_context *ldb, const struct ldb_message *message) β€” Add a record to the database.
  • int ldb_modify (struct ldb_context *ldb, const struct ldb_message *message) β€” Modify the specified attributes of a record.
  • int ldb_rename (struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *newdn) β€” Rename a record in the database.
  • int ldb_delete (struct ldb_context *ldb, struct ldb_dn *dn) β€” Delete a record from the database.
  • int ldb_extended_default_callback (struct ldb_request *req, struct ldb_reply *ares) β€” The default async extended operation callback function.
  • int ldb_build_extended_req (struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *oid, void *data, struct ldb_control **controls, void *context, ldb_request_callback_t callback, struct ldb_request *parent) β€” Helper function to build a extended request.
  • int ldb_extended (struct ldb_context *ldb, const char *oid, void *data, struct ldb_result **res) β€” call an extended operation
  • int ldb_sequence_number (struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num) β€” Obtain current/next database sequence number.
  • int ldb_transaction_start (struct ldb_context *ldb) β€” start a transaction
  • int ldb_transaction_prepare_commit (struct ldb_context *ldb) β€” first phase of two phase commit
  • int ldb_transaction_commit (struct ldb_context *ldb) β€” commit a transaction
  • int ldb_transaction_cancel (struct ldb_context *ldb) β€” cancel a transaction
  • int ldb_transaction_cancel_noerr (struct ldb_context *ldb) β€” just the signature.
  • const char * ldb_errstring (struct ldb_context *ldb) β€” return extended error information from the last call
  • const char * ldb_strerror (int ldb_err) β€” return a string explaining what a ldb error constant means
  • void ldb_set_utf8_default (struct ldb_context *ldb) β€” setup the default utf8 functions FIXME: these functions do not yet handle utf8 😭
  • char * ldb_casefold (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s, size_t n) β€” Casefold a string.
  • int ldb_valid_attr_name (const char *s) β€” Check the attribute name is valid according to rfc2251.
  • int ldb_ldif_write (struct ldb_context *ldb, int(*fprintf_fn)(void *, const char *,...) PRINTF_ATTRIBUTE(2, 3), void *private_data, const struct ldb_ldif *ldif) β€” Write an LDIF message.
  • void ldb_ldif_read_free (struct ldb_context *ldb, struct ldb_ldif *msg) β€” Clean up an LDIF message.
  • struct ldb_ldif * ldb_ldif_read (struct ldb_context *ldb, int(*fgetc_fn)(void *), void *private_data) β€” Read an LDIF message.
  • struct ldb_ldif * ldb_ldif_read_file (struct ldb_context *ldb, FILE *f) β€” Read an LDIF message from a file.
  • struct ldb_ldif * ldb_ldif_read_string (struct ldb_context *ldb, const char **s) β€” Read an LDIF message from a string.
  • int ldb_ldif_parse_modrdn (struct ldb_context *ldb, const struct ldb_ldif *ldif, TALLOC_CTX *mem_ctx, struct ldb_dn **olddn, struct ldb_dn **newrdn, bool *deleteoldrdn, struct ldb_dn **newsuperior, struct ldb_dn **newdn) β€” Parse a modrdn LDIF message from a struct ldb_message.
  • int ldb_ldif_write_file (struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg) β€” Write an LDIF message to a file.
  • char * ldb_ldif_write_string (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const struct ldb_ldif *msg) β€” Write an LDIF message to a string.
  • char * ldb_ldif_message_string (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, enum ldb_changetype changetype, const struct ldb_message *msg) β€” Write an LDB message to a string.
  • char * ldb_ldif_message_redacted_string (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, enum ldb_changetype changetype, const struct ldb_message *msg) β€” Write an LDB message to a string.
  • char * ldb_base64_encode (TALLOC_CTX *mem_ctx, const char *buf, int len) β€” Base64 encode a buffer.
  • int ldb_base64_decode (char *s) β€” Base64 decode a buffer.
  • const char * ldb_dn_get_linearized (struct ldb_dn *dn) β€” Get the linear form of a DN (without any extended components).
  • char * ldb_dn_alloc_linearized (TALLOC_CTX *mem_ctx, struct ldb_dn *dn) β€” Allocate a copy of the linear form of a DN (without any extended components) onto the supplied memory context.
  • char * ldb_dn_get_extended_linearized (TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int mode) β€” Get the linear form of a DN (with any extended components).
  • const struct ldb_val * ldb_dn_get_extended_component (struct ldb_dn *dn, const char *name) β€” just the signature.
  • int ldb_dn_set_extended_component (struct ldb_dn *dn, const char *name, const struct ldb_val *val) β€” just the signature.
  • void ldb_dn_extended_filter (struct ldb_dn *dn, const char *const *accept_list) β€” just the signature.
  • void ldb_dn_remove_extended_components (struct ldb_dn *dn) β€” just the signature.
  • bool ldb_dn_has_extended (struct ldb_dn *dn) β€” just the signature.
  • int ldb_dn_extended_add_syntax (struct ldb_context *ldb, unsigned flags, const struct ldb_dn_extended_syntax *syntax) β€” just the signature.
  • struct ldb_dn * ldb_dn_new (TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn) β€” Allocate a new DN from a string.
  • struct ldb_dn * ldb_dn_new_fmt (TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt,...) PRINTF_ATTRIBUTE(3 β€” Allocate a new DN from a printf style format string and arguments.
  • struct ldb_dn struct ldb_dn * ldb_dn_from_ldb_val (TALLOC_CTX *mem_ctx, β€” just the signature.

okay continuing the DN zone, no pauses πŸ’… β€” and heads up, this very first one is literally the back half of a prototype that started on the last page, so here it is verbatim:

struct ldb_context *ldb, const struct ldb_val *strdn)
  • that fragment above β€” Allocate a new DN from a struct ldb_val (useful to avoid buffer overrun). bestie it's the "please don't overrun my buffer" girlie 🫢
  • bool ldb_dn_validate (struct ldb_dn *dn) β€” Determine if this DN is syntactically valid. vibe check for your DN, basically πŸŽ€
  • char * ldb_dn_escape_value (TALLOC_CTX *mem_ctx, struct ldb_val value) β€” escaping time ✨
  • const char * ldb_dn_get_casefold (struct ldb_dn *dn) β€” casefold, get it πŸ‘‘
  • char * ldb_dn_alloc_casefold (TALLOC_CTX *mem_ctx, struct ldb_dn *dn) β€” casefold but it allocates, iconic
  • int ldb_dn_compare_base (struct ldb_dn *base, struct ldb_dn *dn) β€” comparing bases
  • int ldb_dn_compare (struct ldb_dn *edn0, struct ldb_dn *edn1) β€” the classic DN-vs-DN showdown πŸ’€
  • bool ldb_dn_add_base (struct ldb_dn *dn, struct ldb_dn *base) β€” bolt a base onto a DN
  • bool ldb_dn_add_base_fmt (struct ldb_dn *dn, const char *base_fmt,...) PRINTF_ATTRIBUTE(2 β€” same energy, but with a format string, so it's fancy πŸ’–
  • bool bool ldb_dn_add_child (struct ldb_dn *dn, struct ldb_dn *child) β€” yes the bool bool is really in there, don't come for me, I'm copying it character for character 😭
  • bool ldb_dn_add_child_fmt (struct ldb_dn *dn, const char *child_fmt,...) PRINTF_ATTRIBUTE(2 β€” child + format string
  • bool bool ldb_dn_remove_base_components (struct ldb_dn *dn, unsigned int num) β€” again, bool bool, verbatim, slay
  • bool ldb_dn_remove_child_components (struct ldb_dn *dn, unsigned int num) β€” popping num child components
  • bool ldb_dn_add_child_val (struct ldb_dn *dn, const char *rdn, struct ldb_val value) β€” new child from an rdn and an ldb_val
  • struct ldb_dn * ldb_dn_copy (TALLOC_CTX *mem_ctx, struct ldb_dn *dn) β€” copy that DN, twin energy πŸ¦‹
  • struct ldb_dn * ldb_dn_copy_with_ldb_context (TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct ldb_context *ldb) β€” copy but bring your own ldb context
  • struct ldb_dn * ldb_dn_get_parent (TALLOC_CTX *mem_ctx, struct ldb_dn *dn) β€” get the parent, mother is mothering πŸ’œ
  • char * ldb_dn_canonical_string (TALLOC_CTX *mem_ctx, struct ldb_dn *dn) β€” canonical string version
  • char * ldb_dn_canonical_ex_string (TALLOC_CTX *mem_ctx, struct ldb_dn *dn) β€” canonical ex string version, the extra letter is doing a lot
  • int ldb_dn_get_comp_num (struct ldb_dn *dn) β€” how many components?
  • int ldb_dn_get_extended_comp_num (struct ldb_dn *dn) β€” how many extended components?
  • const char * ldb_dn_get_component_name (struct ldb_dn *dn, unsigned int num) β€” the name of component number num
  • const struct ldb_val * ldb_dn_get_component_val (struct ldb_dn *dn, unsigned int num) β€” the value of component number num
  • const char * ldb_dn_get_rdn_name (struct ldb_dn *dn) β€” the RDN's name
  • const struct ldb_val * ldb_dn_get_rdn_val (struct ldb_dn *dn) β€” the RDN's value
  • int ldb_dn_set_component (struct ldb_dn *dn, int num, const char *name, const struct ldb_val val) β€” set component num to this name + value
  • bool ldb_dn_is_valid (struct ldb_dn *dn) β€” is it valid? we need answers πŸ”₯
  • bool ldb_dn_is_special (struct ldb_dn *dn) β€” is it special? (it's giving main character energy ✨)
  • bool ldb_dn_check_special (struct ldb_dn *dn, const char *check) β€” check if it matches that special thing
  • bool ldb_dn_is_null (struct ldb_dn *dn) β€” is it null tho
  • int ldb_dn_update_components (struct ldb_dn *dn, const struct ldb_dn *ref_dn) β€” refresh your components against ref_dn

okay that's the DN girlies done, now we're on the attribute-name girls 🌸

  • char * ldb_attr_casefold (TALLOC_CTX *mem_ctx, const char *s) β€” casefold an attribute string
  • int ldb_attr_dn (const char *attr) β€” is this attribute a DN? asks attr directly

and now… the ldb_message era, which is genuinely most of this page, brace yourself bestie 😭

  • struct ldb_message * ldb_msg_new (TALLOC_CTX *mem_ctx) β€” Create an empty message. blank slate, fresh start, new me πŸŽ€
  • struct ldb_message_element * ldb_msg_find_element (const struct ldb_message *msg, const char *attr_name) β€” Find an element within an message. yes it says "an message", I'm not editing the original's grammar, that's not my job πŸ’…
  • int ldb_val_equal_exact (const struct ldb_val *v1, const struct ldb_val *v2) β€” Compare two ldb_val values. exactly, no vibes-based matching
  • struct ldb_val * ldb_msg_find_val (const struct ldb_message_element *el, struct ldb_val *val) β€” find a value within an ldb_message_element
  • int ldb_msg_add_empty (struct ldb_message *msg, const char *attr_name, int flags, struct ldb_message_element **return_el) β€” add a new empty element to a ldb_message
  • int ldb_msg_element_add_value (TALLOC_CTX *mem_ctx, struct ldb_message_element *el, const struct ldb_val *val) β€” add a value to a message element
  • int ldb_msg_add (struct ldb_message *msg, const struct ldb_message_element *el, int flags) β€” add a element to a ldb_message. "a element." iconic. we keep it 🫢
  • int ldb_msg_add_value (struct ldb_message *msg, const char *attr_name, const struct ldb_val *val, struct ldb_message_element **return_el) β€” add a value by attribute name
  • int ldb_msg_add_steal_value (struct ldb_message *msg, const char *attr_name, struct ldb_val *val) β€” add a value and steal it (ownership snatched, no cap)
  • int ldb_msg_add_steal_string (struct ldb_message *msg, const char *attr_name, char *str) β€” same but string flavored
  • int ldb_msg_add_string_flags (struct ldb_message *msg, const char *attr_name, const char *str, int flags) β€” add a string, but with flags
  • int ldb_msg_add_string (struct ldb_message *msg, const char *attr_name, const char *str) β€” add a string, no flags, simple life 🌈
  • int ldb_msg_add_linearized_dn (struct ldb_message *msg, const char *attr_name, struct ldb_dn *dn) β€” add a linearized DN
  • int ldb_msg_add_fmt (struct ldb_message *msg, const char *attr_name, const char *fmt,...) PRINTF_ATTRIBUTE(3 β€” add a formatted thing
  • int int ldb_msg_append_value (struct ldb_message *msg, const char *attr_name, const struct ldb_val *val, int flags) β€” append a element to a ldb_message. yep, int int. verbatim. don't look at me πŸ™ˆ
  • int ldb_msg_append_steal_value (struct ldb_message *msg, const char *attr_name, struct ldb_val *val, int flags) β€” append + steal a value
  • int ldb_msg_append_steal_string (struct ldb_message *msg, const char *attr_name, char *str, int flags) β€” append + steal a string
  • int ldb_msg_append_string (struct ldb_message *msg, const char *attr_name, const char *str, int flags) β€” append a string
  • int ldb_msg_append_linearized_dn (struct ldb_message *msg, const char *attr_name, struct ldb_dn *dn, int flags) β€” append a linearized DN
  • int ldb_msg_append_fmt (struct ldb_message *msg, int flags, const char *attr_name, const char *fmt,...) PRINTF_ATTRIBUTE(4 β€” append, formatted, and note the argument order: flags comes before attr_name here πŸ‘€
  • int int ldb_msg_element_compare (struct ldb_message_element *el1, struct ldb_message_element *el2) β€” compare two message elements - return 0 on match. (int int again, we're loyal to the source πŸ’–)
  • int ldb_msg_element_compare_name (struct ldb_message_element *el1, struct ldb_message_element *el2) β€” compare just the names of two elements
  • const struct ldb_val * ldb_msg_find_ldb_val (const struct ldb_message *msg, const char *attr_name) β€” Find elements in a message. and then hand you back a ldb_val
  • int ldb_msg_find_attr_as_int (const struct ldb_message *msg, const char *attr_name, int default_value) β€” find it, read it as an int, fall back to default_value
  • unsigned int ldb_msg_find_attr_as_uint (const struct ldb_message *msg, const char *attr_name, unsigned int default_value) β€” same but unsigned int
  • int64_t ldb_msg_find_attr_as_int64 (const struct ldb_message *msg, const char *attr_name, int64_t default_value) β€” same but int64_t
  • uint64_t ldb_msg_find_attr_as_uint64 (const struct ldb_message *msg, const char *attr_name, uint64_t default_value) β€” same but uint64_t
  • double ldb_msg_find_attr_as_double (const struct ldb_message *msg, const char *attr_name, double default_value) β€” same but double ✨
  • int ldb_msg_find_attr_as_bool (const struct ldb_message *msg, const char *attr_name, int default_value) β€” same but as a bool, returned as an int, classic C behavior πŸŽ€
  • const char * ldb_msg_find_attr_as_string (const struct ldb_message *msg, const char *attr_name, const char *default_value) β€” same but as a string
  • struct ldb_dn * ldb_msg_find_attr_as_dn (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const struct ldb_message *msg, const char *attr_name) β€” same but as a DN, and yes it needs both an ldb and a mem_ctx 🌸
  • void ldb_msg_sort_elements (struct ldb_message *msg) β€” sort those elements, organize your life bestie
  • struct ldb_message * ldb_msg_copy_shallow (TALLOC_CTX *mem_ctx, const struct ldb_message *msg) β€” a shallow copy, so it's copying the surface not the soul πŸ’…
  • struct ldb_message * ldb_msg_copy (TALLOC_CTX *mem_ctx, const struct ldb_message *msg) β€” the full copy
  • struct ldb_message * ldb_msg_canonicalize (struct ldb_context *ldb, const struct ldb_message *msg) _DEPRECATED_ β€” > deprecated, so maybe don't start anything new with it 🚫
  • int ldb_msg_normalize (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const struct ldb_message *msg, struct ldb_message **_msg_out) β€” the non-deprecated normalizing girlie, output lands in _msg_out
  • struct ldb_message * ldb_msg_diff (struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2) _DEPRECATED_ β€” > also deprecated, bestie, heads up
  • int ldb_msg_difference (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg1, struct ldb_message *msg2, struct ldb_message **_msg_out) β€” return a ldb_message representing the differences between msg1 and msg2.
  • int ldb_msg_check_string_attribute (const struct ldb_message *msg, const char *name, const char *value) β€” Tries to find a certain string attribute in a message.
  • int ldb_msg_sanity_check (struct ldb_context *ldb, const struct ldb_message *msg) β€” Integrity check an ldb_message. the vibe check, but for data 🫢

okay we made it past the message mountain, take a breath, hydrate πŸ“

  • struct ldb_val ldb_val_dup (TALLOC_CTX *mem_ctx, const struct ldb_val *v) β€” Duplicate an ldb_val structure.
  • int ldb_set_debug (struct ldb_context *ldb, void(*debug)(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0), void *context) β€” this allows the user to set a debug function for error reporting
  • void ldb_set_utf8_functions (struct ldb_context *ldb, void *context, char *(*casefold)(void *, void *, const char *, size_t n), int(*casecmp)(void *ctx, const struct ldb_val *v1, const struct ldb_val *v2)) β€” This allows the user to set custom utf8 functions.
  • void ldb_set_utf8_fns (struct ldb_context *ldb, void *context, char *(*casefold)(void *, void *, const char *, size_t n)) _DEPRECATED_ β€” This legacy function is for setting a custom utf8 casefold function. > deprecated legacy energy, use the newer one above πŸ’…
  • int ldb_set_debug_stderr (struct ldb_context *ldb) β€” this sets up debug to print messages on stderr
  • int ldb_set_opaque (struct ldb_context *ldb, const char *name, void *value) β€” stash something opaque under a name
  • void * ldb_get_opaque (struct ldb_context *ldb, const char *name) β€” grab that opaque thing back out
  • const char ** ldb_attr_list_copy (TALLOC_CTX *mem_ctx, const char *const *attrs) β€” copy an attribute list
  • const char ** ldb_attr_list_copy_add (TALLOC_CTX *mem_ctx, const char *const *attrs, const char *new_attr) β€” copy it and add new_attr, multitasking queen πŸ‘‘
  • int ldb_attr_in_list (const char *const *attrs, const char *attr) β€” is attr in attrs??
  • int ldb_msg_rename_attr (struct ldb_message *msg, const char *attr, const char *replace) β€” rename attr to replace
  • int ldb_msg_copy_attr (struct ldb_message *msg, const char *attr, const char *replace) β€” copy attr over to replace
  • void ldb_msg_remove_attr (struct ldb_message *msg, const char *attr) β€” bye bye attribute πŸ¦‹
  • void ldb_msg_remove_element (struct ldb_message *msg, struct ldb_message_element *el) β€” bye bye element
  • void ldb_parse_tree_attr_replace (struct ldb_parse_tree *tree, const char *attr, const char *replace) β€” swap attr for replace inside a parse tree
  • struct ldb_parse_tree * ldb_parse_tree_copy_shallow (TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *ot) β€” shallow copy of a parse tree
  • char * ldb_timestring (TALLOC_CTX *mem_ctx, time_t t) β€” Convert a time structure to a string.
  • time_t ldb_string_to_time (const char *s) β€” Convert a string to a time structure.
  • int ldb_val_to_time (const struct ldb_val *v, time_t *t) β€” convert a LDAP GeneralizedTime string in ldb_val format to a time_t.
  • char * ldb_timestring_utc (TALLOC_CTX *mem_ctx, time_t t) β€” Convert a time structure to a string. (the UTC one ⭐)
  • time_t ldb_string_utc_to_time (const char *s) β€” Convert a string to a time structure. (UTC again, consistent queen 🌈)
  • void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp) β€” sorting, but make it ldb
  • char * ldb_control_to_string (TALLOC_CTX *mem_ctx, const struct ldb_control *control) β€” Convert a control into its string representation.
  • struct ldb_control * ldb_parse_control_from_string (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *control_strings) β€” Convert a string representing a control into a ldb_control structure.
  • struct ldb_control ** ldb_parse_control_strings (struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char **control_strings) β€” Convert an array of string representation of a control into an array of ldb_control structures.
  • unsigned int ldb_get_flags (struct ldb_context *ldb) β€” return the ldb flags πŸŽ€
void ldb_set_flags (struct ldb_context *ldb, unsigned flags)
struct ldb_dn * ldb_dn_binary_from_ldb_val (TALLOC_CTX *mem_ctx, struct
    ldb_context *ldb, const struct ldb_val *strdn)
int ldb_dn_get_binary (struct ldb_dn *dn, struct ldb_val *val)
int ldb_dn_set_binary (struct ldb_dn *dn, struct ldb_val *val)
void ldb_req_set_location (struct ldb_request *req, const char
    *location)
const char * ldb_req_location (struct ldb_request *req)
bool ldb_dn_minimise (struct ldb_dn *dn)
int ldb_val_string_cmp (const struct ldb_val *v, const char *str)

🌈 Detailed Description 🌈

Samba's ldb database. πŸ’–

This header file provides the main API for ldb. Like, the whole vibe of ldb lives in here. It's giving "everything you need, bestie". 🫢


πŸŽ€ Macro Definition Documentation πŸŽ€

okay this next bit is the macro section and it is LONG but it is also lowkey iconic so stay with me πŸ’…

#define discard_const( ptr)

Value:

((void *)((uintptr_t)(ptr)))

#define ldb_attr_cmp( a, b)

Value:

strcasecmp(a, b)

Compare two attributes. This function compares to attribute names. Note that this is a case-insensitive comparison. ✨

Parameters

  • a β€” the first attribute name to compare
  • b β€” the second attribute name to compare

Returns

0 if the attribute names are the same, or only differ in case; non-zero if there are any differences 🌸

attribute names are restricted by rfc2251 so using strcasecmp and toupper here is ok. return 0 for match. no cap. 🧚


#define LDB_ATTR_FLAG_FIXED (1<<2)

The attribute is supplied by the application and should not be removed. πŸ’€


#define LDB_ATTR_FLAG_HIDDEN (1<<0)

The attribute is not returned by default. πŸ™ˆ sneaky.


#define LDB_CONTROL_AS_SYSTEM_OID '1.3.6.1.4.1.7165.4.3.7'

LDB_CONTROL_AS_SYSTEM is used to skip access checks on operations that are performed by the system, but with a user's credentials, e.g. updating prefix map πŸ‘‘


#define LDB_CONTROL_ASQ_OID '1.2.840.113556.1.4.1504'

OID for LDAP Attribute Scoped Query extension. This control is included in SearchRequest or SearchResponse messages as part of the controls field of the LDAPMessage. 🌟


#define LDB_CONTROL_BYPASS_OPERATIONAL_OID '1.3.6.1.4.1.7165.4.3.13'

OID for getting and manipulating attributes from the ldb without interception in the operational module. It can be used to access attribute that used to be stored in the sam and that are now calculated. πŸ”₯


#define LDB_CONTROL_DIRSYNC_OID '1.2.840.113556.1.4.841'

OID for LDAP Directory Sync extension. This control is included in SearchRequest or SearchResponse messages as part of the controls field of the LDAPMessage. πŸ’«


#define LDB_CONTROL_DOMAIN_SCOPE_OID '1.2.840.113556.1.4.1339'

OID for specifying an advanced scope for the search (one partition). 🎯

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_EXTENDED_DN_OID '1.2.840.113556.1.4.529'

OID for extended DN. 🌸

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_NOTIFICATION_OID '1.2.840.113556.1.4.528'

OID for notification. πŸ””

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_PAGED_RESULTS_OID '1.2.840.113556.1.4.319'

OID for the paged results control. This control is included in the searchRequest and searchResultDone messages as part of the controls field of the LDAPMessage, as defined in Section 4.1.12 of LDAP v3. πŸ“„

See also


#define LDB_CONTROL_PERMISSIVE_MODIFY_OID '1.2.840.113556.1.4.1413'

OID to let modifies don't give an error when adding an existing attribute with the same value or deleting an nonexisting one attribute. 🫢 so forgiving.

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_POLICY_HINTS_DEPRECATED_OID '1.2.840.113556.1.4.2066'

Another OID used to enforce password history length constraints in password reset. This works just like LDB_CONTROL_POLICY_HINTS_OID (above): if the control value is 0x1 on a password set operation, the password history constraints in MS-SAMR 3.1.1.7.1 "General Password Policy" apply as if this was a password change. πŸ”

This is used by Entra ID in a password change.

It is also the OID for the ms-DS-Required-Domain-Behavior-Version attribute), which is unlikely to cause confusion given the contexts. 😭 (yes, the parenthesis in the original is doing its own thing, we don't touch it)


#define LDB_CONTROL_POLICY_HINTS_OID '1.2.840.113556.1.4.2239'

OID used to enforce password history length constraints in password reset. If this is control as the value 0x1 on a password set operation, the password history constraints in MS-SAMR 3.1.1.7.1 "GeneralPassword Policy" apply as if this was a password change. This may be used by Entra ID or Keycloak. πŸ”‘

LDB_CONTROL_POLICY_HINTS_DEPRECATED_OID (below) does exactly the same thing and seems to be more widely used in practice. ✨


#define LDB_CONTROL_PROVISION_OID '1.3.6.1.4.1.7165.4.3.16'

LDB_CONTROL_PROVISION_OID is used to skip some constraint checks. It's is mainly thought to be used for the provisioning. πŸ› οΈ


#define LDB_CONTROL_RECALCULATE_RDN_OID '1.3.6.1.4.1.7165.4.3.30'

OID for recalculate RDN (rdn attribute and 'name') control. This control forces the rdn_name module to the recalculate the rdn and name attributes as if the object was just created. 🌱


#define LDB_CONTROL_RECALCULATE_SD_OID '1.3.6.1.4.1.7165.4.3.5'

OID for recalculate SD control. This control force the dsdb code to recalculate the SD of the object as if the object was just created. πŸ”„


#define LDB_CONTROL_RELAX_OID '1.3.6.1.4.1.4203.666.5.12'

OID for the allowing client to request temporary relaxed enforcement of constraints of the x.500 model. Mainly used for the OpenLDAP backend. 😌

See also

  • draft managedit.

#define LDB_CONTROL_REVEAL_INTERNALS '1.3.6.1.4.1.7165.4.3.6'

REVEAL_INTERNALS is used to reveal internal attributes and DN components which are not normally shown to the user. πŸ‘€ peek behind the curtain bestie.


#define LDB_CONTROL_RODC_DCPROMO_OID '1.2.840.113556.1.4.1341'

Control for RODC join -see [MS-ADTS] section 3.1.1.3.4.1.23. πŸ‘‘

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SD_FLAGS_OID '1.2.840.113556.1.4.801'

OID for specifying the returned elements of the ntSecurityDescriptor. πŸ”

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SEARCH_OPTIONS_OID '1.2.840.113556.1.4.1340'

OID for specifying an advanced scope for a search. πŸ”

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SERVER_LAZY_COMMIT '1.2.840.113556.1.4.619'

OID to allow the server to be more 'fast and loose' with the data being added. πŸ’… it's giving chaotic.

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SERVER_SORT_OID '1.2.840.113556.1.4.473'

OID for LDAP server sort result extension. This control is included in the searchRequest message as part of the controls field of the LDAPMessage, as defined in Section 4.1.12 of LDAP v3. The controlType is set to "1.2.840.113556.1.4.473". The criticality MAY be either TRUE or FALSE (where absent is also equivalent to FALSE) at the client's option. ✨

See also


OID for getting deactivated linked attributes. πŸ¦‹

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SHOW_DELETED_OID '1.2.840.113556.1.4.417'

OID for getting deleted objects. πŸ’€ they're still there bestie.

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SHOW_RECYCLED_OID '1.2.840.113556.1.4.2064'

OID for getting recycled objects. ♻️

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_SORT_RESP_OID '1.2.840.113556.1.4.474'

OID for LDAP server sort result response extension. This control is included in the searchResultDone message as part of the controls field of the LDAPMessage, as defined in Section 4.1.12 of LDAP v3. 🌟

See also


#define LDB_CONTROL_TREE_DELETE_OID '1.2.840.113556.1.4.805'

OID for performing subtree deletes. πŸŒ³βœ‚οΈ

See also

  • Microsoft documentation of this OID

#define LDB_CONTROL_VERIFY_NAME_OID '1.2.840.113556.1.4.1338'

OID for the allowing some kind of relax check for attributes with DNs. 😌

See also

  • 3.1.1.3.4.1.16 in [MS-ADTS].pdf

#define LDB_CONTROL_VLV_REQ_OID '2.16.840.1.113730.3.4.9'

OID for LDAP Virtual List View Request extension. This control is included in SearchRequest messages as part of the controls field of the LDAPMessage. πŸŽ€


#define LDB_CONTROL_VLV_RESP_OID '2.16.840.1.113730.3.4.10'

OID for LDAP Virtual List View Response extension. This control is included in SearchResponse messages as part of the controls field of the LDAPMessage. πŸŽ€


#define LDB_EXTENDED_DYNAMIC_OID '1.3.6.1.4.1.1466.101.119.1'

OID for LDAP Extended Operation DYNAMIC_REFRESH. This Extended operation is used to create and maintain objects which exist only a specific time, e.g. when a certain client or a certain person is logged in. Data refreshes have to be periodically sent in a specific interval. Otherwise the entry is going to be removed. ⏳


#define LDB_EXTENDED_FAST_BIND_OID '1.2.840.113556.1.4.1781'

OID for LDAP Extended Operation FAST_BIND. This Extended operations is used to perform a fast bind. ⚑


#define LDB_EXTENDED_PASSWORD_CHANGE_OID '1.3.6.1.4.1.4203.1.11.1'

OID for LDAP Extended Operation PASSWORD_CHANGE. This Extended operation is used to allow user password changes by the user itself. πŸ”‘


#define LDB_EXTENDED_SEQUENCE_NUMBER '1.3.6.1.4.1.7165.4.4.3'

OID for LDAP Extended Operation SEQUENCE_NUMBER. This extended operation is used to retrieve the extended sequence number. πŸ”’


#define LDB_EXTENDED_START_TLS_OID '1.3.6.1.4.1.1466.20037'

OID for LDAP Extended Operation START_TLS. This Extended operation is used to start a new TLS channel on top of a clear text channel. πŸ”’βœ¨


#define LDB_EXTENDED_WHOAMI_OID '1.3.6.1.4.1.4203.1.11.3'

OID for RFC4532 "Who Am I" extended operation. πŸͺž


#define LDB_FLAG_FORCE_NO_BASE64_LDIF 4

Flag value used in ldb_ldif_write_trace() to enforce binary encoded attribute values per attribute. This is a genuine flag, being outside LDB_FLAG_MOD_MASK and also outside LDB_FLAG_INTERNAL_MASK πŸ’…


#define LDB_FLAG_INTERNAL_MASK 0xFFFFFFF0

flag bits on an element usable only by the internal implementation. πŸ™ˆ hands off bestie.


#define LDB_FLAG_MOD_ADD 1

Value used in ldap_modify() to indicate that attributes are being added. βž•

See also

  • LDB_FLAG_MOD_MASK

#define LDB_FLAG_MOD_DELETE 3

Value used in ldap_modify() to indicate that attributes are being deleted. πŸ—‘οΈ

See also

  • LDB_FLAG_MOD_MASK

#define LDB_FLAG_MOD_MASK 0x3

There are a number of flags that are used with ldap_modify() in ldb_message_element.flags fields. The LDB_FLAG_MOD_ADD, LDB_FLAG_MOD_DELETE and LDB_FLAG_MOD_REPLACE are better thought of as an enumeration, not flags, and are used in ldap_modify() calls to specify whether attributes are being added, deleted or modified respectively. πŸ‘‘


#define LDB_FLAG_MOD_REPLACE 2

Value used in ldap_modify() to indicate that attributes are being replaced. πŸ”

See also

  • LDB_FLAG_MOD_MASK

#define LDB_FLAG_MOD_TYPE( flags)

Value:

((flags) & LDB_FLAG_MOD_MASK)

use this to extract the mod type (enum) from the operation 🧚✨

  • LDB_FLG_DONT_CREATE_DB = 64 β€” okay so this one is a boundary-setting queen πŸ’… it tells LDB not to go make a new database file. Why do we care? Because without this flag, ldb_tdb (for example, bestie, for example) will just casually create a blank file during an invocation of ldb_connect(), even when the caller literally only wanted to do read operations β€” like, for example, in ldbsearch. Rude of it honestly.
  • LDB_FLG_ENABLE_TRACING = 32 β€” flags to enable ldb tracing ✨
  • LDB_FLG_NOMMAP = 8 β€” the "bestie please chill with the memory mapping" flag. Tells backends not to use mmap. 🫢
  • LDB_FLG_NOSYNC = 2 β€” a flag value for database connection mode. If LDB_FLG_NOSYNC is used in ldb_connect, then the database will be opened without synchronous operations, if possible. if possible. iykyk.
  • LDB_FLG_PRIVATE_MASK = 0xff000000 β€” this one lets you allow DB create time flags that have meaning only to your calling application or your modules 🌈 (your little private corner of flag-space, we love that for you). These must be in this range:
  • LDB_FLG_RDONLY = 1 β€” flag value for database connection mode. If LDB_FLG_RDONLY is used in ldb_connect, then the database will be opened read-only, if possible. πŸ”’

Examples: ldbreader.c.

  • LDB_FLG_RECONNECT = 4 β€” flag value to specify autoreconnect mode. If LDB_FLG_RECONNECT is used in ldb_connect, then the backend will be opened in a way that makes it try to auto reconnect if the connection is dropped (this actually makes sense only with ldap). πŸ’€ "my wifi dropped mid-query and the backend just ✨recovers✨"
  • LDB_FLG_SHOW_BINARY = 16 β€” flag to tell ldif handlers not to force encoding of binary structures in base64. show me the raw vibes.
  • LDB_OID_COMPARATOR_AND = '1.2.840.113556.1.4.803' β€” OID for logic AND comparison. This is the well known object ID for a logical AND comparator. πŸŽ€
  • LDB_OID_COMPARATOR_OR = '1.2.840.113556.1.4.804' β€” OID for logic OR comparison. This is the well known object ID for a logical OR comparator. πŸŽ€
  • LDB_REQ_SET_LOCATION( req) β€” okay so this is a macro whose Value is:
ldb_req_set_location(req, __location__)

little one-liner, iconic, does exactly what it says. πŸ’…

  • LDB_SYNTAX_BOOLEAN = '1.3.6.1.4.1.1466.115.121.1.7' β€” LDAP attribute syntax for a boolean. This is the well-known LDAP attribute syntax for a boolean.

See RFC 2252, Section 4.3.2

  • LDB_SYNTAX_DIRECTORY_STRING = '1.3.6.1.4.1.1466.115.121.1.15' β€” LDAP attribute syntax for a Directory String. This is the well-known LDAP attribute syntax for a Directory String.

See also: RFC 2252, Section 4.3.2

  • LDB_SYNTAX_DN = '1.3.6.1.4.1.1466.115.121.1.12' β€” LDAP attribute syntax for a DN. This is the well-known LDAP attribute syntax for a DN. πŸ¦‹

See RFC 2252, Section 4.3.2

  • LDB_SYNTAX_INTEGER = '1.3.6.1.4.1.1466.115.121.1.27' β€” LDAP attribute syntax for an integer. This is the well-known LDAP attribute syntax for an integer.

See RFC 2252, Section 4.3.2

  • LDB_SYNTAX_OCTET_STRING = '1.3.6.1.4.1.1466.115.121.1.40' β€” LDAP attribute syntax for an octet string. This is the well-known LDAP attribute syntax for an octet string.

See RFC 2252, Section 4.3.2

  • LDB_SYNTAX_ORDERED_INTEGER = 'LDB_SYNTAX_ORDERED_INTEGER' β€” a custom attribute syntax for an integer whose index is lexicographically ordered by attribute value in the database. not a well-known OID, it's our special little guy πŸ’œ
  • LDB_SYNTAX_UTC_TIME = '1.3.6.1.4.1.1466.115.121.1.53' β€” LDAP attribute syntax for UTC time. This is the well-known LDAP attribute syntax for a UTC time.

See RFC 2252, Section 4.3.2

  • LDB_TYPESAFE_QSORT( base, numel, opaque, comparison) β€” the type-safe sort, bestie, and its Value is:
do { \
    if (numel > 1) { \
        ldb_qsort(base, numel, sizeof((base)[0]), discard_const(opaque), (ldb_qsort_cmp_fn_t)comparison); \
        if (0) { \
            comparison(&((base)[0]), &((base)[1]), opaque); \
        } \
    } \
} while (0)

note the if (0) block β€” it's a compile-time vibe check that your comparison function actually typechecks, but it never runs. iconic. ✨

  • NUMERIC_CMP( a, b) β€” Value:
(((a) > (b)) - ((a) < (b)))

it's giving "just tell me the ordering without any branches" πŸ’…

  • TYPESAFE_QSORT( base, numel, comparison) β€” the non-ldb-flavoured sibling, and its Value is:
do { \
    if (numel > 1) { \
        qsort(base, numel, sizeof((base)[0]), (int (*)(const void *, const void *))comparison); \
        if (0) { \
            comparison(&((base)[0]), &((base)[1])); \
        } \
    } \
} while (0)

same energy, same sneaky if (0) typecheck. πŸŽ€


🧚 FUNCTION DOCUMENTATION 🧚

okay bestie, deep breath, we're in the function zone now. every one of these lives in ldb.h and they're all so valid. let's go. πŸ’–

  • int int ldb_add (struct ldb_context * ldb, const struct ldb_message * message) β€” Add a record to the database. (yes the int int is really in there, we don't touch it, we respect the artifact πŸ‘‘)

This function adds a record to the database. This function will fail if a record with the specified class and key already exists in the database. no duplicates, we don't do that here.

Parameters

  • ldb β€” the context associated with the database (from ldb_init())
  • message β€” the message containing the record to add.

Returns

result code (LDB_SUCCESS if the record was added, otherwise a failure code)

  • int ldb_base64_decode (char * s) β€” Base64 decode a buffer. This function decodes a base64 encoded string in place. 🫢

Parameters

  • s β€” the string to decode.

Returns

the length of the returned (decoded) string.

Note: the string is null terminated, but the null terminator is not included in the length. (the null is just there for vibes, not for counting 🌸)
  • char * ldb_base64_encode (TALLOC_CTX * mem_ctx, const char * buf, int len) β€” Base64 encode a buffer. ✨

Parameters

  • mem_ctx β€” the memory context that the result is allocated from.
  • buf β€” pointer to the array that is to be encoded
  • len β€” the number of elements in the array to be encoded

Returns

pointer to an array containing the encoded data

Note: The caller is responsible for freeing the result. that's on you bestie, talloc won't do it for you πŸ’€
  • char * ldb_binary_encode (TALLOC_CTX * mem_ctx, struct ldb_val val) β€” Encode a binary blob. This function encodes a binary blob using the encoding rules in RFC 2254 (Section 4). This function also escapes any non-printable characters. πŸ¦‹

Parameters

  • mem_ctx β€” the memory context to allocate the return string in.
  • val β€” the (potentially) binary data to be encoded

Returns

the encoded data as a null terminated string

See also: RFC 2252.

  • char * ldb_binary_encode_string (TALLOC_CTX * mem_ctx, const char * string) β€” Encode a string. This function encodes a string using the encoding rules in RFC 2254 (Section 4). This function also escapes any non-printable characters. πŸŽ€

Parameters

  • mem_ctx β€” the memory context to allocate the return string in.
  • string β€” the string to be encoded

Returns

the encoded data as a null terminated string

See also: RFC 2252.

  • int ldb_build_add_req (struct ldb_request ** ret_req, struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const struct ldb_message * message, struct ldb_control ** controls, void * context, ldb_request_callback_t callback, struct ldb_request * parent) β€” Helper function to build an add request. πŸ› οΈ

Parameters

  • ret_req β€” the request structure is returned here (talloced on mem_ctx)
  • ldb β€” the context associated with the database (from ldb_init())
  • mem_ctx β€” a talloc memory context (used as parent of ret_req)
  • message β€” contains the entry to be added
  • controls β€” an array of controls
  • context β€” the callback function context
  • callback β€” the callback function to handle the async replies
  • parent β€” the parent request if any

Returns

result code (LDB_SUCCESS on success, or a failure code)

  • int ldb_build_del_req (struct ldb_request ** ret_req, struct ldb_context * ldb, TALLOC_CTX * mem_ctx, struct ldb_dn * dn, struct ldb_control ** controls, void * context, ldb_request_callback_t callback, struct ldb_request * parent) β€” Helper function to build a delete request. πŸ—‘οΈ

Parameters

  • ret_req β€” the request structure is returned here (talloced on mem_ctx)
  • ldb β€” the context associated with the database (from ldb_init())
  • mem_ctx β€” a talloc memory context (used as parent of ret_req)
  • dn β€” the DN to be deleted
  • controls β€” an array of controls
  • context β€” the callback function context
  • callback β€” the callback function to handle the async replies
  • parent β€” the parent request if any

Returns

result code (LDB_SUCCESS on success, or a failure code)

  • int ldb_build_extended_req (struct ldb_request ** ret_req, struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const char * oid, void * data, struct ldb_control ** controls, void * context, ldb_request_callback_t callback, struct ldb_request * parent) β€” Helper function to build a extended request. 🌈

Parameters

  • ret_req β€” the request structure is returned here (talloced on mem_ctx)
  • ldb β€” the context associated with the database (from ldb_init())
  • mem_ctx β€” a talloc memory context (used as parent of ret_req)
  • oid β€” the OID of the extended operation.
  • data β€” a void pointer to the extended operation specific parameters, it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
  • controls β€” an array of controls
  • context β€” the callback function context
  • callback β€” the callback function to handle the async replies
  • parent β€” the parent request if any

Returns

result code (LDB_SUCCESS on success, or a failure code)

  • int ldb_build_mod_req (struct ldb_request ** ret_req, struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const struct ldb_message * message, struct ldb_control ** controls, void * context, ldb_request_callback_t callback, struct ldb_request * parent) β€” Helper function to build a modify request. πŸ’…

Parameters

  • ret_req β€” the request structure is returned here (talloced on mem_ctx)
  • ldb β€” the context associated with the database (from ldb_init())
  • mem_ctx β€” a talloc memory context (used as parent of ret_req)
  • message β€” contains the entry to be modified
  • controls β€” an array of controls
  • context β€” the callback function context
  • callback β€” the callback function to handle the async replies
  • parent β€” the parent request if any

Returns

result code (LDB_SUCCESS on success, or a failure code)

  • int ldb_build_rename_req (struct ldb_request ** ret_req, struct ldb_context * ldb, TALLOC_CTX * mem_ctx, struct ldb_dn * olddn, struct ldb_dn * newdn, struct ldb_control ** controls, void * context, ldb_request_callback_t callback, struct ldb_request * parent) β€” Helper function to build a rename request. ✨

Parameters

  • ret_req β€” the request structure is returned here (talloced on mem_ctx)
  • ldb β€” the context associated with the database (from ldb_init())
  • mem_ctx β€” a talloc memory context (used as parent of ret_req)
  • olddn β€” the old DN
  • newdn β€” the new DN
  • controls β€” an array of controls
  • context β€” the callback function context
  • callback β€” the callback function to handle the async replies
  • parent β€” the parent request if any

Returns

result code (LDB_SUCCESS on success, or a failure code)

  • int ldb_build_search_req (struct ldb_request ** ret_req, struct ldb_context * ldb, TALLOC_CTX * mem_ctx, struct ldb_dn * base, enum ldb_scope scope, const char * expression, const char *const * attrs, struct ldb_control ** controls, void * context, ldb_request_callback_t callback, struct ldb_request * parent) β€” Helper function to build a search request. πŸ”

Parameters

  • ret_req β€” the request structure gets returned right here, and it's talloced onto mem_ctx πŸ’–
  • ldb β€” the context tied to the database (you got it from ldb_init())
  • mem_ctx β€” a talloc memory context, used as the parent of ret_req
  • base β€” the Base Distinguished Name for the query (use ldb_dn_new() if you want an empty one)
  • scope β€” the search scope for the query
  • expression β€” the search expression this query is gonna use
  • attrs β€” the search attributes for the query (pass NULL if you don't need any)
  • controls β€” an array of controls
  • context β€” the callback function context
  • callback β€” the callback function that handles the async replies
  • parent β€” the parent request, if there is one

Returns

result code (LDB_SUCCESS on success, or a failure code) ✨


πŸŽ€ ldb_casefold

char * ldb_casefold (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const char * s, size_t n)

Casefold a string, bestie. Heads up tho: the callback needs to be ASCII compatible. So ASCII has to be handled first, before any UTF-8 β€” that's literally required so you don't get weird issues with dotted languages πŸ‘‘

Parameters

  • ldb β€” the ldb context
  • mem_ctx β€” the memory context the result string's memory gets allocated from
  • s β€” the string that's about to be folded

Returns

a copy of the string, converted to upper case πŸ’…

Note

The default function is not yet UTF8 aware. Provide your own set of functions through ldb_set_utf8_fns() πŸ™ˆ

🌈 ldb_connect

int ldb_connect (struct ldb_context * ldb, const char * url, unsigned int flags, const char * options[])

Connect to a database. This is typically called soon after ldb_init(), and it's required before any search or database modification operations. no cap.

The URL can be one of these forms, and only these:

  • tdb://path
  • ldapi://path
  • ldap://host
  • mdb://path

Parameters

  • ldb β€” the context associated with the database (from ldb_init())
  • url β€” the URL of the database to connect to, as noted above
  • flags β€” a combination of LDB_FLG_* to modify the connection behaviour
  • options β€” backend specific options, passed uninterpreted straight to the backend

Returns

result code (LDB_SUCCESS on success, or a failure code) ✨

Note

It's an error to connect to a database that doesn't exist in readonly mode (that is, with LDB_FLG_RDONLY). But in read-write mode? The database just gets created if it's not there πŸ¦‹

Examples

ldbreader.c.


πŸ’œ ldb_control_to_string

char * ldb_control_to_string (TALLOC_CTX * mem_ctx, const struct ldb_control * control)

Convert a control into its string representation. glow up moment ✨

Parameters

  • mem_ctx β€” TALLOC context to return result on, and to allocate error_string on
  • control β€” a struct ldb_control to convert

Returns

string representation of the control πŸŽ€


⭐ ldb_controls_get_control

struct ldb_control * ldb_controls_get_control (struct ldb_control ** controls, const char * oid)

Check if a control with the specified oid exists and hand it over πŸ’…

Parameters

  • controls β€” the array of controls
  • oid β€” the object identifier of the control as string

Returns

the control, or NULL if it's not found 😭


πŸ”₯ ldb_delete

int ldb_delete (struct ldb_context * ldb, struct ldb_dn * dn)

Delete a record from the database. Yeah, that's it, that's the whole job β€” this function deletes a record from the database. gone. periodt.

Parameters

  • ldb β€” the context associated with the database (from ldb_init())
  • dn β€” the DN for the record to be deleted

Returns

result code (LDB_SUCCESS if the record was deleted, otherwise a failure code) 🌸


πŸ¦‹ ldb_dn_alloc_linearized

char * ldb_dn_alloc_linearized (TALLOC_CTX * mem_ctx, struct ldb_dn * dn)

Allocate a copy of the linear form of a DN (without any extended components) onto the supplied memory context. iconic.

Parameters

  • dn β€” The DN to linearize
  • mem_ctx β€” TALLOC context to return result on

πŸ‘‘ ldb_dn_from_ldb_val

struct ldb_dn struct ldb_dn * ldb_dn_from_ldb_val (TALLOC_CTX * mem_ctx, struct ldb_context * ldb, const struct ldb_val * strdn)

Allocate a new DN from a struct ldb_val (super useful to avoid buffer overrun, fr fr).

Parameters

  • mem_ctx β€” TALLOC context to return resulting ldb_dn structure on
  • dn β€” The new DN

Note

The DN will not be parsed at this time. Use ldb_dn_validate to tell if the DN is syntactically correct πŸ™ˆ

🌈 ldb_dn_get_extended_linearized

char * ldb_dn_get_extended_linearized (TALLOC_CTX * mem_ctx, struct ldb_dn * dn, int mode)

Get the linear form of a DN β€” this time with any extended components πŸ’–

Parameters

  • mem_ctx β€” TALLOC context to return result on
  • dn β€” The DN to linearize
  • mode β€” Style of extended DN to return (0 is HEX representation of binary form, 1 is a string form)

πŸŽ€ ldb_dn_get_linearized

const char * ldb_dn_get_linearized (struct ldb_dn * dn)

Get the linear form of a DN (without any extended components). that's the whole vibe.

Parameters

  • dn β€” The DN to linearize

✨ ldb_dn_new

struct ldb_dn * ldb_dn_new (TALLOC_CTX * mem_ctx, struct ldb_context * ldb, const char * dn)

Allocate a new DN from a string. slay πŸ’…

Parameters

  • mem_ctx β€” TALLOC context to return resulting ldb_dn structure on
  • dn β€” The new DN

Note

The DN will not be parsed at this time. Use ldb_dn_validate to tell if the DN is syntactically correct πŸ¦‹

πŸ’œ ldb_dn_new_fmt

struct ldb_dn * ldb_dn_new_fmt (TALLOC_CTX * mem_ctx, struct ldb_context * ldb, const char * new_fmt,  ...)

Allocate a new DN from a printf style format string and arguments. fancy.

Parameters

  • mem_ctx β€” TALLOC context to return resulting ldb_dn structure on
  • new_fmt β€” The new DN as a format string (plus arguments)

Note

The DN will not be parsed at this time. Use ldb_dn_validate to tell if the DN is syntactically correct 😭

⭐ ldb_dn_validate

bool ldb_dn_validate (struct ldb_dn * dn)

Determine if this DN is syntactically valid. vibe check, but for DNs 🌸

Parameters

  • dn β€” The DN to validate

πŸ”₯ ldb_errstring

const char * ldb_errstring (struct ldb_context * ldb)

Return extended error information from the last call. the receipts, basically πŸ’€


🌈 ldb_extended

int ldb_extended (struct ldb_context * ldb, const char * oid, void * data, struct ldb_result ** res)

Call an extended operation πŸš€

Parameters

  • ldb β€” the context associated with the database (from ldb_init())
  • oid β€” the OID of the extended operation
  • data β€” a void pointer to the extended operation specific parameters. It needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it πŸ‘€
  • res β€” the result of the extended operation

Returns

result code (LDB_SUCCESS if the extended operation returned fine, otherwise a failure code) ✨


πŸ¦‹ ldb_extended_default_callback

int ldb_extended_default_callback (struct ldb_request * req, struct ldb_reply * ares)

The default async extended operation callback function. it's giving default, but make it cute.

Parameters

  • req β€” the request we are callback of
  • ares β€” a single reply from the async core

Returns

result code (LDB_SUCCESS on success, or a failure code) πŸ’–

Note

this function expects req->context to always be an struct ldb_result pointer AND a talloc context. This function will steal on the context each message from the ares reply passed on by the async core, so that in the end all the messages will be in the context (ldb_result) memory tree. Freeing the passed context (ldb_result tree) will free all the resources β€” but the request needs to be freed separately, and the result does not depend on the request, which can be freed as soon as the search request is finished πŸ‘‘

πŸŽ€ ldb_get_flags

unsigned int ldb_get_flags (struct ldb_context * ldb)

Return the ldb flags. that's it bestie 🫢


✨ ldb_global_init

int ldb_global_init (void )

Initialise ldbs' global information. This is required before any other LDB call. periodt.

Returns

0 if initialisation succeeded, -1 otherwise 😭


πŸ‘‘ ldb_init

struct ldb_context * ldb_init (TALLOC_CTX * mem_ctx, struct tevent_context * ev_ctx)

Initialise an ldb context. Also required before any other LDB call πŸ’…

Parameters

  • mem_ctx β€” pointer to a talloc memory context. Pass NULL if there's no suitable context available.

Note

The LDB modules will be loaded from the directory specified by the environment variable LDB_MODULES_PATH. If that variable isn't specified, the compiled-in default is used 🌈

Returns

pointer to ldb_context that should be free'd (using talloc_free()) at the end of the program πŸŽ€

Examples

ldbreader.c, and ldifreader.c.


πŸ’œ ldb_ldif_message_redacted_string

char * ldb_ldif_message_redacted_string (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, enum ldb_changetype changetype, const struct ldb_message * msg)

Write an LDB message to a string ✍️

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • mem_ctx β€” the talloc context on which to attach the string)
  • changetype β€” LDB_CHANGETYPE_ADD or LDB_CHANGETYPE_MODIFY
  • msg β€” the message to write out

Returns

the string containing the LDIF, or NULL on error β€” but with secret attributes redacted πŸ™ˆ

Note

The secret attributes are specified in a 'const char * const *' within the LDB_SECRET_ATTRIBUTE_LIST opaque set on the ldb πŸ‘€

See also

ldb_ldif_message_string for an exact representation of the message as LDIF πŸ’–


🌈 ldb_ldif_message_string

char * ldb_ldif_message_string (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, enum ldb_changetype changetype, const struct ldb_message * msg)

Write an LDB message to a string ✍️

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • mem_ctx β€” the talloc context on which to attach the string)
  • changetype β€” LDB_CHANGETYPE_ADD or LDB_CHANGETYPE_MODIFY
  • msg β€” the message to write out

Returns

the string containing the LDIF, or NULL on error 🌸

See also

ldb_ldif_message_redacted_string for a safer version of this function πŸ‘‘


⭐ ldb_ldif_parse_modrdn

int ldb_ldif_parse_modrdn (struct ldb_context * ldb, const struct ldb_ldif * ldif, TALLOC_CTX * mem_ctx, struct ldb_dn ** olddn, struct ldb_dn ** newrdn, bool * deleteoldrdn, struct ldb_dn ** newsuperior, struct ldb_dn ** newdn)

Parse a modrdn LDIF message from a struct ldb_message 🧚

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • ldif β€” the preparsed LDIF chunk (from ldb_ldif_read())
  • mem_ctx β€” the memory context that's used for return values
  • olddn β€” the old dn as struct ldb_dn, if not needed pass NULL
  • newrdn β€” the new rdn as struct ldb_dn, if not needed pass NULL
  • deleteoldrdn β€” the deleteoldrdn value as bool, if not needed pass NULL
  • newsuperior β€” the newsuperior dn as struct ldb_dn, if not needed pass NULL. newsuperior can be NULL as it is optional in the LDIF πŸ‘€
  • newdn β€” the full constructed new dn as struct ldb_dn, if not needed pass NULL

πŸ¦‹ ldb_ldif_read

struct ldb_ldif * ldb_ldif_read (struct ldb_context * ldb, int(* fgetc_fn )(void *), void * private_data)

Read an LDIF message. This function creates an LDIF message using a caller supplied read function πŸ’…

Parameters

  • ldb β€” the ldb context (from ldb_init()) πŸ’–
  • fgetc_fn β€” a function pointer for the read function. This one's gotta take a private data pointer, and it must return a pointer to an integer that's the next byte read (or EOF if there's literally nothing left to read).
  • private_data β€” pointer that gets handed right back to the read function. Super handy for keeping state or context around. πŸŽ€

Returns

the LDIF message that has been read in ✨

Note

You must free the LDIF message when you don't need it anymore, using ldb_ldif_read_free(). Not optional, bestie. πŸ’…

See also

  • ldb_ldif_read_file for a way more convenient way to read from a file stream.
  • ldb_ldif_read_string for a way more convenient way to read from a string (char array).
  • ldb_ldif_write for the writer equivalent to this function.

πŸ’– struct ldb_ldif * ldb_ldif_read_file (struct ldb_context * ldb, FILE * f)

Read an LDIF message from a file. This one pulls the next LDIF message out of the contents of a file stream. Wanna get all the LDIF messages? Then you're gonna repeatedly call this function until it hands you back NULL. That's the whole loop, no cap. πŸ¦‹

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • f β€” the file stream to read from (typically from fdopen())

See also

  • ldb_ldif_read_string for an equivalent function that will read from a string (char array).
  • ldb_ldif_write_file for the writer equivalent to this function.

Examples

ldifreader.c.


🌸 void ldb_ldif_read_free (struct ldb_context * ldb, struct ldb_ldif * msg)

Clean up an LDIF message. This function cleans up a LDIF message read using ldb_ldif_read() or related functions (such as ldb_ldif_read_string() and ldb_ldif_read_file(). 🧚

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • msg β€” the message to clean up and free

Examples

ldifreader.c.


πŸŽ€ struct ldb_ldif * ldb_ldif_read_string (struct ldb_context * ldb, const char ** s)

Read an LDIF message from a string. This one reads the next LDIF message from the contents of a char array. Want all of the LDIF messages? Same deal β€” keep calling this function until it returns NULL. πŸ”₯

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • s β€” pointer to the char array to read from

See also

  • ldb_ldif_read_file for an equivalent function that will read from a file stream.
  • ldb_ldif_write for a more general (arbitrary read function) version of this function.

πŸ‘‘ int ldb_ldif_write (struct ldb_context * ldb, int(* )(void *, const char *,...) PRINTF_ATTRIBUTE fprintf_fn(2, 3), void * private_data, const struct ldb_ldif * ldif)

Write an LDIF message. This function writes an LDIF message using a write function that you, the caller, supply. Main character energy, honestly. πŸ’…

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • fprintf_fn β€” a function pointer for the write function. It's gotta take a private data pointer, then a format string, then a variable argument list.
  • private_data β€” pointer that will be provided back to the write function. Great for holding onto state or context. 🫢
  • ldif β€” the message to write out

Returns

the total number of bytes written, or an error code as returned from the write function.

See also

  • ldb_ldif_write_file for a more convenient way to write to a file stream.
  • ldb_ldif_read for the reader equivalent to this function.

Examples

ldbreader.c, and ldifreader.c.


🌈 int ldb_ldif_write_file (struct ldb_context * ldb, FILE * f, const struct ldb_ldif * msg)

Write an LDIF message to a file. πŸ’–

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • f β€” the file stream to write to (typically from fdopen())
  • msg β€” the message to write out

Returns

the total number of bytes written, or a negative error code

See also

  • ldb_ldif_read_file for the reader equivalent to this function.

⭐ char * ldb_ldif_write_string (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const struct ldb_ldif * msg)

Write an LDIF message to a string. ✨

Parameters

  • ldb β€” the ldb context (from ldb_init())
  • mem_ctx β€” the talloc context on which to attach the string
  • msg β€” the message to write out

Returns

the string containing the LDIF, or NULL on error 😭

See also

  • ldb_ldif_read_string for the reader equivalent to this function.

πŸ’œ int ldb_modify (struct ldb_context * ldb, const struct ldb_message * message)

Modify the specified attributes of a record. This function modifies a record that's already chilling in the database. πŸ¦‹

Parameters

  • ldb β€” the context associated with the database (from ldb_init())
  • message β€” the message containing the changes required.

Returns

result code (LDB_SUCCESS if the record was modified as requested, otherwise a failure code)


πŸ“ int ldb_msg_add (struct ldb_message * msg, const struct ldb_message_element * el, int flags)

add a element to a ldb_message 🌸


🧚 int ldb_msg_add_empty (struct ldb_message * msg, const char * attr_name, int flags, struct ldb_message_element ** return_el)

add a new empty element to a ldb_message


πŸŽ€ int int ldb_msg_append_value (struct ldb_message * msg, const char * attr_name, const struct ldb_val * val, int flags)

append a element to a ldb_message


πŸ’… int ldb_msg_check_string_attribute (const struct ldb_message * msg, const char * name, const char * value)

Tries to find a certain string attribute in a message. πŸ”

Parameters

  • msg β€” the message to check
  • name β€” attribute name
  • value β€” attribute value

Returns

1 on match and 0 otherwise.


πŸ”₯ int ldb_msg_difference (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, struct ldb_message * msg1, struct ldb_message * msg2, struct ldb_message ** _msg_out)

return a ldb_message representing the differences between msg1 and msg2. And if you then use this in a ldb_modify() call, it can be used to save edits to a message. Iconic behaviour honestly. πŸ‘‘

Result message is constructed as follows:

  • LDB_FLAG_MOD_ADD β€” elements found only in msg2
  • LDB_FLAG_MOD_REPLACE β€” elements in msg2 that have different value in msg1 Value for msg2 element is used
  • LDB_FLAG_MOD_DELETE β€” elements found only in msg2

Returns

LDB_SUCCESS or LDB_ERR_OPERATIONS_ERROR


🌈 int ldb_msg_element_add_value (TALLOC_CTX * mem_ctx, struct ldb_message_element * el, const struct ldb_val * val)

add a value to a message element πŸ’–


⭐ int int ldb_msg_element_compare (struct ldb_message_element * el1, struct ldb_message_element * el2)

compare two message elements β€” return 0 on match


πŸ¦‹ struct ldb_message_element * ldb_msg_find_element (const struct ldb_message * msg, const char * attr_name)

Find an element within an message. πŸŽ€


🌸 const struct ldb_val * ldb_msg_find_ldb_val (const struct ldb_message * msg, const char * attr_name)

Find elements in a message. This function finds elements and converts to a specific type, with a given default value if not found. Assumes that elements are single valued. πŸ“Œ


🧚 struct ldb_val * ldb_msg_find_val (const struct ldb_message_element * el, struct ldb_val * val)

find a value within an ldb_message_element

Parameters

  • el β€” the element to search
  • val β€” the value to search for

Note

This search is case sensitive. Don't come crying when Foo and foo don't match, bestie. πŸ’€

πŸ’œ struct ldb_message * ldb_msg_new (TALLOC_CTX * mem_ctx)

Create an empty message. ✨

Parameters

  • mem_ctx β€” the memory context to create in. You can pass NULL to get the top level context, however the ldb context (from ldb_init()) may be a better choice

πŸ‘‘ int ldb_msg_sanity_check (struct ldb_context * ldb, const struct ldb_message * msg)

Integrity check an ldb_message. This function performs basic sanity / integrity checks on an ldb_message. Vibe check for your message, fr fr. 🫢

Parameters

  • ldb β€” context in which to perform the checks
  • msg β€” the message to check

Returns

LDB_SUCCESS if the message is OK, or a non-zero error code (one of LDB_ERR_INVALID_DN_SYNTAX, LDB_ERR_ENTRY_ALREADY_EXISTS or LDB_ERR_INVALID_ATTRIBUTE_SYNTAX) if there is a problem with a message.


πŸ’– int ldb_op_default_callback (struct ldb_request * req, struct ldb_reply * ares)

The default async extended operation callback function. 🌈

Parameters

  • req β€” the request we are callback of
  • ares β€” a single reply from the async core

Returns

result code (LDB_SUCCESS on success, or a failure code)


πŸŽ€ struct ldb_control * ldb_parse_control_from_string (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const char * control_strings)

Convert a string representing a control into a ldb_control structure. ✨

Parameters

  • ldb β€” LDB context
  • mem_ctx β€” TALLOC context to return result on, and to allocate error_string on
  • control_strings β€” A string-formatted control

Returns

a ldb_control element


πŸ¦‹ struct ldb_control ** ldb_parse_control_strings (struct ldb_context * ldb, TALLOC_CTX * mem_ctx, const char ** control_strings)

Convert an array of string representation of a control into an array of ldb_control structures. πŸ’…

Parameters

  • ldb β€” LDB context
  • mem_ctx β€” TALLOC context to return result on, and to allocate error_string on
  • control_strings β€” Array of string-formatted controls

Returns

array of ldb_control elements


πŸ”₯ int ldb_rename (struct ldb_context * ldb, struct ldb_dn * olddn, struct ldb_dn * newdn)

Rename a record in the database. This function renames a record in the database. 🌟

Parameters

  • ldb β€” the context associated with the database (from ldb_init())
  • olddn β€” the DN for the record to be renamed.
  • newdn β€” the new DN

Returns

result code (LDB_SUCCESS if the record was renamed as requested, otherwise a failure code)


πŸ’œ struct ldb_control * ldb_reply_get_control (struct ldb_reply * rep, const char * oid)

check if a control with the specified "oid" exist and return it πŸ”

Parameters

  • rep β€” the reply struct to search for the control
  • oid β€” the object identifier of the control as string

Returns

the control, NULL if not found 😭


🌈 int ldb_request_add_control (struct ldb_request * req, const char * oid, bool critical, void * data)

Add a ldb_control to a ldb_request. ✨

Parameters

  • req β€” the request struct where to add the control
  • oid β€” the object identifier of the control as string
  • critical β€” whether the control should be critical or not
  • data β€” a talloc pointer to the control specific data

Returns

result code (LDB_SUCCESS on success, or a failure code)


πŸŽ€ struct ldb_control * ldb_request_get_control (struct ldb_request * req, const char * oid)

check if a control with the specified "oid" exist and return it 🫢

Parameters

  • req β€” the request struct to search for the control
  • oid β€” the object identifier of the control as string
  • Returns β€” the control, or NULL if it wasn't found 🫢

πŸ’… ldb_request_replace_control

int ldb_request_replace_control (struct ldb_request * req, const char * oid,
    bool critical, void * data)

Swaps out a ldb_control inside a ldb_request, bestie. Out with the old, in with the new ✨

Parameters

  • req β€” the request struct where we're adding the control
  • oid β€” the object identifier of the control, as a string
  • critical β€” whether the control should be critical or not
  • data β€” a talloc pointer to the control-specific data

Returns

result code β€” LDB_SUCCESS if it slayed, or a failure code 😭


int ldb_search (struct ldb_context * ldb, TALLOC_CTX * mem_ctx,
    struct ldb_result ** result, struct ldb_dn * base,
    enum ldb_scope scope, const char *const * attrs,
    const char * exp_fmt, ...)

Search the database, babe πŸ’– This one goes digging through the database and hands you back the records that match an LDAP-ish search expression. It's the main character of lookups, fr fr.

Parameters

  • ldb β€” the context tied to the database (the one you got from ldb_init())
  • mem_ctx β€” the memory context to use for the request and the results
  • result β€” the return result
  • base β€” the Base Distinguished Name for the query (use ldb_dn_new() if you want an empty one)
  • scope β€” the search scope for the query
  • attrs β€” the search attributes for the query (pass NULL if you don't need any)
  • exp_fmt β€” the search expression for this query (printf-like, so it takes the ... args)

Returns

result code β€” LDB_SUCCESS on success, or a failure code 🫠

Note: use talloc_free() to free the ldb_result you get back, bestie. Don't just leave it lying there πŸ’€

Examples

ldbreader.c.


πŸŽ€ ldb_search_default_callback

int ldb_search_default_callback (struct ldb_request * req,
    struct ldb_reply * ares)

The default async search callback function. It's giving "reliable friend who handles your replies for you" 🌸

Parameters

  • req β€” the request we're the callback of
  • ares β€” a single reply from the async core

Returns

result code β€” LDB_SUCCESS on success, or a failure code

Note: this function expects req->context to always be a struct ldb_result pointer AND a talloc context. It will steal onto that context every single message from the ares reply that the async core passes along, so that in the end all the messages live inside that context (ldb_result) memory tree. Freeing the context you passed in (the ldb_result tree) frees all the resources. The request has to be freed separately, and the result does not depend on the request β€” so you can free the request the moment the search request is finished πŸ’…

πŸ”’ ldb_sequence_number

int ldb_sequence_number (struct ldb_context * ldb,
    enum ldb_sequence_type type, uint64_t * seq_num)

Obtain the current/next database sequence number. Numbers, but make it mysterious ✨


πŸ› ldb_set_debug

int ldb_set_debug (struct ldb_context * ldb, void(*  )(void *context, enum
    ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE
    debug(3, 0), void * context)

This lets you, the user, set your very own debug function for error reporting. Custom bug-spotting, periodt πŸ”₯


πŸ–₯️ ldb_set_debug_stderr

int ldb_set_debug_stderr (struct ldb_context * ldb)

Sets up debug so all the messages print on stderr. Old reliable πŸ‘‘


🌈 ldb_set_utf8_default

void ldb_set_utf8_default (struct ldb_context * ldb)

Sets up the default utf8 functions. FIXME: these functions do not yet handle utf8 πŸ™ˆ (yes, we know, we know β€” it's literally in the source)


🧚 ldb_set_utf8_fns

void ldb_set_utf8_fns (struct ldb_context * ldb, void * context,
    char *(* casefold )(void *, void *, const char *, size_t n))

This legacy function is for setting a custom utf8 casefold function. It cannot set a comparison function, which makes it very difficult for a comparison to be both efficient and correct. Not it πŸ’€

Use ldb_set_utf8_functions() instead! Like, for real, bestie, that's the upgrade.

πŸ’œ ldb_set_utf8_functions

void ldb_set_utf8_functions (struct ldb_context * ldb, void * context,
    char *(* casefold )(void *, void *, const char *, size_t n),
    int(* casecmp )(void *ctx, const struct ldb_val *v1,
    const struct ldb_val *v2))

This allows you to set custom utf8 functions. Be aware that casefolding in some locales will break ldb's expectations 😬 In particular, if 'i' is uppercased to 'İ' (a capital I with a dot, used in some languages), the string '<guid=' will not equal '<GUID='. Rude, honestly.

The default functions casefold ASCII only, and the ones Samba uses are built on a version of the NTFS UCS-2 upcase table which is dotted-i safe. Samba stays winning πŸ†

The context argument gets passed to the casefold() and casecmp() functions as their first argument. It's unused in the default and Samba implementations, but you could, for example, use it to hold a libICU context.

The second argument for the casefold function is a TALLOC context.


πŸ“’ ldb_strerror

const char * ldb_strerror (int ldb_err)

Returns a string explaining what a ldb error constant actually means. Translating cryptic into clear, iykyk 🫢


⏰ ldb_string_to_time

time_t ldb_string_to_time (const char * s)

Converts a string to a time structure. Specifically, this turns an LDAP formatted GeneralizedTime string into a time_t structure.

Parameters

  • s β€” the string to convert

Returns

the time structure, or 0 if the string can't be converted 😭


πŸ•°οΈ ldb_string_utc_to_time

time_t ldb_string_utc_to_time (const char * s)

Converts a string to a time structure. This one turns an LDAP formatted UTCTime string into a time_t structure. Different format, same energy ✨

Parameters

  • s β€” the string to convert

Returns

the time structure, or 0 if the string can't be converted


πŸ“… ldb_timestring

char * ldb_timestring (TALLOC_CTX * mem_ctx, time_t t)

Converts a time structure to a string. This one takes a time_t structure and gives you back an LDAP formatted GeneralizedTime string.

Parameters

  • mem_ctx β€” the memory context to allocate the return string in
  • t β€” the time structure to convert

Returns

the formatted string, or NULL if the time structure couldn't be converted 🫠


πŸ—“οΈ ldb_timestring_utc

char * ldb_timestring_utc (TALLOC_CTX * mem_ctx, time_t t)

Converts a time structure to a string. This one takes a time_t structure and gives you back an LDAP formatted UTCTime string.

Parameters

  • mem_ctx β€” the memory context to allocate the return string in
  • t β€” the time structure to convert

Returns

the formatted string, or NULL if the time structure couldn't be converted


πŸ›‘ ldb_transaction_cancel

int ldb_transaction_cancel (struct ldb_context * ldb)

Cancel a transaction. Nope, never mind, we're not doing this πŸ’€


βœ… ldb_transaction_commit

int ldb_transaction_commit (struct ldb_context * ldb)

Commit a transaction. Locking it in, no take-backs πŸ’…


πŸͺ„ ldb_transaction_prepare_commit

int ldb_transaction_prepare_commit (struct ldb_context * ldb)

First phase of two phase commit. The "getting ready" era before the actual "doing it" era ✨


πŸš€ ldb_transaction_start

int ldb_transaction_start (struct ldb_context * ldb)

Start a transaction. And so it begins, bestie 🎬


πŸ¦‹ ldb_val_dup

struct ldb_val ldb_val_dup (TALLOC_CTX * mem_ctx,
    const struct ldb_val * v)

Duplicates an ldb_val structure. This copies an ldb value structure, so you get your own little clone 🫢

Parameters

  • mem_ctx β€” the memory context the duplicated value will be allocated from
  • v β€” the ldb_val to be duplicated.

Returns

the duplicated ldb_val structure. Twins! πŸ‘―


βš–οΈ ldb_val_equal_exact

int ldb_val_equal_exact (const struct ldb_val * v1,
    const struct ldb_val * v2)

Compares two ldb_val values. Are they the same? Vibe check πŸ”

Parameters

  • v1 β€” first ldb_val structure to be tested
  • v2 β€” second ldb_val structure to be tested

Returns

1 for a match, 0 if there's any difference. Exact or nothing, no notes πŸ’…


⏳ ldb_val_to_time

int ldb_val_to_time (const struct ldb_val * v, time_t * t)

Converts an LDAP GeneralizedTime string in ldb_val format to a time_t. Time-zone-hopping from val-land into time-land 🌸


πŸ”€ ldb_valid_attr_name

int ldb_valid_attr_name (const char * s)

Checks that the attribute name is valid according to rfc2251. Gatekeeping, but make it standards-compliant πŸ‘‘

Parameters

  • s β€” the string to check

Returns

1 if the name is ok βœ…


πŸ’– Author

Generated automatically by Doxygen for LDB from the source code. (Not a human, just a very diligent robot who never misses 🫑)


And that's a wrap on the whole page, bestie!! πŸŽ€ You made it all the way to the bottom, which is honestly iconic behavior πŸ‘‘ The little footer at the very end stamps the source/version as LDB and the page as include/ldb.h(3) β€” that's your "the end, go touch grass" marker πŸ’…βœ¨ 🌈

πŸ“¦ where this page comes from