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 database library
Copyright ( C ) Andrew Tridgell 2004 - 2005
2005-07-17 18:15:45 +04:00
Copyright ( C ) Simo Sorce 2005
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
* * 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 .
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
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/>.
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
*/
/*
* Name : ldb
*
* Component : ldb expression matching
*
* Description : ldb expression matching
*
* Author : Andrew Tridgell
*/
2009-01-30 02:39:30 +03:00
# include "ldb_private.h"
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
/*
check if the scope matches in a search result
*/
2005-07-12 16:04:54 +04:00
static int ldb_match_scope ( struct ldb_context * ldb ,
2006-11-22 03:59:34 +03:00
struct ldb_dn * base ,
struct ldb_dn * dn ,
2005-07-12 16:04:54 +04:00
enum ldb_scope scope )
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
{
2005-07-12 16:04:54 +04:00
int ret = 0 ;
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
2005-08-18 19:02:01 +04:00
if ( base = = NULL | | dn = = NULL ) {
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
return 1 ;
}
switch ( scope ) {
case LDB_SCOPE_BASE :
2006-11-22 03:59:34 +03:00
if ( ldb_dn_compare ( base , dn ) = = 0 ) {
2005-07-12 16:04:54 +04:00
ret = 1 ;
}
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
break ;
case LDB_SCOPE_ONELEVEL :
2006-11-02 02:31:26 +03:00
if ( ldb_dn_get_comp_num ( dn ) = = ( ldb_dn_get_comp_num ( base ) + 1 ) ) {
2006-11-22 03:59:34 +03:00
if ( ldb_dn_compare_base ( base , dn ) = = 0 ) {
2005-07-12 16:04:54 +04:00
ret = 1 ;
}
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
}
break ;
case LDB_SCOPE_SUBTREE :
default :
2006-11-22 03:59:34 +03:00
if ( ldb_dn_compare_base ( base , dn ) = = 0 ) {
2005-07-12 16:04:54 +04:00
ret = 1 ;
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
}
break ;
}
2005-07-12 16:04:54 +04:00
return ret ;
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
}
/*
2005-07-12 16:04:54 +04:00
match if node is present
*/
static int ldb_match_present ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2010-10-13 13:48:27 +04:00
enum ldb_scope scope , bool * matched )
2005-07-12 16:04:54 +04:00
{
2010-10-13 13:48:27 +04:00
const struct ldb_schema_attribute * a ;
struct ldb_message_element * el ;
2005-10-28 11:05:32 +04:00
if ( ldb_attr_dn ( tree - > u . present . attr ) = = 0 ) {
2010-10-13 13:48:27 +04:00
* matched = true ;
return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
}
2010-10-13 13:48:27 +04:00
el = ldb_msg_find_element ( msg , tree - > u . present . attr ) ;
if ( el = = NULL ) {
* matched = false ;
return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
}
2010-10-13 13:48:27 +04:00
a = ldb_schema_attribute_by_name ( ldb , el - > name ) ;
if ( ! a ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
if ( a - > syntax - > operator_fn ) {
2010-10-13 16:03:09 +04:00
unsigned int i ;
2010-10-13 13:48:27 +04:00
for ( i = 0 ; i < el - > num_values ; i + + ) {
int ret = a - > syntax - > operator_fn ( ldb , LDB_OP_PRESENT , a , & el - > values [ i ] , NULL , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( * matched ) return LDB_SUCCESS ;
}
* matched = false ;
return LDB_SUCCESS ;
}
* matched = true ;
return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
}
2005-07-19 13:09:00 +04:00
static int ldb_match_comparison ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2005-07-19 13:09:00 +04:00
enum ldb_scope scope ,
2010-10-13 13:48:27 +04:00
enum ldb_parse_op comp_op , bool * matched )
2005-07-19 13:09:00 +04:00
{
unsigned int i ;
struct ldb_message_element * el ;
2006-12-15 16:08:57 +03:00
const struct ldb_schema_attribute * a ;
2005-07-19 13:09:00 +04:00
/* FIXME: APPROX comparison not handled yet */
2010-10-13 13:48:27 +04:00
if ( comp_op = = LDB_OP_APPROX ) {
return LDB_ERR_INAPPROPRIATE_MATCHING ;
}
2005-07-19 13:09:00 +04:00
el = ldb_msg_find_element ( msg , tree - > u . comparison . attr ) ;
if ( el = = NULL ) {
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
2005-07-19 13:09:00 +04:00
}
2006-12-15 16:08:57 +03:00
a = ldb_schema_attribute_by_name ( ldb , el - > name ) ;
2010-10-13 13:48:27 +04:00
if ( ! a ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
2005-07-19 13:09:00 +04:00
for ( i = 0 ; i < el - > num_values ; i + + ) {
2010-10-13 13:48:27 +04:00
if ( a - > syntax - > operator_fn ) {
int ret ;
ret = a - > syntax - > operator_fn ( ldb , comp_op , a , & el - > values [ i ] , & tree - > u . comparison . value , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( * matched ) return LDB_SUCCESS ;
} else {
int ret = a - > syntax - > comparison_fn ( ldb , ldb , & el - > values [ i ] , & tree - > u . comparison . value ) ;
if ( ret = = 0 ) {
* matched = true ;
return LDB_SUCCESS ;
}
if ( ret > 0 & & comp_op = = LDB_OP_GREATER ) {
* matched = true ;
return LDB_SUCCESS ;
}
if ( ret < 0 & & comp_op = = LDB_OP_LESS ) {
* matched = true ;
return LDB_SUCCESS ;
}
2005-07-19 13:09:00 +04:00
}
}
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
2005-07-19 13:09:00 +04:00
}
2005-07-12 16:04:54 +04:00
/*
match a simple leaf node
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
*/
2005-07-19 13:09:00 +04:00
static int ldb_match_equality ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2010-10-13 13:48:27 +04:00
enum ldb_scope scope ,
bool * matched )
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
{
unsigned int i ;
struct ldb_message_element * el ;
2006-12-15 16:08:57 +03:00
const struct ldb_schema_attribute * a ;
2005-08-18 19:02:01 +04:00
struct ldb_dn * valuedn ;
2005-07-12 16:04:54 +04:00
int ret ;
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
2005-10-28 11:05:32 +04:00
if ( ldb_attr_dn ( tree - > u . equality . attr ) = = 0 ) {
2008-10-27 05:32:23 +03:00
valuedn = ldb_dn_from_ldb_val ( ldb , ldb , & tree - > u . equality . value ) ;
2005-07-12 16:04:54 +04:00
if ( valuedn = = NULL ) {
2010-10-13 13:48:27 +04:00
return LDB_ERR_INVALID_DN_SYNTAX ;
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
}
2005-07-12 16:04:54 +04:00
2006-11-22 03:59:34 +03:00
ret = ldb_dn_compare ( msg - > dn , valuedn ) ;
2005-07-12 16:04:54 +04:00
talloc_free ( valuedn ) ;
2010-10-13 13:48:27 +04:00
* matched = ( ret = = 0 ) ;
return LDB_SUCCESS ;
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
}
2005-08-02 18:04:22 +04:00
/* TODO: handle the "*" case derived from an extended search
operation without the attibute type defined */
2005-07-19 13:09:00 +04:00
el = ldb_msg_find_element ( msg , tree - > u . equality . attr ) ;
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
if ( el = = NULL ) {
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
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-12-15 16:08:57 +03:00
a = ldb_schema_attribute_by_name ( ldb , el - > name ) ;
2010-10-13 13:48:27 +04:00
if ( a = = NULL ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
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
for ( i = 0 ; i < el - > num_values ; i + + ) {
2010-10-13 13:48:27 +04:00
if ( a - > syntax - > operator_fn ) {
ret = a - > syntax - > operator_fn ( ldb , LDB_OP_EQUALITY , a ,
& tree - > u . equality . value , & el - > values [ i ] , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( * matched ) return LDB_SUCCESS ;
} else {
if ( a - > syntax - > comparison_fn ( ldb , ldb , & tree - > u . equality . value ,
& el - > values [ i ] ) = = 0 ) {
* matched = true ;
return LDB_SUCCESS ;
}
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
}
}
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
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
}
2005-07-12 16:04:54 +04:00
static int ldb_wildcard_compare ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_parse_tree * tree ,
2010-10-13 13:48:27 +04:00
const struct ldb_val value , bool * matched )
2005-07-12 16:04:54 +04:00
{
2006-12-15 16:08:57 +03:00
const struct ldb_schema_attribute * a ;
2005-07-12 16:04:54 +04:00
struct ldb_val val ;
struct ldb_val cnk ;
struct ldb_val * chunk ;
char * p , * g ;
2005-10-12 10:10:23 +04:00
uint8_t * save_p = NULL ;
2009-11-06 20:35:17 +03:00
unsigned int c = 0 ;
2005-07-12 16:04:54 +04:00
2006-12-15 16:08:57 +03:00
a = ldb_schema_attribute_by_name ( ldb , tree - > u . substring . attr ) ;
2010-10-13 13:48:27 +04:00
if ( ! a ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
2005-07-12 16:04:54 +04:00
2010-10-13 13:48:27 +04:00
if ( a - > syntax - > canonicalise_fn ( ldb , ldb , & value , & val ) ! = 0 ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
2005-07-12 16:04:54 +04:00
save_p = val . data ;
cnk . data = NULL ;
if ( ! tree - > u . substring . start_with_wildcard ) {
chunk = tree - > u . substring . chunks [ c ] ;
2010-10-13 13:48:27 +04:00
if ( a - > syntax - > canonicalise_fn ( ldb , ldb , chunk , & cnk ) ! = 0 ) goto mismatch ;
2005-07-12 16:04:54 +04:00
2006-06-07 02:04:55 +04:00
/* This deals with wildcard prefix searches on binary attributes (eg objectGUID) */
if ( cnk . length > val . length ) {
2010-10-13 13:48:27 +04:00
goto mismatch ;
2006-06-07 02:04:55 +04:00
}
2010-10-13 13:48:27 +04:00
if ( memcmp ( ( char * ) val . data , ( char * ) cnk . data , cnk . length ) ! = 0 ) goto mismatch ;
2005-07-12 16:04:54 +04:00
val . length - = cnk . length ;
val . data + = cnk . length ;
c + + ;
talloc_free ( cnk . data ) ;
cnk . data = NULL ;
}
while ( tree - > u . substring . chunks [ c ] ) {
chunk = tree - > u . substring . chunks [ c ] ;
2010-10-13 13:48:27 +04:00
if ( a - > syntax - > canonicalise_fn ( ldb , ldb , chunk , & cnk ) ! = 0 ) goto mismatch ;
2005-07-12 16:04:54 +04:00
/* FIXME: case of embedded nulls */
2005-10-12 10:10:23 +04:00
p = strstr ( ( char * ) val . data , ( char * ) cnk . data ) ;
2010-10-13 13:48:27 +04:00
if ( p = = NULL ) goto mismatch ;
2005-07-12 16:04:54 +04:00
if ( ( ! tree - > u . substring . chunks [ c + 1 ] ) & & ( ! tree - > u . substring . end_with_wildcard ) ) {
do { /* greedy */
2005-10-12 10:10:23 +04:00
g = strstr ( ( char * ) p + cnk . length , ( char * ) cnk . data ) ;
2005-07-12 16:04:54 +04:00
if ( g ) p = g ;
} while ( g ) ;
}
val . length = val . length - ( p - ( char * ) ( val . data ) ) - cnk . length ;
2005-10-12 10:10:23 +04:00
val . data = ( uint8_t * ) ( p + cnk . length ) ;
2005-07-12 16:04:54 +04:00
c + + ;
talloc_free ( cnk . data ) ;
cnk . data = NULL ;
}
2010-10-13 13:48:27 +04:00
/* last chunk may not have reached end of string */
if ( ( ! tree - > u . substring . end_with_wildcard ) & & ( * ( val . data ) ! = 0 ) ) goto mismatch ;
2005-07-12 16:04:54 +04:00
talloc_free ( save_p ) ;
2010-10-13 13:48:27 +04:00
* matched = true ;
return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
2010-10-13 13:48:27 +04:00
mismatch :
* matched = false ;
2005-07-12 16:04:54 +04:00
talloc_free ( save_p ) ;
talloc_free ( cnk . data ) ;
2010-10-13 13:48:27 +04:00
return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
}
/*
match a simple leaf node
*/
static int ldb_match_substring ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2010-10-13 13:48:27 +04:00
enum ldb_scope scope , bool * matched )
2005-07-12 16:04:54 +04:00
{
unsigned int i ;
struct ldb_message_element * el ;
2005-07-19 13:09:00 +04:00
el = ldb_msg_find_element ( msg , tree - > u . substring . attr ) ;
2005-07-12 16:04:54 +04:00
if ( el = = NULL ) {
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
}
for ( i = 0 ; i < el - > num_values ; i + + ) {
2010-10-13 13:48:27 +04:00
int ret ;
ret = ldb_wildcard_compare ( ldb , tree , el - > values [ i ] , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( * matched ) return LDB_SUCCESS ;
2005-07-12 16:04:54 +04:00
}
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
2005-07-12 16:04:54 +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
/*
bitwise - and comparator
*/
2010-10-13 13:48:27 +04:00
static int ldb_comparator_bitmask ( const char * oid , const struct ldb_val * v1 , const struct ldb_val * v2 ,
bool * matched )
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
{
uint64_t i1 , i2 ;
2010-10-13 13:48:27 +04:00
char ibuf [ 100 ] ;
char * endptr = NULL ;
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
2010-10-13 13:48:27 +04:00
if ( v1 - > length > = sizeof ( ibuf ) - 1 ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
memcpy ( ibuf , ( char * ) v1 - > data , v1 - > length ) ;
ibuf [ v1 - > length ] = 0 ;
i1 = strtoull ( ibuf , & endptr , 0 ) ;
if ( endptr ! = NULL ) {
if ( endptr = = ibuf | | * endptr ! = 0 ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
}
if ( v2 - > length > = sizeof ( ibuf ) - 1 ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
endptr = NULL ;
memcpy ( ibuf , ( char * ) v2 - > data , v2 - > length ) ;
ibuf [ v2 - > length ] = 0 ;
i2 = strtoull ( ibuf , & endptr , 0 ) ;
if ( endptr ! = NULL ) {
if ( endptr = = ibuf | | * endptr ! = 0 ) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX ;
}
}
if ( strcmp ( LDB_OID_COMPARATOR_AND , oid ) = = 0 ) {
* matched = ( ( i1 & i2 ) = = i2 ) ;
} else if ( strcmp ( LDB_OID_COMPARATOR_OR , oid ) = = 0 ) {
* matched = ( ( i1 & i2 ) ! = 0 ) ;
} else {
return LDB_ERR_INAPPROPRIATE_MATCHING ;
}
return LDB_SUCCESS ;
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
}
/*
extended match , handles things like bitops
*/
static int ldb_match_extended ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2010-10-13 13:48:27 +04:00
enum ldb_scope scope , bool * matched )
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
{
2009-11-06 20:35:17 +03:00
unsigned int i ;
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
const struct {
const char * oid ;
2010-10-13 13:48:27 +04:00
int ( * comparator ) ( const char * , const struct ldb_val * , const struct ldb_val * , bool * ) ;
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
} rules [ ] = {
2010-10-13 13:48:27 +04:00
{ LDB_OID_COMPARATOR_AND , ldb_comparator_bitmask } ,
{ LDB_OID_COMPARATOR_OR , ldb_comparator_bitmask }
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
} ;
2010-10-13 13:48:27 +04:00
int ( * comp ) ( const char * , const struct ldb_val * , const struct ldb_val * , bool * ) = NULL ;
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
struct ldb_message_element * el ;
if ( tree - > u . extended . dnAttributes ) {
2010-02-11 17:42:48 +03:00
/* FIXME: We really need to find out what this ":dn" part in
* an extended match means and how to handle it . For now print
* only a warning to have s3 winbind and other tools working
* against us . - Matthias */
ldb_debug ( ldb , LDB_DEBUG_WARNING , " ldb: dnAttributes extended match not supported yet " ) ;
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
}
if ( tree - > u . extended . rule_id = = NULL ) {
ldb_debug ( ldb , LDB_DEBUG_ERROR , " ldb: no-rule extended matches not supported yet " ) ;
2010-10-13 13:48:27 +04:00
return LDB_ERR_INAPPROPRIATE_MATCHING ;
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
}
if ( tree - > u . extended . attr = = NULL ) {
ldb_debug ( ldb , LDB_DEBUG_ERROR , " ldb: no-attribute extended matches not supported yet " ) ;
2010-10-13 13:48:27 +04:00
return LDB_ERR_INAPPROPRIATE_MATCHING ;
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
}
for ( i = 0 ; i < ARRAY_SIZE ( rules ) ; i + + ) {
if ( strcmp ( rules [ i ] . oid , tree - > u . extended . rule_id ) = = 0 ) {
comp = rules [ i ] . comparator ;
break ;
}
}
if ( comp = = NULL ) {
2009-07-11 00:44:27 +04:00
ldb_debug ( ldb , LDB_DEBUG_ERROR , " ldb: unknown extended rule_id %s " ,
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
tree - > u . extended . rule_id ) ;
2010-10-13 13:48:27 +04:00
return LDB_ERR_INAPPROPRIATE_MATCHING ;
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
}
/* find the message element */
el = ldb_msg_find_element ( msg , tree - > u . extended . attr ) ;
if ( el = = NULL ) {
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
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
}
for ( i = 0 ; i < el - > num_values ; i + + ) {
2010-10-13 13:48:27 +04:00
int ret = comp ( tree - > u . extended . rule_id , & el - > values [ i ] , & tree - > u . extended . value , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( * matched ) return LDB_SUCCESS ;
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
}
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
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
}
/*
return 0 if the given parse tree matches the given message . Assumes
the message is in sorted order
return 1 if it matches , and 0 if it doesn ' t match
this is a recursive function , and does short - circuit evaluation
*/
2005-07-12 16:04:54 +04:00
static int ldb_match_message ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2010-10-13 13:48:27 +04:00
enum ldb_scope scope , bool * matched )
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
{
unsigned int i ;
2010-10-13 13:48:27 +04:00
int ret ;
* matched = false ;
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
2011-07-13 06:25:09 +04:00
if ( scope ! = LDB_SCOPE_BASE & & ldb_dn_is_special ( msg - > dn ) ) {
/* don't match special records except on base searches */
return LDB_SUCCESS ;
}
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
switch ( tree - > operation ) {
case LDB_OP_AND :
for ( i = 0 ; i < tree - > u . list . num_elements ; i + + ) {
2010-10-13 13:48:27 +04:00
ret = ldb_match_message ( ldb , msg , tree - > u . list . elements [ i ] , scope , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( ! * matched ) return LDB_SUCCESS ;
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
}
2010-10-13 13:48:27 +04:00
* matched = true ;
return LDB_SUCCESS ;
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
case LDB_OP_OR :
for ( i = 0 ; i < tree - > u . list . num_elements ; i + + ) {
2010-10-13 13:48:27 +04:00
ret = ldb_match_message ( ldb , msg , tree - > u . list . elements [ i ] , scope , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
if ( * matched ) return LDB_SUCCESS ;
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
}
2010-10-13 13:48:27 +04:00
* matched = false ;
return LDB_SUCCESS ;
2005-07-19 13:09:00 +04:00
case LDB_OP_NOT :
2010-10-13 13:48:27 +04:00
ret = ldb_match_message ( ldb , msg , tree - > u . isnot . child , scope , matched ) ;
if ( ret ! = LDB_SUCCESS ) return ret ;
* matched = ! * matched ;
return LDB_SUCCESS ;
2005-07-19 13:09:00 +04:00
case LDB_OP_EQUALITY :
2010-10-13 13:48:27 +04:00
return ldb_match_equality ( ldb , msg , tree , scope , matched ) ;
2005-07-19 13:09:00 +04:00
case LDB_OP_SUBSTRING :
2010-10-13 13:48:27 +04:00
return ldb_match_substring ( ldb , msg , tree , scope , matched ) ;
2005-07-19 13:09:00 +04:00
case LDB_OP_GREATER :
2010-10-13 13:48:27 +04:00
return ldb_match_comparison ( ldb , msg , tree , scope , LDB_OP_GREATER , matched ) ;
2005-07-19 13:09:00 +04:00
case LDB_OP_LESS :
2010-10-13 13:48:27 +04:00
return ldb_match_comparison ( ldb , msg , tree , scope , LDB_OP_LESS , matched ) ;
2005-07-19 13:09:00 +04:00
case LDB_OP_PRESENT :
2010-10-13 13:48:27 +04:00
return ldb_match_present ( ldb , msg , tree , scope , matched ) ;
2005-07-19 13:09:00 +04:00
case LDB_OP_APPROX :
2010-10-13 13:48:27 +04:00
return ldb_match_comparison ( ldb , msg , tree , scope , LDB_OP_APPROX , matched ) ;
2005-07-19 13:09:00 +04:00
case LDB_OP_EXTENDED :
2010-10-13 13:48:27 +04:00
return ldb_match_extended ( ldb , msg , tree , scope , matched ) ;
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
}
2010-10-13 13:48:27 +04:00
return LDB_ERR_INAPPROPRIATE_MATCHING ;
2005-07-12 16:04:54 +04:00
}
int ldb_match_msg ( struct ldb_context * ldb ,
2006-08-02 02:46:49 +04:00
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
2006-11-22 03:59:34 +03:00
struct ldb_dn * base ,
2005-07-12 16:04:54 +04:00
enum ldb_scope scope )
{
2010-10-13 13:48:27 +04:00
bool matched ;
int ret ;
2005-07-12 16:04:54 +04:00
if ( ! ldb_match_scope ( ldb , base , msg - > dn , scope ) ) {
return 0 ;
}
2010-10-13 13:48:27 +04:00
ret = ldb_match_message ( ldb , msg , tree , scope , & matched ) ;
if ( ret ! = LDB_SUCCESS ) {
/* to match the old API, we need to consider this a
failure to match */
return 0 ;
}
return matched ? 1 : 0 ;
}
int ldb_match_msg_error ( struct ldb_context * ldb ,
const struct ldb_message * msg ,
const struct ldb_parse_tree * tree ,
struct ldb_dn * base ,
enum ldb_scope scope ,
bool * matched )
{
if ( ! ldb_match_scope ( ldb , base , msg - > dn , scope ) ) {
* matched = false ;
return LDB_SUCCESS ;
}
return ldb_match_message ( ldb , msg , tree , scope , matched ) ;
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
}
2009-12-07 07:27:43 +03:00
int ldb_match_msg_objectclass ( const struct ldb_message * msg ,
const char * objectclass )
{
2010-09-19 15:00:38 +04:00
unsigned int i ;
2009-12-07 07:27:43 +03:00
struct ldb_message_element * el = ldb_msg_find_element ( msg , " objectClass " ) ;
if ( ! el ) {
return 0 ;
}
for ( i = 0 ; i < el - > num_values ; i + + ) {
if ( ldb_attr_cmp ( ( const char * ) el - > values [ i ] . data , objectclass ) = = 0 ) {
return 1 ;
}
}
return 0 ;
}