2004-03-31 10:45:39 +04:00
/*
ldb database library
Copyright ( C ) Andrew Tridgell 2004
2004-10-20 23:28:02 +04:00
Copyright ( C ) Stefan Metzmacher 2004
2006-11-02 02:31:26 +03:00
Copyright ( C ) Simo Sorce 2005 - 2006
2004-03-31 10:45:39 +04:00
* * NOTE ! The following LGPL license applies to the ldb
* * library . This does NOT imply that all of Samba is released
* * under the LGPL
This library is free software ; you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation ; either
2007-07-10 06:46:15 +04:00
version 3 of the License , or ( at your option ) any later version .
2004-03-31 10:45:39 +04:00
This library is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public
2007-07-10 07:42:26 +04:00
License along with this library ; if not , see < http : //www.gnu.org/licenses/>.
2004-03-31 10:45:39 +04:00
*/
/*
* Name : ldb
*
* Component : ldb header
*
* Description : defines for base ldb API
*
* Author : Andrew Tridgell
2004-10-20 23:28:02 +04:00
* Author : Stefan Metzmacher
2004-03-31 10:45:39 +04:00
*/
2006-01-11 19:31:57 +03:00
/**
\ file ldb . h Samba ' s ldb database
This header file provides the main API for ldb .
*/
2004-05-06 08:40:15 +04:00
# ifndef _LDB_H_
2006-01-11 19:31:57 +03:00
/*! \cond DOXYGEN_IGNORE */
2004-05-06 08:40:15 +04:00
# define _LDB_H_ 1
2006-01-11 19:31:57 +03:00
/*! \endcond */
2004-05-06 08:40:15 +04:00
2004-03-31 10:45:39 +04:00
/*
major restrictions as compared to normal LDAP :
- no async calls .
- each record must have a unique key field
- the key must be representable as a NULL terminated C string and may not
contain a comma or braces
major restrictions as compared to tdb :
- no explicit locking calls
2005-09-22 13:06:37 +04:00
UPDATE : we have transactions now , better than locking - - SSS .
2004-03-31 10:45:39 +04:00
*/
2005-06-15 05:02:53 +04:00
# ifndef ldb_val
2006-01-11 19:31:57 +03:00
/**
Result value
An individual lump of data in a result comes in this format . The
pointer will usually be to a UTF - 8 string if the application is
sensible , but it can be to anything you like , including binary data
blobs of arbitrary size .
\ note the data is null ( 0x00 ) terminated , but the length does not
include the terminator .
*/
2004-03-31 10:45:39 +04:00
struct ldb_val {
2006-01-11 19:31:57 +03:00
uint8_t * data ; /*!< result data */
size_t length ; /*!< length of data */
2004-03-31 10:45:39 +04:00
} ;
2005-06-15 05:02:53 +04:00
# endif
2004-03-31 10:45:39 +04:00
2006-08-23 13:19:19 +04:00
/*! \cond DOXYGEN_IGNORE */
# ifndef PRINTF_ATTRIBUTE
# define PRINTF_ATTRIBUTE(a,b)
# endif
/*! \endcond */
2006-11-02 02:31:26 +03:00
/* opaque ldb_dn structures, see ldb_dn.c for internals */
struct ldb_dn_component ;
struct ldb_dn ;
2005-08-18 19:02:01 +04:00
2006-01-11 19:31:57 +03:00
/**
There are a number of flags that are used with ldap_modify ( ) in
ldb_message_element . flags fields . The LDA_FLAGS_MOD_ADD ,
LDA_FLAGS_MOD_DELETE and LDA_FLAGS_MOD_REPLACE flags are used in
ldap_modify ( ) calls to specify whether attributes are being added ,
deleted or modified respectively .
*/
2004-03-31 10:45:39 +04:00
# define LDB_FLAG_MOD_MASK 0x3
2006-01-11 19:31:57 +03:00
/**
Flag value used in ldap_modify ( ) to indicate that attributes are
being added .
\ sa LDB_FLAG_MOD_MASK
*/
2004-03-31 10:45:39 +04:00
# define LDB_FLAG_MOD_ADD 1
2006-01-11 19:31:57 +03:00
/**
Flag value used in ldap_modify ( ) to indicate that attributes are
being replaced .
\ sa LDB_FLAG_MOD_MASK
*/
2004-03-31 10:45:39 +04:00
# define LDB_FLAG_MOD_REPLACE 2
2006-01-11 19:31:57 +03:00
/**
Flag value used in ldap_modify ( ) to indicate that attributes are
being deleted .
\ sa LDB_FLAG_MOD_MASK
*/
2004-03-31 10:45:39 +04:00
# define LDB_FLAG_MOD_DELETE 3
2006-01-11 19:31:57 +03:00
/**
OID for logic AND comaprison .
2004-03-31 10:45:39 +04:00
2006-01-11 19:31:57 +03:00
This is the well known object ID for a logical AND comparitor .
2005-06-14 07:04:24 +04:00
*/
# define LDB_OID_COMPARATOR_AND "1.2.840.113556.1.4.803"
2006-01-11 19:31:57 +03:00
/**
OID for logic OR comparison .
This is the well known object ID for a logical OR comparitor .
*/
2005-06-14 07:04:24 +04:00
# define LDB_OID_COMPARATOR_OR "1.2.840.113556.1.4.804"
2006-01-11 19:31:57 +03:00
/**
2004-03-31 10:45:39 +04:00
results are given back as arrays of ldb_message_element
*/
struct ldb_message_element {
unsigned int flags ;
2005-06-15 05:02:53 +04:00
const char * name ;
2004-04-03 16:29:21 +04:00
unsigned int num_values ;
struct ldb_val * values ;
2004-03-31 10:45:39 +04:00
} ;
2006-01-11 19:31:57 +03:00
/**
2004-03-31 10:45:39 +04:00
a ldb_message represents all or part of a record . It can contain an arbitrary
number of elements .
*/
struct ldb_message {
2005-08-18 19:02:01 +04:00
struct ldb_dn * dn ;
2004-03-31 10:45:39 +04:00
unsigned int num_elements ;
struct ldb_message_element * elements ;
} ;
2004-04-03 16:29:21 +04:00
enum ldb_changetype {
LDB_CHANGETYPE_NONE = 0 ,
LDB_CHANGETYPE_ADD ,
LDB_CHANGETYPE_DELETE ,
LDB_CHANGETYPE_MODIFY
} ;
2006-01-11 19:31:57 +03:00
/**
LDIF record
This structure contains a LDIF record , as returned from ldif_read ( )
and equivalent functions .
2004-04-03 16:29:21 +04:00
*/
struct ldb_ldif {
2006-01-11 19:31:57 +03:00
enum ldb_changetype changetype ; /*!< The type of change */
struct ldb_message * msg ; /*!< The changes */
2004-04-03 16:29:21 +04:00
} ;
2004-03-31 10:45:39 +04:00
enum ldb_scope { LDB_SCOPE_DEFAULT = - 1 ,
LDB_SCOPE_BASE = 0 ,
LDB_SCOPE_ONELEVEL = 1 ,
LDB_SCOPE_SUBTREE = 2 } ;
struct ldb_context ;
2008-09-12 02:33:16 +04:00
struct event_context ;
2004-03-31 10:45:39 +04:00
2004-05-06 13:55:05 +04:00
/* debugging uses one of the following levels */
enum ldb_debug_level { LDB_DEBUG_FATAL , LDB_DEBUG_ERROR ,
LDB_DEBUG_WARNING , LDB_DEBUG_TRACE } ;
2006-01-11 19:31:57 +03:00
/**
2004-05-06 13:55:05 +04:00
the user can optionally supply a debug function . The function
is based on the vfprintf ( ) style of interface , but with the addition
of a severity level
*/
struct ldb_debug_ops {
void ( * debug ) ( void * context , enum ldb_debug_level level ,
2006-08-23 13:19:19 +04:00
const char * fmt , va_list ap ) PRINTF_ATTRIBUTE ( 3 , 0 ) ;
2004-05-06 13:55:05 +04:00
void * context ;
} ;
2006-02-04 03:38:48 +03:00
/**
The user can optionally supply a custom utf8 functions ,
to handle comparisons and casefolding .
*/
struct ldb_utf8_fns {
void * context ;
2008-08-22 11:36:56 +04:00
char * ( * casefold ) ( void * context , TALLOC_CTX * mem_ctx , const char * s , size_t n ) ;
2006-02-04 03:38:48 +03:00
} ;
2006-01-11 19:31:57 +03:00
/**
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 .
*/
2004-03-31 10:45:39 +04:00
# define LDB_FLG_RDONLY 1
2006-01-11 19:31:57 +03:00
/**
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 .
*/
2005-09-22 08:16:46 +04:00
# define LDB_FLG_NOSYNC 2
2004-03-31 10:45:39 +04:00
2006-04-25 20:08:55 +04:00
/**
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 ( actually make sense only with ldap ) .
*/
2006-04-25 20:21:56 +04:00
# define LDB_FLG_RECONNECT 4
2006-04-25 20:08:55 +04:00
2007-06-06 16:44:04 +04:00
/**
Flag to tell backends not to use mmap
*/
# define LDB_FLG_NOMMAP 8
2006-01-11 19:31:57 +03:00
/*
structures for ldb_parse_tree handling code
*/
2005-07-19 13:09:00 +04:00
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 } ;
2005-06-13 13:10:17 +04:00
struct ldb_parse_tree {
enum ldb_parse_op operation ;
union {
struct {
2005-07-19 13:09:00 +04:00
struct ldb_parse_tree * child ;
} isnot ;
2005-07-12 16:04:54 +04:00
struct {
2005-10-12 10:10:23 +04:00
const char * attr ;
2005-07-19 13:09:00 +04:00
struct ldb_val value ;
} equality ;
2005-07-12 16:04:54 +04:00
struct {
2005-10-12 10:10:23 +04:00
const char * attr ;
2005-07-12 16:04:54 +04:00
int start_with_wildcard ;
int end_with_wildcard ;
struct ldb_val * * chunks ;
} substring ;
2005-07-19 13:09:00 +04:00
struct {
2005-10-12 10:10:23 +04:00
const char * attr ;
2005-07-19 13:09:00 +04:00
} present ;
struct {
2005-10-12 10:10:23 +04:00
const char * attr ;
2005-07-19 13:09:00 +04:00
struct ldb_val value ;
} comparison ;
2005-06-14 05:35:44 +04:00
struct {
2005-10-12 10:10:23 +04:00
const char * attr ;
2005-06-14 05:35:44 +04:00
int dnAttributes ;
char * rule_id ;
struct ldb_val value ;
} extended ;
2005-06-13 13:10:17 +04:00
struct {
unsigned int num_elements ;
struct ldb_parse_tree * * elements ;
} list ;
} u ;
} ;
2007-11-20 17:50:08 +03:00
struct ldb_parse_tree * ldb_parse_tree ( TALLOC_CTX * mem_ctx , const char * s ) ;
char * ldb_filter_from_tree ( TALLOC_CTX * mem_ctx , struct ldb_parse_tree * tree ) ;
2006-01-26 19:37:37 +03:00
/**
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 .
2008-03-02 12:46:47 +03:00
\ param mem_ctx the memory context to allocate the return string in .
2006-01-26 19:37:37 +03:00
\ param val the ( potentially ) binary data to be encoded
\ return the encoded data as a null terminated string
\ sa < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > .
*/
2007-11-20 17:50:08 +03:00
char * ldb_binary_encode ( TALLOC_CTX * mem_ctx , struct ldb_val val ) ;
2006-01-26 19:37:37 +03:00
/**
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 .
\ param mem_ctx the memory context to allocate the return string in .
\ param string the string to be encoded
\ return the encoded data as a null terminated string
\ sa < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > .
*/
2007-11-20 17:50:08 +03:00
char * ldb_binary_encode_string ( TALLOC_CTX * mem_ctx , const char * string ) ;
2005-06-21 10:35:55 +04:00
/*
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
functions for controlling attribute handling
2005-06-21 10:35:55 +04:00
*/
2007-11-20 17:50:08 +03:00
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 * ) ;
2005-06-21 10:35:55 +04:00
2006-11-02 02:31:26 +03:00
/*
attribute handler structure
attr - > The attribute name
flags - > LDB_ATTR_FLAG_ *
ldif_read_fn - > convert from ldif to binary format
ldif_write_fn - > convert from binary to ldif format
canonicalise_fn - > canonicalise a value , for use by indexing and dn construction
comparison_fn - > compare two values
*/
2006-12-15 16:08:57 +03:00
struct ldb_schema_syntax {
const char * name ;
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
ldb_attr_handler_t ldif_read_fn ;
ldb_attr_handler_t ldif_write_fn ;
ldb_attr_handler_t canonicalise_fn ;
ldb_attr_comparison_t comparison_fn ;
2005-06-21 10:35:55 +04:00
} ;
2006-12-15 16:08:57 +03:00
struct ldb_schema_attribute {
2006-12-14 13:03:21 +03:00
const char * name ;
2006-12-15 16:08:57 +03:00
unsigned flags ;
const struct ldb_schema_syntax * syntax ;
2006-12-14 13:03:21 +03:00
} ;
2006-12-15 16:08:57 +03:00
const struct ldb_schema_attribute * ldb_schema_attribute_by_name ( struct ldb_context * ldb ,
const char * name ) ;
2008-12-16 10:19:07 +03:00
struct ldb_dn_extended_syntax {
const char * name ;
ldb_attr_handler_t read_fn ;
ldb_attr_handler_t write_clear_fn ;
ldb_attr_handler_t write_hex_fn ;
} ;
const struct ldb_dn_extended_syntax * ldb_dn_extended_syntax_by_name ( struct ldb_context * ldb ,
const char * name ) ;
2006-01-11 19:31:57 +03:00
/**
The attribute is not returned by default
*/
# define LDB_ATTR_FLAG_HIDDEN (1<<0)
2005-10-12 10:10:23 +04:00
2006-10-17 09:50:01 +04:00
/* the attribute handler name should be freed when released */
# define LDB_ATTR_FLAG_ALLOCATED (1<<1)
2006-01-11 19:31:57 +03:00
/**
2008-08-20 09:46:58 +04:00
The attribute is supplied by the application and should not be removed
2006-01-11 19:31:57 +03:00
*/
2008-08-20 09:46:58 +04:00
# define LDB_ATTR_FLAG_FIXED (1<<2)
2006-01-11 19:31:57 +03:00
/**
LDAP attribute syntax for a DN
This is the well - known LDAP attribute syntax for a DN .
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
2006-01-11 19:31:57 +03:00
See < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > , Section 4.3 .2
*/
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
# define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12"
2006-01-11 19:31:57 +03:00
/**
LDAP attribute syntax for a Directory String
This is the well - known LDAP attribute syntax for a Directory String .
2006-01-26 19:37:37 +03:00
\ sa < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > , Section 4.3 .2
2006-01-11 19:31:57 +03:00
*/
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
# define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15"
2006-01-11 19:31:57 +03:00
/**
LDAP attribute syntax for an integer
This is the well - known LDAP attribute syntax for an integer .
See < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > , Section 4.3 .2
*/
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
# define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27"
2006-01-11 19:31:57 +03:00
/**
LDAP attribute syntax for an octet string
This is the well - known LDAP attribute syntax for an octet string .
See < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > , Section 4.3 .2
*/
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
# define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40"
2006-01-11 19:31:57 +03:00
/**
LDAP attribute syntax for UTC time .
This is the well - known LDAP attribute syntax for a UTC time .
See < a href = " http://www.ietf.org/rfc/rfc2252.txt " > RFC 2252 < / a > , Section 4.3 .2
*/
2005-10-12 11:54:15 +04:00
# define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53"
2006-01-11 19:31:57 +03:00
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the
generic ldb code. This allows the ldb_match() message match logic
to be generic, so it can be used by other backend
- added the generic ability to load attribute handlers, for
canonicalisation, compare, ldif read and ldif write. In the future
this will be used by the schema module to allow us to correctly
obey the attributetype schema elements
- added attribute handlers for some of the core ldap attribute types,
Integer, DirectoryString, DN, ObjectClass etc
- added automatic registration of attribute handlers for well-known
attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass'
- converted the objectSid special handlers for Samba to the new system
- added more correct handling of indexing in tdb backend based on the
attribute canonicalisation function
- added generic support for subclasses, moving it out of the tdb
backend. This will be used in future by the schema module
- fixed several bugs in the dn_explode code. It still needs more
work, but doesn't corrupt ldb dbs any more.
(This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
2005-07-01 10:21:26 +04:00
# define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS"
2005-06-21 10:35:55 +04:00
2006-01-06 07:01:23 +03:00
/* sorting helpers */
2006-01-24 21:40:53 +03:00
typedef int ( * ldb_qsort_cmp_fn_t ) ( void * v1 , void * v2 , void * opaque ) ;
2006-01-06 07:01:23 +03:00
2006-01-11 19:31:57 +03:00
/**
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 .
\ sa < a href = " http://www.ietf.org/rfc/rfc2696.txt " > RFC 2696 < / a > .
*/
2006-01-06 07:01:23 +03:00
# define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319"
2006-01-11 19:31:57 +03:00
2006-08-05 14:26:23 +04:00
/**
OID for specifying the returned elements of the ntSecurityDescriptor
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_sd_flags_oid.asp " > Microsoft documentation of this OID < / a >
*/
# define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801"
2006-08-05 15:38:50 +04:00
/**
OID for specifying an advanced scope for the search ( one partition )
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_domain_scope_oid.asp " > Microsoft documentation of this OID < / a >
*/
# define LDB_CONTROL_DOMAIN_SCOPE_OID "1.2.840.113556.1.4.1339"
2006-08-05 15:18:14 +04:00
/**
OID for specifying an advanced scope for a search
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_search_options_oid.asp " > Microsoft documentation of this OID < / a >
*/
# define LDB_CONTROL_SEARCH_OPTIONS_OID "1.2.840.113556.1.4.1340"
2006-01-17 21:56:04 +03:00
/**
OID for notification
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_notification_oid.asp " > Microsoft documentation of this OID < / a >
*/
# define LDB_CONTROL_NOTIFICATION_OID "1.2.840.113556.1.4.528"
2006-08-05 23:35:00 +04:00
/**
OID for getting deleted objects
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_show_deleted_oid.asp " > Microsoft documentation of this OID < / a >
*/
# define LDB_CONTROL_SHOW_DELETED_OID "1.2.840.113556.1.4.417"
2006-01-11 19:31:57 +03:00
/**
OID for extended DN
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_extended_dn_oid.asp " > Microsoft documentation of this OID < / a >
*/
2006-01-06 07:01:23 +03:00
# define LDB_CONTROL_EXTENDED_DN_OID "1.2.840.113556.1.4.529"
2006-01-11 19:31:57 +03:00
/**
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 .
\ sa < a href = " http://www.ietf.org/rfc/rfc2891.txt " > RFC 2891 < / a > .
*/
2006-01-06 07:01:23 +03:00
# define LDB_CONTROL_SERVER_SORT_OID "1.2.840.113556.1.4.473"
2006-01-11 19:31:57 +03:00
/**
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 .
\ sa < a href = " http://www.ietf.org/rfc/rfc2891.txt " > RFC 2891 < / a > .
*/
2006-01-06 07:01:23 +03:00
# define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474"
2006-01-14 04:06:16 +03:00
/**
OID for LDAP Attribute Scoped Query extension .
2006-02-06 04:21:17 +03:00
This control is included in SearchRequest or SearchResponse
2006-01-14 04:06:16 +03:00
messages as part of the controls field of the LDAPMessage .
*/
# define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504"
2006-01-17 07:04:57 +03:00
/**
2006-02-06 04:21:17 +03:00
OID for LDAP Directory Sync extension .
2006-01-17 07:04:57 +03:00
2006-02-06 04:21:17 +03:00
This control is included in SearchRequest or SearchResponse
2006-01-17 07:04:57 +03:00
messages as part of the controls field of the LDAPMessage .
*/
# define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841"
2006-01-14 04:06:16 +03:00
2006-02-06 04:21:17 +03:00
/**
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_REQ_OID "2.16.840.1.113730.3.4.9"
/**
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_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10"
2006-08-05 23:50:58 +04:00
/**
OID to let modifies don ' t give an error when adding an existing
attribute with the same value or deleting an nonexisting one attribute
\ sa < a href = " http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_permissive_modify_oid.asp " > Microsoft documentation of this OID < / a >
*/
# define LDB_CONTROL_PERMISSIVE_MODIFY_OID "1.2.840.113556.1.4.1413"
2006-07-23 01:16:01 +04:00
/**
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 .
*/
2006-07-25 07:41:32 +04:00
# define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037"
2006-07-23 01:16:01 +04:00
2006-08-01 07:22:02 +04:00
/**
*/
# define LDB_EXTENDED_DYNAMIC_OID "1.3.6.1.4.1.1466.101.119.1"
/**
*/
# define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781"
2006-08-05 14:26:23 +04:00
struct ldb_sd_flags_control {
/*
* request the owner 0x00000001
* request the group 0x00000002
* request the DACL 0x00000004
* request the SACL 0x00000008
*/
unsigned secinfo_flags ;
} ;
2007-02-22 04:54:40 +03:00
/*
* DOMAIN_SCOPE 0x00000001
* this limits the search to one partition ,
* and no referrals will be returned .
* ( Note this doesn ' t limit the entries by there
* objectSid belonging to a domain ! Builtin and Foreign Sids
* are still returned )
*
* PHANTOM_ROOT 0x00000002
* this search on the whole tree on a domain controller
* over multiple partitions without referrals .
* ( This is the default behavior on the Global Catalog Port )
*/
# define LDB_SEARCH_OPTION_DOMAIN_SCOPE 0x00000001
# define LDB_SEARCH_OPTION_PHANTOM_ROOT 0x00000002
2006-08-05 15:18:14 +04:00
struct ldb_search_options_control {
unsigned search_options ;
} ;
2006-01-06 07:01:23 +03:00
struct ldb_paged_control {
int size ;
int cookie_len ;
char * cookie ;
} ;
struct ldb_extended_dn_control {
int type ;
} ;
struct ldb_server_sort_control {
char * attributeName ;
char * orderingRule ;
int reverse ;
} ;
struct ldb_sort_resp_control {
int result ;
char * attr_desc ;
} ;
2006-01-14 04:06:16 +03:00
struct ldb_asq_control {
int request ;
char * source_attribute ;
int src_attr_len ;
int result ;
} ;
2006-01-17 07:04:57 +03:00
struct ldb_dirsync_control {
int flags ;
int max_attributes ;
int cookie_len ;
char * cookie ;
} ;
2006-02-06 04:21:17 +03:00
struct ldb_vlv_req_control {
int beforeCount ;
int afterCount ;
int type ;
union {
struct {
int offset ;
int contentCount ;
} byOffset ;
struct {
int value_len ;
char * value ;
} gtOrEq ;
} match ;
int ctxid_len ;
char * contextId ;
} ;
struct ldb_vlv_resp_control {
int targetPosition ;
int contentCount ;
int vlv_result ;
int ctxid_len ;
char * contextId ;
} ;
2006-01-06 07:01:23 +03:00
struct ldb_control {
const char * oid ;
int critical ;
void * data ;
} ;
2005-11-08 03:11:45 +03:00
enum ldb_request_type {
2006-05-30 04:33:52 +04:00
LDB_SEARCH ,
LDB_ADD ,
LDB_MODIFY ,
LDB_DELETE ,
LDB_RENAME ,
2006-07-23 01:16:01 +04:00
LDB_EXTENDED ,
r16264: Add, but do not yet enable, the partitions module.
This required changes to the rootDSE module, to allow registration of
partitions. In doing so I renamed the 'register' operation to
'register_control' and 'register_partition', which changed a few more
modules.
Due to the behaviour of certain LDAP servers, we create the baseDN
entry in two parts: Firstly, we allow the admin to export a simple
LDIF file to add to their server. Then we perform a modify to add the
remaining attributes.
To delete all users in partitions, we must now search and delete all
objects in the partition, rather than a simple search from the root.
Against LDAP, this might not delete all objects, so we allow this to
fail.
In testing, we found that the 'Domain Controllers' container was
misnamed, and should be 'CN=', rather than 'OU='.
To avoid the Templates being found in default searches, they have been
moved to CN=Templates from CN=Templates,${BASEDN}.
Andrew Bartlett
(This used to be commit b49a4fbb57f10726bd288fdc9fc95c0cbbe9094a)
2006-06-15 22:04:24 +04:00
LDB_REQ_REGISTER_CONTROL ,
2007-01-06 12:03:28 +03:00
LDB_REQ_REGISTER_PARTITION
2005-11-08 03:11:45 +03:00
} ;
2006-02-22 04:31:35 +03:00
enum ldb_reply_type {
LDB_REPLY_ENTRY ,
LDB_REPLY_REFERRAL ,
LDB_REPLY_DONE
} ;
2006-07-22 20:56:33 +04:00
enum ldb_wait_type {
2006-02-22 04:31:35 +03:00
LDB_WAIT_ALL ,
LDB_WAIT_NONE
} ;
2006-07-22 20:56:33 +04:00
enum ldb_state {
2006-02-22 08:21:43 +03:00
LDB_ASYNC_INIT ,
2006-02-22 04:31:35 +03:00
LDB_ASYNC_PENDING ,
LDB_ASYNC_DONE
} ;
2007-01-06 12:49:29 +03:00
struct ldb_extended {
const char * oid ;
2007-01-07 22:04:40 +03:00
void * data ; /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
2007-01-06 12:49:29 +03:00
} ;
2008-10-15 22:03:20 +04:00
# define LDB_EXTENDED_SEQUENCE_NUMBER "1.3.6.1.4.1.7165.4.4.3"
enum ldb_sequence_type {
LDB_SEQ_HIGHEST_SEQ ,
LDB_SEQ_HIGHEST_TIMESTAMP ,
LDB_SEQ_NEXT
} ;
struct ldb_seqnum_request {
enum ldb_sequence_type type ;
} ;
struct ldb_seqnum_result {
uint64_t seq_num ;
uint32_t flags ;
} ;
2005-11-08 03:11:45 +03:00
struct ldb_result {
unsigned int count ;
struct ldb_message * * msgs ;
2007-01-06 12:49:29 +03:00
struct ldb_extended * extended ;
2006-01-06 07:01:23 +03:00
struct ldb_control * * controls ;
2008-10-15 22:03:20 +04:00
char * * refs ;
2005-11-08 03:11:45 +03:00
} ;
2006-07-22 20:56:33 +04:00
struct ldb_reply {
2008-10-15 22:03:20 +04:00
int error ;
2006-02-22 04:31:35 +03:00
enum ldb_reply_type type ;
struct ldb_message * message ;
2006-07-23 01:16:01 +04:00
struct ldb_extended * response ;
2006-02-22 04:31:35 +03:00
struct ldb_control * * controls ;
2008-10-15 22:03:20 +04:00
char * referral ;
2006-02-22 04:31:35 +03:00
} ;
2008-09-12 02:33:16 +04:00
struct ldb_request ;
struct ldb_handle ;
2006-02-22 04:31:35 +03:00
2005-11-08 03:11:45 +03:00
struct ldb_search {
2006-11-22 03:59:34 +03:00
struct ldb_dn * base ;
2005-11-08 03:11:45 +03:00
enum ldb_scope scope ;
2007-12-26 02:10:34 +03:00
struct ldb_parse_tree * tree ;
2005-11-08 03:11:45 +03:00
const char * const * attrs ;
2005-11-29 15:34:03 +03:00
struct ldb_result * res ;
2005-11-08 03:11:45 +03:00
} ;
struct ldb_add {
2006-05-20 23:37:21 +04:00
const struct ldb_message * message ;
2005-11-08 03:11:45 +03:00
} ;
2007-01-06 12:25:54 +03:00
struct ldb_modify {
2006-05-20 23:37:21 +04:00
const struct ldb_message * message ;
2005-11-08 03:11:45 +03:00
} ;
struct ldb_delete {
2006-11-22 03:59:34 +03:00
struct ldb_dn * dn ;
2005-11-08 03:11:45 +03:00
} ;
struct ldb_rename {
2006-11-22 03:59:34 +03:00
struct ldb_dn * olddn ;
struct ldb_dn * newdn ;
2005-11-08 03:11:45 +03:00
} ;
2006-01-06 07:01:23 +03:00
struct ldb_register_control {
const char * oid ;
} ;
r16264: Add, but do not yet enable, the partitions module.
This required changes to the rootDSE module, to allow registration of
partitions. In doing so I renamed the 'register' operation to
'register_control' and 'register_partition', which changed a few more
modules.
Due to the behaviour of certain LDAP servers, we create the baseDN
entry in two parts: Firstly, we allow the admin to export a simple
LDIF file to add to their server. Then we perform a modify to add the
remaining attributes.
To delete all users in partitions, we must now search and delete all
objects in the partition, rather than a simple search from the root.
Against LDAP, this might not delete all objects, so we allow this to
fail.
In testing, we found that the 'Domain Controllers' container was
misnamed, and should be 'CN=', rather than 'OU='.
To avoid the Templates being found in default searches, they have been
moved to CN=Templates from CN=Templates,${BASEDN}.
Andrew Bartlett
(This used to be commit b49a4fbb57f10726bd288fdc9fc95c0cbbe9094a)
2006-06-15 22:04:24 +04:00
struct ldb_register_partition {
2006-11-22 03:59:34 +03:00
struct ldb_dn * dn ;
r16264: Add, but do not yet enable, the partitions module.
This required changes to the rootDSE module, to allow registration of
partitions. In doing so I renamed the 'register' operation to
'register_control' and 'register_partition', which changed a few more
modules.
Due to the behaviour of certain LDAP servers, we create the baseDN
entry in two parts: Firstly, we allow the admin to export a simple
LDIF file to add to their server. Then we perform a modify to add the
remaining attributes.
To delete all users in partitions, we must now search and delete all
objects in the partition, rather than a simple search from the root.
Against LDAP, this might not delete all objects, so we allow this to
fail.
In testing, we found that the 'Domain Controllers' container was
misnamed, and should be 'CN=', rather than 'OU='.
To avoid the Templates being found in default searches, they have been
moved to CN=Templates from CN=Templates,${BASEDN}.
Andrew Bartlett
(This used to be commit b49a4fbb57f10726bd288fdc9fc95c0cbbe9094a)
2006-06-15 22:04:24 +04:00
} ;
2008-09-12 02:33:16 +04:00
typedef int ( * ldb_request_callback_t ) ( struct ldb_request * , struct ldb_reply * ) ;
2005-11-08 03:11:45 +03:00
struct ldb_request {
2006-05-20 23:37:21 +04:00
enum ldb_request_type operation ;
2005-11-08 03:11:45 +03:00
union {
struct ldb_search search ;
struct ldb_add add ;
struct ldb_modify mod ;
struct ldb_delete del ;
struct ldb_rename rename ;
2007-01-06 12:25:54 +03:00
struct ldb_extended extended ;
r16264: Add, but do not yet enable, the partitions module.
This required changes to the rootDSE module, to allow registration of
partitions. In doing so I renamed the 'register' operation to
'register_control' and 'register_partition', which changed a few more
modules.
Due to the behaviour of certain LDAP servers, we create the baseDN
entry in two parts: Firstly, we allow the admin to export a simple
LDIF file to add to their server. Then we perform a modify to add the
remaining attributes.
To delete all users in partitions, we must now search and delete all
objects in the partition, rather than a simple search from the root.
Against LDAP, this might not delete all objects, so we allow this to
fail.
In testing, we found that the 'Domain Controllers' container was
misnamed, and should be 'CN=', rather than 'OU='.
To avoid the Templates being found in default searches, they have been
moved to CN=Templates from CN=Templates,${BASEDN}.
Andrew Bartlett
(This used to be commit b49a4fbb57f10726bd288fdc9fc95c0cbbe9094a)
2006-06-15 22:04:24 +04:00
struct ldb_register_control reg_control ;
struct ldb_register_partition reg_partition ;
2005-11-08 03:11:45 +03:00
} op ;
2006-01-06 07:01:23 +03:00
struct ldb_control * * controls ;
2006-02-22 04:31:35 +03:00
2006-07-22 21:21:59 +04:00
void * context ;
2006-09-21 10:14:32 +04:00
ldb_request_callback_t callback ;
2006-07-22 21:21:59 +04:00
int timeout ;
time_t starttime ;
struct ldb_handle * handle ;
2006-01-26 19:37:37 +03:00
} ;
2005-11-08 03:11:45 +03:00
int ldb_request ( struct ldb_context * ldb , struct ldb_request * request ) ;
2008-09-12 02:33:16 +04:00
int ldb_request_done ( struct ldb_request * req , int status ) ;
bool ldb_request_is_done ( struct ldb_request * req ) ;
2005-11-08 03:11:45 +03:00
2008-09-12 02:33:16 +04:00
int ldb_modules_wait ( struct ldb_handle * handle ) ;
2006-07-22 20:56:33 +04:00
int ldb_wait ( struct ldb_handle * handle , enum ldb_wait_type type ) ;
2006-02-22 04:31:35 +03:00
2006-06-04 09:28:13 +04:00
int ldb_set_timeout ( struct ldb_context * ldb , struct ldb_request * req , int timeout ) ;
int ldb_set_timeout_from_prev_req ( struct ldb_context * ldb , struct ldb_request * oldreq , struct ldb_request * newreq ) ;
2006-09-27 09:57:41 +04:00
void ldb_set_create_perms ( struct ldb_context * ldb , unsigned int perms ) ;
2007-09-11 19:42:19 +04:00
void ldb_set_modules_dir ( struct ldb_context * ldb , const char * path ) ;
2008-06-27 11:39:30 +04:00
struct event_context ;
2008-06-14 19:24:17 +04:00
void ldb_set_event_context ( struct ldb_context * ldb , struct event_context * ev ) ;
struct event_context * ldb_get_event_context ( struct ldb_context * ldb ) ;
2006-06-04 09:28:13 +04:00
2006-03-02 19:32:53 +03:00
/**
Initialise ldbs ' global information
This is required before any other LDB call
\ return 0 if initialisation succeeded , - 1 otherwise
*/
int ldb_global_init ( void ) ;
2006-01-11 19:31:57 +03:00
/**
Initialise an ldb context
This is required before any other LDB call .
\ param mem_ctx pointer to a talloc memory context . Pass NULL if there is
no suitable context available .
\ return pointer to ldb_context that should be free ' d ( using talloc_free ( ) )
at the end of the program .
2005-06-18 11:42:21 +04:00
*/
2008-06-14 19:24:17 +04:00
struct ldb_context * ldb_init ( TALLOC_CTX * mem_ctx , struct event_context * ev_ctx ) ;
2005-06-13 13:10:17 +04:00
2006-01-11 19:31:57 +03:00
/**
Connect to a database .
This is typically called soon after ldb_init ( ) , and is required prior to
any search or database modification operations .
The URL can be one of the following forms :
- tdb : //path
- ldapi : //path
- ldap : //host
2006-02-01 02:37:56 +03:00
- sqlite : //path
2004-03-31 10:45:39 +04:00
2006-01-11 19:31:57 +03:00
\ param ldb the context associated with the database ( from ldb_init ( ) )
\ param url the URL of the database to connect to , as noted above
\ param flags a combination of LDB_FLG_ * to modify the connection behaviour
\ param options backend specific options - passed uninterpreted to the backend
2004-03-31 10:45:39 +04:00
2006-01-11 19:31:57 +03:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
\ note It is an error to connect to a database that does not exist in readonly mode
( that is , with LDB_FLG_RDONLY ) . However in read - write mode , the database will be
created if it does not exist .
2004-03-31 10:45:39 +04:00
*/
2008-09-12 02:33:16 +04:00
typedef void ( * ldb_async_timeout_fn ) ( void * ) ;
typedef bool ( * ldb_async_callback_fn ) ( void * ) ;
typedef int ( * ldb_async_ctx_add_op_fn ) ( void * , time_t , void * , ldb_async_timeout_fn , ldb_async_callback_fn ) ;
typedef int ( * ldb_async_ctx_wait_op_fn ) ( void * ) ;
void ldb_async_ctx_set_private_data ( struct ldb_context * ldb ,
void * private_data ) ;
void ldb_async_ctx_set_add_op ( struct ldb_context * ldb ,
ldb_async_ctx_add_op_fn add_op ) ;
void ldb_async_ctx_set_wait_op ( struct ldb_context * ldb ,
ldb_async_ctx_wait_op_fn wait_op ) ;
2005-06-18 11:42:21 +04:00
int ldb_connect ( struct ldb_context * ldb , const char * url , unsigned int flags , const char * options [ ] ) ;
2004-03-31 10:45:39 +04:00
2006-12-22 20:27:07 +03:00
/*
return an automatic basedn from the rootDomainNamingContext of the rootDSE
This value have been set in an opaque pointer at connection time
*/
struct ldb_dn * ldb_get_root_basedn ( struct ldb_context * ldb ) ;
/*
return an automatic basedn from the configurationNamingContext of the rootDSE
This value have been set in an opaque pointer at connection time
*/
struct ldb_dn * ldb_get_config_basedn ( struct ldb_context * ldb ) ;
/*
return an automatic basedn from the schemaNamingContext of the rootDSE
This value have been set in an opaque pointer at connection time
*/
struct ldb_dn * ldb_get_schema_basedn ( struct ldb_context * ldb ) ;
2006-08-25 10:41:37 +04:00
/*
return an automatic baseDN from the defaultNamingContext of the rootDSE
2006-08-25 16:59:03 +04:00
This value have been set in an opaque pointer at connection time
2006-08-25 10:41:37 +04:00
*/
2006-11-22 03:59:34 +03:00
struct ldb_dn * ldb_get_default_basedn ( struct ldb_context * ldb ) ;
2006-08-25 10:41:37 +04:00
2006-10-23 01:16:22 +04:00
/**
2007-01-07 18:26:35 +03:00
The default async search callback function
2006-10-23 01:16:22 +04:00
2008-09-12 02:33:16 +04:00
\ param req the request we are callback of
2006-10-23 01:16:22 +04:00
\ param ares a single reply from the async core
\ return result code ( LDB_SUCCESS on success , or a failure code )
2008-09-12 02:33:16 +04:00
\ note this function expects req - > context to always be an struct ldb_result pointer
2006-10-23 01:16:22 +04:00
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
( the request need to be freed separately and the result doe not depend on the
request that can be freed as sson as the search request is finished )
*/
2008-09-12 02:33:16 +04:00
int ldb_search_default_callback ( struct ldb_request * req , struct ldb_reply * ares ) ;
/**
The default async extended operation callback function
\ param req the request we are callback of
\ param ares a single reply from the async core
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_op_default_callback ( struct ldb_request * req , struct ldb_reply * ares ) ;
2006-10-23 01:16:22 +04:00
/**
Helper function to build a search request
\ param ret_req the request structure is returned here ( talloced on mem_ctx )
\ param ldb the context associated with the database ( from ldb_init ( ) )
2007-09-11 19:42:19 +04:00
\ param mem_ctx a talloc memory context ( used as parent of ret_req )
2006-10-23 01:16:22 +04:00
\ param base the Base Distinguished Name for the query ( use ldb_dn_new ( ) for an empty one )
\ param scope the search scope for the query
\ param expression the search expression to use for this query
\ param attrs the search attributes for the query ( pass NULL if none required )
\ param controls an array of controls
\ param context the callback function context
2008-09-12 02:33:16 +04:00
\ param the callback function to handle the async replies
\ param the parent request if any
2006-10-23 01:16:22 +04:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_build_search_req ( struct ldb_request * * ret_req ,
struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2006-11-22 03:59:34 +03:00
struct ldb_dn * base ,
2006-10-23 01:16:22 +04:00
enum ldb_scope scope ,
const char * expression ,
const char * const * attrs ,
struct ldb_control * * controls ,
void * context ,
2008-09-12 02:33:16 +04:00
ldb_request_callback_t callback ,
struct ldb_request * parent ) ;
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 ) ;
2006-10-23 01:16:22 +04:00
/**
Helper function to build an add request
\ param ret_req the request structure is returned here ( talloced on mem_ctx )
\ param ldb the context associated with the database ( from ldb_init ( ) )
2007-09-11 19:42:19 +04:00
\ param mem_ctx a talloc memory context ( used as parent of ret_req )
2006-10-23 01:16:22 +04:00
\ param message contains the entry to be added
\ param controls an array of controls
\ param context the callback function context
2008-09-12 02:33:16 +04:00
\ param the callback function to handle the async replies
\ param the parent request if any
2006-10-23 01:16:22 +04:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_build_add_req ( struct ldb_request * * ret_req ,
struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2006-10-23 01:16:22 +04:00
const struct ldb_message * message ,
struct ldb_control * * controls ,
void * context ,
2008-09-12 02:33:16 +04:00
ldb_request_callback_t callback ,
struct ldb_request * parent ) ;
2006-10-23 01:16:22 +04:00
/**
Helper function to build a modify request
\ param ret_req the request structure is returned here ( talloced on mem_ctx )
\ param ldb the context associated with the database ( from ldb_init ( ) )
2007-09-11 19:42:19 +04:00
\ param mem_ctx a talloc memory context ( used as parent of ret_req )
2006-10-23 01:16:22 +04:00
\ param message contains the entry to be modified
\ param controls an array of controls
\ param context the callback function context
2008-09-12 02:33:16 +04:00
\ param the callback function to handle the async replies
\ param the parent request if any
2006-10-23 01:16:22 +04:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_build_mod_req ( struct ldb_request * * ret_req ,
struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2006-10-23 01:16:22 +04:00
const struct ldb_message * message ,
struct ldb_control * * controls ,
void * context ,
2008-09-12 02:33:16 +04:00
ldb_request_callback_t callback ,
struct ldb_request * parent ) ;
2006-10-23 01:16:22 +04:00
/**
Helper function to build a delete request
\ param ret_req the request structure is returned here ( talloced on mem_ctx )
\ param ldb the context associated with the database ( from ldb_init ( ) )
2007-09-11 19:42:19 +04:00
\ param mem_ctx a talloc memory context ( used as parent of ret_req )
2006-10-23 01:16:22 +04:00
\ param dn the DN to be deleted
\ param controls an array of controls
\ param context the callback function context
2008-09-12 02:33:16 +04:00
\ param the callback function to handle the async replies
\ param the parent request if any
2006-10-23 01:16:22 +04:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_build_del_req ( struct ldb_request * * ret_req ,
struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2006-11-22 03:59:34 +03:00
struct ldb_dn * dn ,
2006-10-23 01:16:22 +04:00
struct ldb_control * * controls ,
void * context ,
2008-09-12 02:33:16 +04:00
ldb_request_callback_t callback ,
struct ldb_request * parent ) ;
2006-10-23 01:16:22 +04:00
/**
Helper function to build a rename request
\ param ret_req the request structure is returned here ( talloced on mem_ctx )
\ param ldb the context associated with the database ( from ldb_init ( ) )
2007-09-11 19:42:19 +04:00
\ param mem_ctx a talloc memory context ( used as parent of ret_req )
2006-10-23 01:16:22 +04:00
\ param olddn the old DN
\ param newdn the new DN
\ param controls an array of controls
\ param context the callback function context
2008-09-12 02:33:16 +04:00
\ param the callback function to handle the async replies
\ param the parent request if any
2006-10-23 01:16:22 +04:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_build_rename_req ( struct ldb_request * * ret_req ,
struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2006-11-22 03:59:34 +03:00
struct ldb_dn * olddn ,
struct ldb_dn * newdn ,
2006-10-23 01:16:22 +04:00
struct ldb_control * * controls ,
void * context ,
2008-09-12 02:33:16 +04:00
ldb_request_callback_t callback ,
struct ldb_request * parent ) ;
2006-10-23 01:16:22 +04:00
2007-01-17 19:10:33 +03:00
/**
Add a ldb_control to a ldb_request
\ param req the request struct where to add the control
\ param oid the object identifier of the control as string
2008-03-02 12:46:47 +03:00
\ param critical whether the control should be critical or not
2007-01-17 19:10:33 +03:00
\ param data a talloc pointer to the control specific data
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_request_add_control ( struct ldb_request * req , const char * oid , bool critical , void * data ) ;
2007-02-22 04:54:40 +03:00
/**
check if a control with the specified " oid " exist and return it
\ param req the request struct where to add the control
\ param oid the object identifier of the control as string
\ return the control , NULL if not found
*/
struct ldb_control * ldb_request_get_control ( struct ldb_request * req , const char * oid ) ;
2006-01-11 19:31:57 +03:00
/**
Search the database
This function searches the database , and returns
records that match an LDAP - like search expression
2004-03-31 10:45:39 +04:00
2006-01-11 19:31:57 +03:00
\ param ldb the context associated with the database ( from ldb_init ( ) )
2008-09-23 22:30:06 +04:00
\ param mem_ctx the memory context to use for the request and the results
\ param result the return result
2006-10-23 01:16:22 +04:00
\ param base the Base Distinguished Name for the query ( use ldb_dn_new ( ) for an empty one )
2006-01-11 19:31:57 +03:00
\ param scope the search scope for the query
\ param attrs the search attributes for the query ( pass NULL if none required )
2008-09-23 22:30:06 +04:00
\ param exp_fmt the search expression to use for this query ( printf like )
2005-04-25 16:46:18 +04:00
2006-01-11 19:31:57 +03:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
\ note use talloc_free ( ) to free the ldb_result returned
2004-03-31 10:45:39 +04:00
*/
2008-09-23 22:30:06 +04:00
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 , 8 ) ;
2006-12-05 19:20:39 +03:00
2006-01-11 19:31:57 +03:00
/**
Add a record to the database .
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 .
\ param ldb the context associated with the database ( from
ldb_init ( ) )
\ param message the message containing the record to add .
\ return result code ( LDB_SUCCESS if the record was added , otherwise
a failure code )
2004-03-31 10:45:39 +04:00
*/
int ldb_add ( struct ldb_context * ldb ,
const struct ldb_message * message ) ;
2006-01-11 19:31:57 +03:00
/**
Modify the specified attributes of a record
This function modifies a record that is in the database .
\ param ldb the context associated with the database ( from
ldb_init ( ) )
\ param message the message containing the changes required .
\ return result code ( LDB_SUCCESS if the record was modified as
requested , otherwise a failure code )
2004-03-31 10:45:39 +04:00
*/
int ldb_modify ( struct ldb_context * ldb ,
const struct ldb_message * message ) ;
2006-01-11 19:31:57 +03:00
/**
Rename a record in the database
This function renames a record in the database .
\ param ldb the context associated with the database ( from
ldb_init ( ) )
\ param olddn the DN for the record to be renamed .
\ param newdn the new DN
\ return result code ( LDB_SUCCESS if the record was renamed as
requested , otherwise a failure code )
2004-10-20 23:28:02 +04:00
*/
2006-11-22 03:59:34 +03:00
int ldb_rename ( struct ldb_context * ldb , struct ldb_dn * olddn , struct ldb_dn * newdn ) ;
2004-10-20 23:28:02 +04:00
2006-01-11 19:31:57 +03:00
/**
Delete a record from the database
This function deletes a record from the database .
\ param ldb the context associated with the database ( from
ldb_init ( ) )
\ param dn the DN for the record to be deleted .
\ return result code ( LDB_SUCCESS if the record was deleted ,
otherwise a failure code )
2004-03-31 10:45:39 +04:00
*/
2006-11-22 03:59:34 +03:00
int ldb_delete ( struct ldb_context * ldb , struct ldb_dn * dn ) ;
2004-03-31 10:45:39 +04:00
2007-01-07 18:26:35 +03:00
/**
The default async extended operation callback function
2008-09-12 02:33:16 +04:00
\ param req the request we are callback of
2007-01-07 18:26:35 +03:00
\ param ares a single reply from the async core
\ return result code ( LDB_SUCCESS on success , or a failure code )
2008-09-12 02:33:16 +04:00
\ note this function expects req - > context to always be an struct ldb_result pointer
2007-01-07 18:26:35 +03:00
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
( the request need to be freed separately and the result doe not depend on the
request that can be freed as sson as the search request is finished )
*/
2008-09-12 02:33:16 +04:00
int ldb_extended_default_callback ( struct ldb_request * req , struct ldb_reply * ares ) ;
2007-01-07 18:26:35 +03:00
/**
Helper function to build a extended request
\ param ret_req the request structure is returned here ( talloced on mem_ctx )
\ param ldb the context associated with the database ( from ldb_init ( ) )
2007-09-11 19:42:19 +04:00
\ param mem_ctx a talloc memory context ( used as parent of ret_req )
2007-01-07 18:26:35 +03:00
\ param oid the OID of the extended operation .
2007-01-07 22:04:40 +03:00
\ param data a void pointer a the extended operation specific parameters ,
it needs to be NULL or a valid talloc pointer ! talloc_get_type ( ) will be used on it
2007-01-07 18:26:35 +03:00
\ param controls an array of controls
\ param context the callback function context
2008-09-12 02:33:16 +04:00
\ param the callback function to handle the async replies
\ param the parent request if any
2007-01-07 18:26:35 +03:00
\ return result code ( LDB_SUCCESS on success , or a failure code )
*/
int ldb_build_extended_req ( struct ldb_request * * ret_req ,
struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2007-01-07 18:26:35 +03:00
const char * oid ,
2007-01-07 22:04:40 +03:00
void * data , /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
2007-01-07 18:26:35 +03:00
struct ldb_control * * controls ,
void * context ,
2008-09-12 02:33:16 +04:00
ldb_request_callback_t callback ,
struct ldb_request * parent ) ;
2007-01-07 18:26:35 +03:00
/**
call an extended operation
This function deletes a record from the database .
\ param ldb the context associated with the database ( from ldb_init ( ) )
\ param oid the OID of the extended operation .
2007-01-07 22:04:40 +03:00
\ param data a void pointer a the extended operation specific parameters ,
it needs to be NULL or a valid talloc pointer ! talloc_get_type ( ) will be used on it
2007-01-07 18:26:35 +03:00
\ param res the result of the extended operation
\ return result code ( LDB_SUCCESS if the extended operation returned fine ,
otherwise a failure code )
*/
int ldb_extended ( struct ldb_context * ldb ,
const char * oid ,
2007-01-07 22:04:40 +03:00
void * data , /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
2007-01-07 18:26:35 +03:00
struct ldb_result * * res ) ;
2006-01-11 19:31:57 +03:00
/**
2005-09-24 19:42:15 +04:00
start a transaction
*/
int ldb_transaction_start ( struct ldb_context * ldb ) ;
2006-01-11 19:31:57 +03:00
/**
2005-09-24 19:42:15 +04:00
commit a transaction
*/
int ldb_transaction_commit ( struct ldb_context * ldb ) ;
2006-01-11 19:31:57 +03:00
/**
2005-09-24 19:42:15 +04:00
cancel a transaction
*/
int ldb_transaction_cancel ( struct ldb_context * ldb ) ;
2004-03-31 10:45:39 +04:00
2006-01-11 19:31:57 +03:00
/**
2004-03-31 10:45:39 +04:00
return extended error information from the last call
*/
const char * ldb_errstring ( struct ldb_context * ldb ) ;
2006-04-18 03:25:25 +04:00
/**
return a string explaining what a ldb error constant meancs
*/
const char * ldb_strerror ( int ldb_err ) ;
2006-02-04 03:38:48 +03:00
/**
setup the default utf8 functions
FIXME : these functions do not yet handle utf8
*/
void ldb_set_utf8_default ( struct ldb_context * ldb ) ;
2006-01-11 19:31:57 +03:00
/**
Casefold a string
2006-02-04 03:38:48 +03:00
\ param ldb the ldb context
2006-01-11 19:31:57 +03:00
\ param mem_ctx the memory context to allocate the result string
memory from .
\ param s the string that is to be folded
\ return a copy of the string , converted to upper case
2006-02-04 03:38:48 +03:00
\ note The default function is not yet UTF8 aware . Provide your own
set of functions through ldb_set_utf8_fns ( )
2004-05-01 13:45:56 +04:00
*/
2008-08-22 11:36:56 +04:00
char * ldb_casefold ( struct ldb_context * ldb , TALLOC_CTX * mem_ctx , const char * s , size_t n ) ;
2006-01-11 19:31:57 +03:00
2006-02-04 03:38:48 +03:00
/**
Check the attribute name is valid according to rfc2251
2007-12-10 12:29:32 +03:00
\ param s the string to check
2006-02-04 03:38:48 +03:00
\ return 1 if the name is ok
2006-01-11 19:31:57 +03:00
*/
2006-02-04 03:38:48 +03:00
int ldb_valid_attr_name ( const char * s ) ;
2004-05-01 13:45:56 +04:00
2004-03-31 10:45:39 +04:00
/*
ldif manipulation functions
*/
2008-03-02 12:46:47 +03:00
2006-01-11 19:31:57 +03:00
/**
Write an LDIF message
This function writes an LDIF message using a caller supplied write
function .
\ param ldb the ldb context ( from ldb_init ( ) )
\ param fprintf_fn a function pointer for the write function . This must take
a private data pointer , followed by a format string , and then a variable argument
list .
\ param private_data pointer that will be provided back to the write
function . This is useful for maintaining state or context .
\ param ldif the message to write out
\ return the total number of bytes written , or an error code as returned
from the write function .
\ sa ldb_ldif_write_file for a more convenient way to write to a
file stream .
\ sa ldb_ldif_read for the reader equivalent to this function .
*/
2004-05-20 17:25:06 +04:00
int ldb_ldif_write ( struct ldb_context * ldb ,
2006-08-23 13:19:19 +04:00
int ( * fprintf_fn ) ( void * , const char * , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ,
2004-05-20 17:25:06 +04:00
void * private_data ,
const struct ldb_ldif * ldif ) ;
2006-01-11 19:31:57 +03:00
/**
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 ( ) .
\ param ldb the ldb context ( from ldb_init ( ) )
\ param msg the message to clean up and free
*/
void ldb_ldif_read_free ( struct ldb_context * ldb , struct ldb_ldif * msg ) ;
/**
Read an LDIF message
This function creates an LDIF message using a caller supplied read
function .
\ param ldb the ldb context ( from ldb_init ( ) )
\ param fgetc_fn a function pointer for the read function . This must
take a private data pointer , and must return a pointer to an
integer corresponding to the next byte read ( or EOF if there is no
more data to be read ) .
\ param private_data pointer that will be provided back to the read
function . This is udeful for maintaining state or context .
\ return the LDIF message that has been read in
\ note You must free the LDIF message when no longer required , using
ldb_ldif_read_free ( ) .
\ sa ldb_ldif_read_file for a more convenient way to read from a
file stream .
\ sa ldb_ldif_read_string for a more convenient way to read from a
string ( char array ) .
\ sa ldb_ldif_write for the writer equivalent to this function .
*/
2004-05-20 17:25:06 +04:00
struct ldb_ldif * ldb_ldif_read ( struct ldb_context * ldb ,
int ( * fgetc_fn ) ( void * ) , void * private_data ) ;
2006-01-11 19:31:57 +03:00
/**
Read an LDIF message from a file
This function reads the next LDIF message from the contents of a
file stream . If you want to get all of the LDIF messages , you will
need to repeatedly call this function , until it returns NULL .
\ param ldb the ldb context ( from ldb_init ( ) )
\ param f the file stream to read from ( typically from fdopen ( ) )
\ sa ldb_ldif_read_string for an equivalent function that will read
from a string ( char array ) .
\ sa ldb_ldif_write_file for the writer equivalent to this function .
*/
2004-05-20 17:25:06 +04:00
struct ldb_ldif * ldb_ldif_read_file ( struct ldb_context * ldb , FILE * f ) ;
2006-01-11 19:31:57 +03:00
/**
Read an LDIF message from a string
This function reads the next LDIF message from the contents of a char
array . If you want to get all of the LDIF messages , you will need
to repeatedly call this function , until it returns NULL .
\ param ldb the ldb context ( from ldb_init ( ) )
\ param s pointer to the char array to read from
\ sa ldb_ldif_read_file for an equivalent function that will read
from a file stream .
\ sa ldb_ldif_write for a more general ( arbitrary read function )
version of this function .
*/
2005-07-12 09:56:06 +04:00
struct ldb_ldif * ldb_ldif_read_string ( struct ldb_context * ldb , const char * * s ) ;
2006-01-11 19:31:57 +03:00
/**
Write an LDIF message to a file
\ param ldb the ldb context ( from ldb_init ( ) )
\ param f the file stream to write to ( typically from fdopen ( ) )
\ param msg the message to write out
\ return the total number of bytes written , or a negative error code
\ sa ldb_ldif_read_file for the reader equivalent to this function .
*/
2004-05-20 17:25:06 +04:00
int ldb_ldif_write_file ( struct ldb_context * ldb , FILE * f , const struct ldb_ldif * msg ) ;
2006-01-11 19:31:57 +03:00
/**
Base64 encode a buffer
\ param mem_ctx the memory context that the result is allocated
from .
\ param buf pointer to the array that is to be encoded
\ param len the number of elements in the array to be encoded
\ return pointer to an array containing the encoded data
\ note The caller is responsible for freeing the result
*/
2007-11-20 17:50:08 +03:00
char * ldb_base64_encode ( TALLOC_CTX * mem_ctx , const char * buf , int len ) ;
2006-01-11 19:31:57 +03:00
/**
Base64 decode a buffer
This function decodes a base64 encoded string in place .
\ param s the string to decode .
\ return the length of the returned ( decoded ) string .
\ note the string is null terminated , but the null terminator is not
included in the length .
*/
2005-06-19 05:31:27 +04:00
int ldb_base64_decode ( char * s ) ;
2006-01-11 19:31:57 +03:00
2005-08-18 19:02:01 +04:00
/* The following definitions come from lib/ldb/common/ldb_dn.c */
2005-08-18 20:27:09 +04:00
2008-12-16 10:19:07 +03:00
/**
Get the linear form of a DN ( without any extended components )
\ param dn The DN to linearize
*/
const char * ldb_dn_get_linearized ( struct ldb_dn * dn ) ;
/**
Allocate a copy of the linear form of a DN ( without any extended components ) onto the supplied memory context
\ param dn The DN to linearize
\ param mem_ctx TALLOC context to return result on
*/
char * ldb_dn_alloc_linearized ( TALLOC_CTX * mem_ctx , struct ldb_dn * dn ) ;
/**
Get the linear form of a DN ( with any extended components )
\ param mem_ctx TALLOC context to return result on
\ param dn The DN to linearize
\ param mode Style of extended DN to return ( 0 is HEX representation of binary form , 1 is a string form )
*/
char * ldb_dn_get_extended_linearized ( void * mem_ctx , struct ldb_dn * dn , int mode ) ;
const struct ldb_val * ldb_dn_get_extended_component ( struct ldb_dn * dn , const char * name ) ;
int ldb_dn_set_extended_component ( struct ldb_dn * dn , const char * name , const struct ldb_val * val ) ;
void ldb_dn_remove_extended_components ( struct ldb_dn * dn ) ;
bool ldb_dn_has_extended ( struct ldb_dn * dn ) ;
int ldb_dn_extended_add_syntax ( struct ldb_context * ldb ,
unsigned flags ,
const struct ldb_dn_extended_syntax * syntax ) ;
/**
Allocate a new DN from a string
\ param mem_ctx TALLOC context to return resulting ldb_dn structure on
\ param dn The new DN
\ note The DN will not be parsed at this time . Use ldb_dn_validate to tell if the DN is syntacticly correct
*/
2007-11-20 17:50:08 +03:00
struct ldb_dn * ldb_dn_new ( TALLOC_CTX * mem_ctx , struct ldb_context * ldb , const char * dn ) ;
2008-12-16 10:19:07 +03:00
/**
Allocate a new DN from a printf style format string and arguments
\ param mem_ctx TALLOC context to return resulting ldb_dn structure on
\ param new_fms 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 syntacticly correct
*/
2007-11-20 17:50:08 +03:00
struct ldb_dn * ldb_dn_new_fmt ( TALLOC_CTX * mem_ctx , struct ldb_context * ldb , const char * new_fmt , . . . ) PRINTF_ATTRIBUTE ( 3 , 4 ) ;
2008-12-16 10:19:07 +03:00
/**
Allocate a new DN from a struct ldb_val ( useful to avoid buffer overrun )
\ param mem_ctx TALLOC context to return resulting ldb_dn structure on
\ param dn The new DN
\ note The DN will not be parsed at this time . Use ldb_dn_validate to tell if the DN is syntacticly correct
*/
2008-08-21 13:24:58 +04:00
struct ldb_dn * ldb_dn_from_ldb_val ( void * mem_ctx , struct ldb_context * ldb , const struct ldb_val * strdn ) ;
2008-12-16 10:19:07 +03:00
/**
Determine if this DN is syntactically valid
\ param dn The DN to validate
*/
2006-11-22 03:59:34 +03:00
bool ldb_dn_validate ( struct ldb_dn * dn ) ;
2007-11-20 17:50:08 +03:00
char * ldb_dn_escape_value ( TALLOC_CTX * mem_ctx , struct ldb_val value ) ;
2006-11-22 03:59:34 +03:00
const char * ldb_dn_get_casefold ( struct ldb_dn * dn ) ;
2007-11-20 17:50:08 +03:00
char * ldb_dn_alloc_casefold ( TALLOC_CTX * mem_ctx , struct ldb_dn * dn ) ;
2006-11-22 03:59:34 +03:00
int ldb_dn_compare_base ( struct ldb_dn * base , struct ldb_dn * dn ) ;
int ldb_dn_compare ( struct ldb_dn * edn0 , struct ldb_dn * edn1 ) ;
bool ldb_dn_add_base ( struct ldb_dn * dn , struct ldb_dn * base ) ;
2006-12-22 20:26:09 +03:00
bool ldb_dn_add_base_fmt ( struct ldb_dn * dn , const char * base_fmt , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
2006-11-22 03:59:34 +03:00
bool ldb_dn_add_child ( struct ldb_dn * dn , struct ldb_dn * child ) ;
2006-12-22 20:26:09 +03:00
bool ldb_dn_add_child_fmt ( struct ldb_dn * dn , const char * child_fmt , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
2006-11-22 03:59:34 +03:00
bool ldb_dn_remove_base_components ( struct ldb_dn * dn , unsigned int num ) ;
bool ldb_dn_remove_child_components ( struct ldb_dn * dn , unsigned int num ) ;
2007-11-20 17:50:08 +03:00
struct ldb_dn * ldb_dn_copy ( TALLOC_CTX * mem_ctx , struct ldb_dn * dn ) ;
struct ldb_dn * ldb_dn_get_parent ( TALLOC_CTX * mem_ctx , struct ldb_dn * dn ) ;
char * ldb_dn_canonical_string ( TALLOC_CTX * mem_ctx , struct ldb_dn * dn ) ;
char * ldb_dn_canonical_ex_string ( TALLOC_CTX * mem_ctx , struct ldb_dn * dn ) ;
2006-11-22 03:59:34 +03:00
int ldb_dn_get_comp_num ( struct ldb_dn * dn ) ;
const char * ldb_dn_get_component_name ( struct ldb_dn * dn , unsigned int num ) ;
const struct ldb_val * ldb_dn_get_component_val ( struct ldb_dn * dn , unsigned int num ) ;
const char * ldb_dn_get_rdn_name ( struct ldb_dn * dn ) ;
const struct ldb_val * ldb_dn_get_rdn_val ( struct ldb_dn * dn ) ;
2006-11-02 02:31:26 +03:00
int ldb_dn_set_component ( struct ldb_dn * dn , int num , const char * name , const struct ldb_val val ) ;
2006-11-22 03:59:34 +03:00
bool ldb_dn_is_valid ( struct ldb_dn * dn ) ;
bool ldb_dn_is_special ( struct ldb_dn * dn ) ;
bool ldb_dn_check_special ( struct ldb_dn * dn , const char * check ) ;
bool ldb_dn_is_null ( struct ldb_dn * dn ) ;
2006-11-02 02:31:26 +03:00
2004-05-05 08:27:29 +04:00
2006-01-11 19:31:57 +03:00
/**
Compare two attributes
This function compares to attribute names . Note that this is a
case - insensitive comparison .
2008-03-02 12:46:47 +03:00
\ param a the first attribute name to compare
\ param b the second attribute name to compare
2006-01-11 19:31:57 +03:00
\ return 0 if the attribute names are the same , or only differ in
case ; non - zero if there are any differences
2006-11-26 07:39:17 +03:00
attribute names are restricted by rfc2251 so using
strcasecmp and toupper here is ok .
return 0 for match
2006-01-11 19:31:57 +03:00
*/
2006-11-26 07:39:17 +03:00
# define ldb_attr_cmp(a, b) strcasecmp(a, b)
2007-11-20 17:50:08 +03:00
char * ldb_attr_casefold ( TALLOC_CTX * mem_ctx , const char * s ) ;
2005-10-28 11:05:32 +04:00
int ldb_attr_dn ( const char * attr ) ;
2004-11-16 12:00:52 +03:00
2006-01-11 19:31:57 +03:00
/**
Create an empty message
\ param 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
*/
2007-11-20 17:50:08 +03:00
struct ldb_message * ldb_msg_new ( TALLOC_CTX * mem_ctx ) ;
2005-01-02 10:49:29 +03:00
2006-01-11 19:31:57 +03:00
/**
Find an element within an message
*/
2004-05-05 08:27:29 +04:00
struct ldb_message_element * ldb_msg_find_element ( const struct ldb_message * msg ,
const char * attr_name ) ;
2006-01-11 19:31:57 +03:00
/**
Compare two ldb_val values
\ param v1 first ldb_val structure to be tested
\ param v2 second ldb_val structure to be tested
\ return 1 for a match , 0 if there is any difference
*/
2004-05-05 08:27:29 +04:00
int ldb_val_equal_exact ( const struct ldb_val * v1 , const struct ldb_val * v2 ) ;
2006-01-11 19:31:57 +03:00
/**
find a value within an ldb_message_element
\ param el the element to search
\ param val the value to search for
\ note This search is case sensitive
*/
2004-05-05 08:27:29 +04:00
struct ldb_val * ldb_msg_find_val ( const struct ldb_message_element * el ,
struct ldb_val * val ) ;
2006-01-11 19:31:57 +03:00
/**
add a new empty element to a ldb_message
*/
2006-10-25 05:42:59 +04:00
int ldb_msg_add_empty ( struct ldb_message * msg ,
const char * attr_name ,
int flags ,
struct ldb_message_element * * return_el ) ;
2004-05-05 08:27:29 +04:00
2006-01-11 19:31:57 +03:00
/**
add a element to a ldb_message
*/
2005-10-12 10:10:23 +04:00
int ldb_msg_add ( struct ldb_message * msg ,
2004-05-05 08:27:29 +04:00
const struct ldb_message_element * el ,
int flags ) ;
2005-10-12 10:10:23 +04:00
int ldb_msg_add_value ( struct ldb_message * msg ,
2006-10-25 05:42:59 +04:00
const char * attr_name ,
const struct ldb_val * val ,
struct ldb_message_element * * return_el ) ;
2006-02-22 12:28:58 +03:00
int ldb_msg_add_steal_value ( struct ldb_message * msg ,
const char * attr_name ,
struct ldb_val * val ) ;
int ldb_msg_add_steal_string ( struct ldb_message * msg ,
const char * attr_name , char * str ) ;
2005-10-12 10:10:23 +04:00
int ldb_msg_add_string ( struct ldb_message * msg ,
2005-01-29 07:04:38 +03:00
const char * attr_name , const char * str ) ;
2005-10-12 10:10:23 +04:00
int ldb_msg_add_fmt ( struct ldb_message * msg ,
const char * attr_name , const char * fmt , . . . ) PRINTF_ATTRIBUTE ( 3 , 4 ) ;
2004-05-05 08:27:29 +04:00
2006-01-11 19:31:57 +03:00
/**
compare two message elements - return 0 on match
*/
2004-05-05 08:27:29 +04:00
int ldb_msg_element_compare ( struct ldb_message_element * el1 ,
struct ldb_message_element * el2 ) ;
2006-01-11 19:31:57 +03:00
/**
Find elements in a message .
This function finds elements and converts to a specific type , with
2004-05-05 08:27:29 +04:00
a give default value if not found . Assumes that elements are
2006-01-11 19:31:57 +03:00
single valued .
*/
2004-11-16 12:00:52 +03:00
const struct ldb_val * ldb_msg_find_ldb_val ( const struct ldb_message * msg , const char * attr_name ) ;
2006-08-13 12:00:36 +04:00
int ldb_msg_find_attr_as_int ( const struct ldb_message * msg ,
2004-11-16 12:00:52 +03:00
const char * attr_name ,
2006-08-13 12:00:36 +04:00
int default_value ) ;
unsigned int ldb_msg_find_attr_as_uint ( const struct ldb_message * msg ,
const char * attr_name ,
unsigned int default_value ) ;
int64_t ldb_msg_find_attr_as_int64 ( const struct ldb_message * msg ,
const char * attr_name ,
int64_t default_value ) ;
uint64_t ldb_msg_find_attr_as_uint64 ( const struct ldb_message * msg ,
const char * attr_name ,
uint64_t default_value ) ;
double ldb_msg_find_attr_as_double ( const struct ldb_message * msg ,
const char * attr_name ,
double default_value ) ;
2006-08-17 12:31:19 +04:00
int ldb_msg_find_attr_as_bool ( const struct ldb_message * msg ,
const char * attr_name ,
int default_value ) ;
2006-08-13 12:00:36 +04:00
const char * ldb_msg_find_attr_as_string ( const struct ldb_message * msg ,
const char * attr_name ,
const char * default_value ) ;
2006-11-22 03:59:34 +03:00
struct ldb_dn * ldb_msg_find_attr_as_dn ( struct ldb_context * ldb ,
2007-11-20 17:50:08 +03:00
TALLOC_CTX * mem_ctx ,
2006-08-13 12:00:36 +04:00
const struct ldb_message * msg ,
2006-11-22 03:59:34 +03:00
const char * attr_name ) ;
2006-08-12 19:20:06 +04:00
2004-12-31 06:51:42 +03:00
void ldb_msg_sort_elements ( struct ldb_message * msg ) ;
2007-11-20 17:50:08 +03:00
struct ldb_message * ldb_msg_copy_shallow ( TALLOC_CTX * mem_ctx ,
2005-10-12 11:54:15 +04:00
const struct ldb_message * msg ) ;
2007-11-20 17:50:08 +03:00
struct ldb_message * ldb_msg_copy ( TALLOC_CTX * mem_ctx ,
2004-12-31 06:51:42 +03:00
const struct ldb_message * msg ) ;
struct ldb_message * ldb_msg_canonicalize ( struct ldb_context * ldb ,
const struct ldb_message * msg ) ;
2005-05-17 02:31:45 +04:00
struct ldb_message * ldb_msg_diff ( struct ldb_context * ldb ,
struct ldb_message * msg1 ,
struct ldb_message * msg2 ) ;
2006-05-14 01:08:37 +04:00
int ldb_msg_check_string_attribute ( const struct ldb_message * msg ,
const char * name ,
const char * value ) ;
2006-01-11 19:31:57 +03:00
/**
Integrity check an ldb_message
This function performs basic sanity / integrity checks on an
ldb_message .
2008-03-02 12:46:47 +03:00
\ param ldb context in which to perform the checks
2006-01-11 19:31:57 +03:00
\ param msg the message to check
\ return 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 .
*/
2006-07-06 09:08:30 +04:00
int ldb_msg_sanity_check ( struct ldb_context * ldb ,
const struct ldb_message * msg ) ;
2005-09-18 14:47:03 +04:00
2006-01-11 19:31:57 +03:00
/**
Duplicate an ldb_val structure
This function copies an ldb value structure .
\ param mem_ctx the memory context that the duplicated value will be
allocated from
\ param v the ldb_val to be duplicated .
\ return the duplicated ldb_val structure .
*/
2007-11-20 17:50:08 +03:00
struct ldb_val ldb_val_dup ( TALLOC_CTX * mem_ctx , const struct ldb_val * v ) ;
2004-11-16 12:00:52 +03:00
2006-01-11 19:31:57 +03:00
/**
2004-05-06 13:55:05 +04:00
this allows the user to set a debug function for error reporting
*/
int ldb_set_debug ( struct ldb_context * ldb ,
void ( * debug ) ( void * context , enum ldb_debug_level level ,
2006-08-23 13:19:19 +04:00
const char * fmt , va_list ap ) PRINTF_ATTRIBUTE ( 3 , 0 ) ,
2004-05-06 13:55:05 +04:00
void * context ) ;
2006-02-04 04:27:47 +03:00
/**
this allows the user to set custom utf8 function for error reporting
*/
void ldb_set_utf8_fns ( struct ldb_context * ldb ,
2008-08-22 11:36:56 +04:00
void * context ,
char * ( * casefold ) ( void * , void * , const char * , size_t n ) ) ;
2006-02-04 04:27:47 +03:00
2006-01-11 19:31:57 +03:00
/**
this sets up debug to print messages on stderr
*/
2004-05-06 13:55:05 +04:00
int ldb_set_debug_stderr ( struct ldb_context * ldb ) ;
2005-06-20 08:56:43 +04:00
/* control backend specific opaque values */
int ldb_set_opaque ( struct ldb_context * ldb , const char * name , void * value ) ;
void * ldb_get_opaque ( struct ldb_context * ldb , const char * name ) ;
2007-11-20 17:50:08 +03:00
const char * * ldb_attr_list_copy ( TALLOC_CTX * mem_ctx , const char * const * attrs ) ;
const char * * ldb_attr_list_copy_add ( TALLOC_CTX * mem_ctx , const char * const * attrs , const char * new_attr ) ;
2005-10-12 10:10:23 +04:00
int ldb_attr_in_list ( const char * const * attrs , const char * attr ) ;
void ldb_parse_tree_attr_replace ( struct ldb_parse_tree * tree ,
const char * attr ,
const char * replace ) ;
2005-10-12 12:11:45 +04:00
int ldb_msg_rename_attr ( struct ldb_message * msg , const char * attr , const char * replace ) ;
2005-10-12 10:10:23 +04:00
int ldb_msg_copy_attr ( struct ldb_message * msg , const char * attr , const char * replace ) ;
2005-10-13 09:04:16 +04:00
void ldb_msg_remove_attr ( struct ldb_message * msg , const char * attr ) ;
2005-10-12 10:10:23 +04:00
2006-01-11 19:31:57 +03:00
/**
Convert a time structure to a string
2007-01-02 13:59:38 +03:00
This function converts a time_t structure to an LDAP formatted
GeneralizedTime string .
2006-01-11 19:31:57 +03:00
\ param mem_ctx the memory context to allocate the return string in
\ param t the time structure to convert
\ return the formatted string , or NULL if the time structure could
not be converted
*/
2007-11-20 17:50:08 +03:00
char * ldb_timestring ( TALLOC_CTX * mem_ctx , time_t t ) ;
2006-01-11 19:31:57 +03:00
/**
Convert a string to a time structure
2007-01-02 13:59:38 +03:00
This function converts an LDAP formatted GeneralizedTime string
to a time_t structure .
2006-01-11 19:31:57 +03:00
\ param s the string to convert
\ return the time structure , or 0 if the string cannot be converted
*/
2005-10-12 10:30:47 +04:00
time_t ldb_string_to_time ( const char * s ) ;
2007-01-02 13:59:38 +03:00
/**
Convert a time structure to a string
This function converts a time_t structure to an LDAP formatted
UTCTime string .
\ param mem_ctx the memory context to allocate the return string in
\ param t the time structure to convert
\ return the formatted string , or NULL if the time structure could
not be converted
*/
2007-11-20 17:50:08 +03:00
char * ldb_timestring_utc ( TALLOC_CTX * mem_ctx , time_t t ) ;
2007-01-02 13:59:38 +03:00
/**
Convert a string to a time structure
This function converts an LDAP formatted UTCTime string
to a time_t structure .
\ param s the string to convert
\ return the time structure , or 0 if the string cannot be converted
*/
time_t ldb_string_utc_to_time ( const char * s ) ;
2006-01-06 07:01:23 +03:00
void ldb_qsort ( void * const pbase , size_t total_elems , size_t size , void * opaque , ldb_qsort_cmp_fn_t cmp ) ;
2007-02-22 04:54:40 +03:00
/**
Convert an array of string represention of a control into an array of ldb_control structures
\ param ldb LDB context
\ param mem_ctx TALLOC context to return result on , and to allocate error_string on
\ param control_strings Array of string - formatted controls
\ return array of ldb_control elements
*/
2007-11-20 17:50:08 +03:00
struct ldb_control * * ldb_parse_control_strings ( struct ldb_context * ldb , TALLOC_CTX * mem_ctx , const char * * control_strings ) ;
2007-02-22 04:54:40 +03:00
2004-05-06 08:40:15 +04:00
# endif