1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-07 17:18:11 +03:00
Commit Graph

506 Commits

Author SHA1 Message Date
Matthieu Patou
2f3adc001e s4-schema: improve the documentation of the dsdb_schema structure 2012-06-22 23:42:08 -07:00
Matthieu Patou
718ed842ba s4-dsdb: Check for key SCHEMA_SEQ_NUM in metadata.tdb updates
If the value has changed then reload the schema, this means that now the
schema is only reloaded on a periodical basis or if we have been asked
explicitly to do it and not necesserly if the schema partition has
changed.
2012-06-22 23:42:08 -07:00
Matthieu Patou
9374ee1ba1 s4-schema: keep track of the timestamp of the most recently changed/created object 2012-06-22 23:22:03 -07:00
Matthieu Patou
2d20a918db s4-schema: generalized time use its own syntax now 2012-06-22 23:22:03 -07:00
Matthieu Patou
1521bb95a7 dsdb-schema: do not reload more often than schema_reload_interval
Samba 4 use to try to reload the schema every time dsdb_get_schema was
called (which could be 20+ time per ldb request). Now we only reload at
most every xx seconds (xx being the value of dsdb:"schema_reload_interval"
 or 120). The timestamp of the last reloaded schema is kept in the
 dsdb_schema object. There is also a timestamp in the ldb_context, that
 is used by the LDAP server to know if it has to reload the schema after
 handling the request. This is used to allow that the schema will be
 immediately reload after a schemaUpdateNow request has been issued, the
 reload can't occur in the handling of the LDAP request itself because
 we have a transaction autostarted.
2012-06-22 23:16:04 -07:00
Matthieu Patou
b019248fe8 Add some debug for FOOBAR return case as they are hard to diagnose
Autobuild-User: Matthieu Patou <mat@samba.org>
Autobuild-Date: Sun Apr 29 09:08:15 CEST 2012 on sn-devel-104
2012-04-29 09:08:15 +02:00
Matthieu Patou
167c6eb61e s4-schema: rename dsdb_attribute_from_ldb to dsdb_set_attribute_from_ldb and dsdb_class_from_ldb to dsdb_set_class_from_ldb 2012-04-18 00:06:59 +02:00
Matthias Dieter Wallnöfer
4eb0d42291 s4:dsdb - move "objectclass_sort()" out from the objectclass LDB module into the schema code
This allows it to be useful for the dbchecker utility in respect to
object class problems.
Fix up the API to only work with standardised LDB "ldb_message_element"
structures which do allow much easier interoperations. As a consequence this
leads to some changes in the objectclass module as well.
2012-04-11 12:50:16 +10:00
Matthias Dieter Wallnöfer
3d886e3e15 s4:schema/schema_query.c - fix a comment 2012-04-11 12:50:16 +10:00
Matthias Dieter Wallnöfer
35dfd79dca s4:schema/schema_init.c - better use "ldb_attr_cmp" instead of "strcasecmp"
LDB convention
2012-04-11 12:50:16 +10:00
Stefan Metzmacher
e7e9f1e2dd s4:dsdb/schema: add "dsdb:schema update allowed" option to enable schema updates
By default schema updates are not allowed anymore, as we don't have
complete validation code to prevent database corruption.

metze
2011-11-15 09:46:30 +01:00
Stefan Metzmacher
28d573168c s4:param/provision: pass schema_dn to provision_get_schema()
metze
2011-11-15 09:46:27 +01:00
Stefan Metzmacher
75ae19422b s4:dsdb/schema: pass and remember the schema_dn in dsdb_set_schema_from_ldif()
metze
2011-11-15 09:46:27 +01:00
Gregor Beck
85b145d745 s3:utils change data_blob_dup_talloc() to take a DATA_BLOB by value
Signed-off-by: Michael Adam <obnox@samba.org>
2011-10-12 22:45:53 +02:00
Andrew Tridgell
a729dbb269 s4-dsdb: fixed one_way_link calculation
we need to check for the other end of the link, not the current linkID

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-10-07 13:20:44 +11:00
Andrew Bartlett
1afeb4e391 s4-schema consolidate schema handling
It also creates a single routine dsdb_load_ldb_results_into_schema()
to handle cases where the schema is in the form of an ldb_result.

Andrew Bartlett
2011-09-05 11:19:25 +02:00
Andrew Tridgell
27656e9123 s4-dsdb: fixed calls to ldb_val_string_cmp()
wrong order of arguments
2011-08-25 07:39:38 +10:00
Andrew Bartlett
b206a365ea move schema_fill_constructed() call to dsdb_setup_sorted_accessors() 2011-08-09 11:56:23 +02:00
Andrew Bartlett
dee678a7be s4-dsdb Remove unused schema function 2011-08-09 11:56:23 +02:00
Andrew Tridgell
0e9cf380ea s4-dsdb: added SAMDB_INDEXING_VERSION to @INDEXLIST
this can be used to force re-indexing of samdb when we change
something that affects index comparison, in this case the
canonicalisation of booleans

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-08-09 11:56:23 +02:00
Andrew Tridgell
6853b3a805 s4-dsdb: fixed booling conversion to check value length
this ensures we don't look past the end of the data

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-08-09 11:56:23 +02:00
Andrew Tridgell
4ede333f46 s4-dsdb: add auto-normalisation of attributes
this auto-normalises some attributes when they are added/modified. The
list that we auto-normalise is currently:

Boolean
INT32
INTEGER
UTC_TIME

This fixes a problem with groupType being stored in an unnormalised
form

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-08-09 11:56:23 +02:00
Andrew Tridgell
55b25e1e23 s4-dsdb: ensure we setup the dn_format field in schema attributes
this ensures we setup dn_format when we do runtime schema changes

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-08-09 11:56:23 +02:00
Andrew Tridgell
d4a1f6a42b s4-dsdb: added dn_format attribute of a dsdb_attribute
this is faster than string comparisons during searches at runtime

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
2011-08-04 16:17:25 +10:00
Andrew Tridgell
a74f4673ed s4-dsdb: setup a one_way_link attribute on schema attributes
this allows us to quickly determine if a DN is a one way link

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
2011-08-04 16:17:24 +10:00
Matthieu Patou
930fa1ee46 update/add my copyright 2011-07-21 11:44:33 +10:00
Matthieu Patou
b1ffe82fac s4-schema: add systemFlags to dsdb classes objects 2011-07-21 11:44:33 +10:00
Andrew Tridgell
014fca1069 dsdb: fixed special case of zero NTTIME
we can't convert 0 NTTIME via a unix time_t

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-07-13 12:51:05 +02:00
Matthieu Patou
4d51ddbb5c s4-schema: avoid segfaulting if id3.guid is NULL 2011-06-22 20:13:08 +02:00
Andrew Tridgell
c46f80824b s4-dsdb: don't add zero GUID to BINARY_DN
When converting from DRS to ldb format for a BINARY_DN, don't add the
GUID extended DN element if the GUID is all zeros.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-06-22 14:47:07 +10:00
Andrew Tridgell
4905725599 s4-dsdb: if we don't have a remote schema, then use the local one
this allows the use of drsuapi_to_ldb() on all attributes for the
local database
2011-06-17 12:32:55 +10:00
Matthias Dieter Wallnöfer
26c7223e72 s4:schema_convert_to_ol.c - fix memory contexts
- Add more "mem_ctx" free functions on error cases
- Steal the "out" string directly onto the LDB context to be able to free
  the local "mem_ctx"

Reviewed-by: Tridge
2011-06-09 10:53:36 +02:00
Matthias Dieter Wallnöfer
87a38d77ac s4:dsdb/schema_convert_to_ol.c - quiet enum warning
Introduce a error message when choosing wrong targets.

Reviewed-by: Tridge
2011-06-09 09:35:35 +02:00
Matthias Dieter Wallnöfer
ddb41f2af4 dsdb:schema/schema_syntax.c - correctly check error code of "ldb_string_utc_to_time"
This one doesn't set ERRNO. An error happens if the result is "0".

Reviewed-by: abartlet
2011-04-07 15:53:20 +02:00
Matthias Dieter Wallnöfer
6cef940b40 dsdb:schema/schema_syntax.c - add some empty value checks on validate functions
They are needed since the check in "ldb_msg_sanity_check" will be removed.

Reviewed-by: abartlet
2011-04-07 15:53:20 +02:00
Jeremy Allison
0c5214e2eb Ensure convert_string_XXX is always called with a valid converted_size pointer.
Preparation for cleaning up this API.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Tue Mar 29 21:01:49 CEST 2011 on sn-devel-104
2011-03-29 21:01:49 +02:00
Andrew Tridgell
15e84a9a09 charcnv: removed the allow_badcharcnv and allow_bad_conv options to convert_string*()
we shouldn't accept bad multi-byte strings, it just hides problems

Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Thu Mar 24 01:47:26 CET 2011 on sn-devel-104
2011-03-24 01:47:26 +01:00
Andrew Tridgell
8dc92c8f71 ldb: use #include <ldb.h> for ldb
thi ensures we are using the header corresponding to the version of
ldb we're linking against. Otherwise we could use the system ldb for
link and the in-tree one for include

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-02-10 06:51:07 +01:00
Matthias Dieter Wallnöfer
912faf1b08 s4:dsdb/schema/schema_* - adaptions needed for removed "const" on OIDs 2010-12-21 15:10:37 +11:00
Kamen Mazdrashki
5bc0848fc7 s4-dsdb_schema: Copy info needed for Schema refresh in dsdb_schema_copy_shallow
Just 'refresh_fn' and 'loaded_from_module' are copied.
I left 'reload_seq_number' set to 0 intentionally, so that
this Schema cache will looks like a very old one to ,refresh_fn'.
This way, if this shallow copy is attached to LDB, it will be
refreshed as soon as possible by 'refresh_fn'.
2010-12-18 05:32:15 +02:00
Kamen Mazdrashki
dda73b85e6 s4-dsdb_schema: Handle remote ATTIDs based on msDs-IntId value
If we get such an msDs-IntId value, then we should just use it,
there is no mapping available for such values
2010-12-15 00:51:19 +01:00
Kamen Mazdrashki
52f7e38d6a s4-schema_syntax: Log error message when _dsdb_syntax_OID_oid_drsuapi_to_ldb() fails
I haven't found a way to test this function during replication so far,
but when I do, it will be useful to notice this error in the log file
2010-12-15 00:51:19 +01:00
Kamen Mazdrashki
2b74838c14 s4-dsdb_schema: We need base_dn in Schema's shallow copy too 2010-12-15 00:51:19 +01:00
Kamen Mazdrashki
3a8fa09c4f s4-schema_syntax: We should use make_ATTID function when converting remote-ATTID to local one
We may have no prefix for the remote ATTID (remote OID strictly speaking)
So this is the place for us to update our local prefixMap
adding a prefix for the numeric OID we've recived
2010-12-15 00:51:19 +01:00
Kamen Mazdrashki
afee8a28c4 s4-schema_syntax: Use remote prefixMap to map remote ATTID to local one
in dsdb_attribute_drsuapi_to_ldb() function.

drsuapi_DsReplicaAttribute *in parameter come from remote DC
so we can't rely on in->attid to map it directly to an
dsdb_attribute in our local schema cache
2010-12-15 00:51:19 +01:00
Kamen Mazdrashki
79e1a71e56 s4-dsdb_schema: Seize using global_schema when referencing new schema for an LDB
Without this change, when a schema is set to ldb, the
effect is that dsdb_get_schema() returns global_schema
preferably.

Thus we end up with two schemas in effect:
- global one, which is the old one and it is still used everywhere
- new one, which is just cached in ldb, but can't be used, as
  there is no way to access it
2010-12-15 00:51:18 +01:00
Jelmer Vernooij
35fbc7bbda s4-smbtorture: Make test names lowercase and dot-separated.
This is consistent with the test names used by selftest, should
make the names less confusing and easier to integrate with other tools.

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Dec 11 04:16:13 CET 2010 on sn-devel-104
2010-12-11 04:16:13 +01:00
Kamen Mazdrashki
03b078c567 s4-dsdb/syntax: Map remote ATTIDs for Class OID syntax
Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Thu Dec  2 18:47:59 CET 2010 on sn-devel-104
2010-12-02 18:47:59 +01:00
Kamen Mazdrashki
5bc11855f6 s4-dsdb_syntax: Be a little bit more chatty when we can't an ATTID in our cache 2010-12-02 19:02:54 +02:00
Kamen Mazdrashki
23b4408a62 s4-dsdb/syntax: Map remote ATTIDs for Attribute OID syntax 2010-12-01 13:01:17 +02:00
Kamen Mazdrashki
29f9249bd6 s4-dsdb/syntax: Implement Remote-ATTID to Local-ATTID mapping function 2010-12-01 13:01:17 +02:00
Kamen Mazdrashki
fcc26c5d59 s4-dsdb/schema: Add Schema shallow copy function 2010-12-01 13:01:16 +02:00
Kamen Mazdrashki
16bd9dd7ae s4-dsdb/prefixMap: Add prefixMap shallow copy function 2010-12-01 13:01:16 +02:00
Kamen Mazdrashki
0868a15982 s4-repl: Propagate remote prefixMap in DRSUAPI data conversion functions 2010-11-11 18:54:20 +00:00
Kamen Mazdrashki
2d0cb54ceb s4-dsdb_syntax: Warning message that we can't find requested ATTID in Schema Cache 2010-11-11 18:54:20 +00:00
Kamen Mazdrashki
3ab75524ee s4-prefixMap: dsdb_schema_pfm_oid_from_attid() to use const prefixMap
It is not supposed to change supplied prefixMap
2010-11-11 18:54:20 +00:00
Kamen Mazdrashki
e772518a64 s4-dsdb_syntax: Use remote prefixMap to handle generic cases in drsuapi_to_ldb conversions 2010-11-11 18:54:20 +00:00
Kamen Mazdrashki
f65c840299 s4-dsdb_syntax: Add remote prefixMap member for dsdb_syntax conversions 2010-11-11 18:54:20 +00:00
Stefan Metzmacher
9f39d4bfa4 s4:dsdb/schema/schema_filtered.c: make never_in_filtered_attrs static const
metze
2010-11-09 22:52:59 +01:00
Stefan Metzmacher
44b1c82e84 s4:dsdb/schema/schema_filtered.c: use DSDB_SECRET_ATTRIBUTES
metze
2010-11-09 22:52:57 +01:00
Kamen Mazdrashki
0aeb08e2eb s4-attid: Uppercase ATTID type constants
Thanks Metze for noting this!

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Mon Nov  8 23:06:41 UTC 2010 on sn-devel-104
2010-11-08 23:06:41 +00:00
Andrew Tridgell
18085b1236 s4-dsdb: give the DN on a shema attribute failure 2010-11-07 22:50:05 +00:00
Kamen Mazdrashki
a2d787d95d s4-dsdb_schema: Use DRSUAPI_ATTID_INVALID instead of 0xFFFFFFFF magic value
Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Mon Nov  1 00:36:20 UTC 2010 on sn-devel-104
2010-11-01 00:36:20 +00:00
Kamen Mazdrashki
717b1158a6 idl: Use DRSUAPI_ATTID_ prefix instead of DRSUAPI_ATTRIBUTE_ for ATTID values
Those values are actually ATTID values and such, they are used
for ATTIDs for Attributes, Classes and Syntaxes.
2010-10-31 23:54:04 +00:00
Kamen Mazdrashki
6b188fbad4 s4-schema_init: we should be able to resolve Syntax OIDs with prefixMap we have
If Syntax OID is not in the prefixMap then we are getting
an unknown Attribute Syntax (which we can't handle anyway)
2010-10-29 02:31:17 +03:00
Kamen Mazdrashki
e5ebc48697 s4-dsdb_syntax: *_OID_oid_ldb_to_drsuapi() functions should use
dsdb_schema_pfm_attid_from_oid() instead of
dsdb_schema_pfm_make_attid() as those functions are
supposed to return ATTIDs only for OIDs we already know about
(i.e. are in prefixMap)

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Tue Oct 26 22:44:36 UTC 2010 on sn-devel-104
2010-10-26 22:44:36 +00:00
Kamen Mazdrashki
0fc2427224 s4-prefixMap: split dsdb_schema_make_attid() function into read-only and
read-write functions.
dsdb_schema_make_attid() may change prefixMap implicitly
and this is not always desired behavior.
The problem was that
(1) callers had no control on this behavior
(2) callers had no way to know wheter prefixMap has been
    changed which can lead to hard to find bugs like
    prefixMap is changed in read operation
2010-10-26 22:17:41 +03:00
Kamen Mazdrashki
5e108fc5f9 s4-prefixmap: Use WERR_NOT_FOUND when OID is not found in current prefixMap
rather than WERR_DS_NO_MSDS_INTID.
WERR_DS_NO_MSDS_INTID is intended to be used for msDsIntId
attribute values handling
2010-10-26 22:17:40 +03:00
Kamen Mazdrashki
d46ca0eb80 s4-dsdb_syntax: Setup "String(Case Sensitive)" syntax
Currently it is mapped to Octet String LDAP syntax
for comparison purposes.

According to LDAP rfc we should be using same comparison
as Directory String (LDB_SYNTAX_DIRECTORY_STRING), but case sensitive.
But according to ms docs binary compare should do the job:
http://msdn.microsoft.com/en-us/library/cc223200(v=PROT.10).aspx

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Fri Oct 22 22:19:50 UTC 2010 on sn-devel-104
2010-10-22 22:19:50 +00:00
Kamen Mazdrashki
2a001381e8 s4-dsdb/schema_syntax: Separate validation for numericoid OID values
This implementation doesn't use prefixMap/Schema to validate
numericoid OIDs. We may not have this OID yet, so I see no point
checking schema for if we have it.

Side effect of using prefixMap/Schema for validating numericoids
is that we mistakenly add the OID to the prefixMap.
This led to a corrupted prefixMap in LDB.

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Thu Oct 21 23:32:26 UTC 2010 on sn-devel-104
2010-10-21 23:32:26 +00:00
Andrew Tridgell
47591ea5ec s4-dsdb: moved a bunch of fuctions from schema/schema_info_attr.c to samdb/ldb_modules/schema_util.c
these functions operate on ldb_modules, so they should be in the
ldb_modules directory. They also should return ldb errors codes, not
WERROR codes, as otherwise the error can be hidden from the ldap
caller

This re-arrangement fixes a dependency loop in the schema/samdb code.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Kamen Mazdrashki <kamenim@samba.org>
2010-10-21 19:03:25 +11:00
Kamen Mazdrashki
71ac92b673 s4-schema_init: Print more info about syntax we fail to recognize
Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Wed Oct 20 13:54:01 UTC 2010 on sn-devel-104
2010-10-20 13:54:01 +00:00
Matthias Dieter Wallnöfer
a6d70ddf86 s4:dsdb/schema/schema_init.c - remove a duplicated "talloc_free" 2010-10-19 10:11:03 +00:00
Matthias Dieter Wallnöfer
a0e9814c0d s4:dsdb - remove "samdb_result_uint", "samdb_result_int64", "samdb_result_uint64" and "samdb_result_string"
We have ldb_msg_find_attr_as_* calls which do exactly the same. Therefore this
reduces only code redundancies.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2010-10-15 08:36:01 +11:00
Jelmer Vernooij
1229935aa9 torture/becomedc: Add test for global schema, use samdb_connect().
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Tue Oct 12 18:35:33 UTC 2010 on sn-devel-104
2010-10-12 18:35:33 +00:00
Jelmer Vernooij
3b19993561 dsdb/schema: Move some dsdb_dn functions that are schema-specific. 2010-10-11 01:06:35 +02:00
Kamen Mazdrashki
81e5e23683 s4-dsdb: Make dsdb_setup_sorted_accessors() public
We are going to need it while converting DRS schema.
2010-10-10 12:58:32 +03:00
Kamen Mazdrashki
f06d98764a s4-dsdb-schema_prefixmap: return WERR_DS_NO_ATTRIBUTE_OR_VALUE when ATTID is not found
rather than WERR_INTERNAL_ERROR - it is not internal error!
2010-09-21 00:15:24 +03:00
Kamen Mazdrashki
395b09c1b6 s4-dsdb-schema_prefixmap: Print debug message when internal failure occurs 2010-09-21 00:15:24 +03:00
Kamen Mazdrashki
9256b5f226 s4-schema: Helper func to compare schemaInfo signitures 2010-09-17 13:53:03 +03:00
Kamen Mazdrashki
1295da92f9 s4-schema: use dsdb_schema_info_blob_is_valid() to verify schemaInfo blob
instead of parsing it.
2010-09-17 13:53:03 +03:00
Kamen Mazdrashki
aedefd3e99 s4-prefixMap: use dsdb_schema_info_blob_is_valid() for schemaInfo blob validation
This fixes a leaking dsdb_schema_info object also.
2010-09-17 13:53:03 +03:00
Kamen Mazdrashki
e691b1fd27 s4-dsdb: Add dsdb_schema_info_blob_is_valid() to verify schemaInfo blobls 2010-09-17 13:53:03 +03:00
Matthias Dieter Wallnöfer
a4b7fac86d s4:cosmetic - the SID attribute is called objectSid - not objectSID 2010-09-13 22:39:50 +02:00
Kamen Mazdrashki
89899f55dc s4-drs: ATTIDs for deleted attributes should be based on msDs-IntId value if it exists 2010-08-19 03:34:05 +03:00
Kamen Mazdrashki
695072478d s4-dsdb: No need for dsdb_syntax_one_DN_drsuapi_to_ldb() to be public
It is intended to be used in schema_syntax.c module
2010-08-19 03:34:04 +03:00
Kamen Mazdrashki
35d886db17 s4-dsdb-syntax: ATTID should be msDs-IntId value for the attributeSchema object
in case object replicated is not in Schema NC and attributeSchema
object has msDs-IntId attribute value set
2010-08-19 03:34:03 +03:00
Kamen Mazdrashki
fffc98f33e s4: fix few comment typos 2010-08-19 03:34:02 +03:00
Kamen Mazdrashki
d01804dda9 s4-schema_syntax.c: Fix white spaces and alignment 2010-08-19 03:34:02 +03:00
Kamen Mazdrashki
c5ec1f3d92 s4-dsdb: Use dsdb_syntax_ctx in *_drsuapi_to_ldb functions 2010-08-19 03:34:02 +03:00
Kamen Mazdrashki
b5af7b9a1e s4-dsdb: Use dsdb_syntax_ctx in *_ldb_to_drsuapi functions 2010-08-19 03:34:01 +03:00
Kamen Mazdrashki
ca80918613 s4-dsdb: Use dsdb_syntax_ctx in *_validate_ldb functions 2010-08-19 03:34:01 +03:00
Kamen Mazdrashki
b7d1586ccd s4-dsdb: Add context structure for dsdb_syntax conversion functions
This structure is intended to hold context-dependent data.

Syntax-conversion and object-conversion functions need
that data to convert objects and attributes from drs-to-ldb
and ldb-to-drs correctly.

For instance: ATTID value depends on whether we are converting
object from partition different that Schema partition.
2010-08-19 03:34:01 +03:00
Kamen Mazdrashki
d595f070f6 s4-dsdb: fix attributes_by_msDS_IntId index sorting 2010-08-11 00:18:14 +03:00
Kamen Mazdrashki
f827904596 s4-schema: More verbose error log when subClassOf is not found in schema
Error message show failing classSchema object
but not the specific value for the failure,
which makes diagnostics by log files really hard.
2010-08-03 04:29:23 +03:00
Kamen Mazdrashki
a268e0846f s4: fix comment typos 2010-08-03 04:29:22 +03:00
Kamen Mazdrashki
86cc914717 s4-dsdb: use ldb_msg_normalize() in source4/dsdb/schema/schema_set.c
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2010-07-19 17:33:34 +10:00
Kamen Mazdrashki
fb1c0796c7 s4-dsdb/schema/schema_set.c: fix trailing spaces and comments spelling
Few comments split on several lines also...

(Sorry Metze, I know you hate reviewing "and this, and that"
type of patches, but those are just cosmetics)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2010-07-19 17:33:33 +10:00
Kamen Mazdrashki
a11d3b4dfb s4-dsdb: use ldb_msg_difference() in source4/dsdb/schema/schema_set.c
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2010-07-19 17:33:33 +10:00
Andrew Tridgell
87df785a68 s4-dsdb: use ldb_operr() in the dsdb code
this replaces "return LDB_ERR_OPERATIONS_ERROR" with "return ldb_operr(ldb)"
in places in the dsdb code where we don't already explicitly set an
error string. This should make is much easier to track down dsdb
module bugs that result in an operations error.
2010-07-07 20:14:55 +10:00
Matthias Dieter Wallnöfer
02eab66026 s4:schema_set.c - Fix a comment 2010-07-03 14:53:03 +02:00
Matthias Dieter Wallnöfer
d1ee7ab16e s4:dsdb_schema_set_attributes - remove unneeded filter criterias
We already choose the right entry by specifying the right basedn with scope
"LDB_SCOPE_BASE".
2010-07-03 14:53:02 +02:00
Matthias Dieter Wallnöfer
4df9757b48 s4:schema_set.c - fix typo 2010-07-03 12:36:34 +02:00
Anatoliy Atanasov
62341537d7 s4/schema: remove unnecessary deletion of dsdb_schema cached pointer
This is needed so we can find and free old schemas based using
the cached pointer
2010-07-02 11:55:33 +03:00
Andrew Bartlett
c48279896d s4:dsdb Ensure we free old schema copies
It was reported by aatanasov that we kept around one whole schema per
modification made.  This does not fix that, but I hope moves us closer
to a fix

The most important part of the fix is that:

-		if (schema_out != schema_in) {
-			talloc_unlink(schema_in, ldb);
-		}

was the wrong way around.  This is now handled in the schema_set calls.

Andrew Bartlett
2010-07-02 10:08:16 +10:00
Anatoliy Atanasov
6abfe8904a s4:schema/schema_set.c - free LDB message diffs
Especially the "free"s after "ldb_msg_diff" are very important since the diff
message is allocated on the long-living LDB context.

Signed-off-by: Matthias Dieter Wallnöfer <mdw@samba.org>
2010-06-30 09:17:44 +02:00
Andrew Bartlett
32b8b401d6 s4:dsdb Fix possible schema segfaults for DRS-replication based schema
The problem here is that if the schema has been modified on the source
domain, there may be attributes that appear over DRS with 0 values (to
indicate that any existing values on the target should be deleted).
This would confuse the previous version of this macro.

Andrew Bartlett
2010-06-30 10:22:59 +10:00
Kamen Mazdrashki
3aa8853f58 s4/dsdb: msg_idx->dn should be allocated in msg_idx mem context 2010-06-21 02:57:56 +03:00
Kamen Mazdrashki
cc7e2c10f2 s4/dsdb: Move schema accessors cleanup in separate function
This way dsdb_setup_sorted_accessors() will
free memory allocated for accessor arrays correctly
in case of failure,
2010-06-21 02:57:56 +03:00
Kamen Mazdrashki
267645ca55 s4/dsdb-schema: Index attributes on msDS-IntId value
O(n) search for dsdb_attribute by msDS-IntId value was
replaced by binary-search in ordered index.

I've choosen the approach of separate index on msDS-IntId values
as I think it is more clear what we are searching for.
And it should little bit faster as we can clearly determine
in which index to perform the search based on ATTID value -
ATTIDs based on prefixMap and ATTIDs based on msDS-IntId
are in separate ranges.

Other way to implement this index was to merge msDS-IntId values
in attributeID_id index.
This led me to a shorted but not so obvious implementation.
2010-06-21 02:57:55 +03:00
Andrew Bartlett
7c60ac97bf s4:provision Allow a specific prefix map to be loaded into a new schema provision
This allows the prefixMap from a DRS server to be used when loading
the schema from the local files.  This helps us then import other
schema with this map in place.

Andrew Bartlett

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
2010-06-15 10:51:34 +10:00
Andrew Bartlett
5323485eb3 s4:dsdb Allow the setting an override on the schema
The change here is to try and convert a per the previous rules, but if
we don't know a particular OID as a attributeID, then store it as an
OID (for example).  This allows known values to be converted as
before, but still copes with unknown values.

Andrew Bartlett

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
2010-06-15 10:51:34 +10:00
Andrew Bartlett
6a2f7fe04c s4:dsdb Use the schema from our local provision to decode the schema
This works on the assumption that the schema partition can only
contain schema objects.

We may need to pass down some kind of 'relax' to the DRS -> LDB
conversion code, so that it allows incomplete conversions, so that we
don't fail if a new attribute is present, and we can't decode it.
This would then be resolved the second time we do the conversion.

Andrew Bartlett

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
2010-06-15 10:51:34 +10:00
Andrew Bartlett
088d5b76ca s4:dsdb Simplfy match of objectclass in dsdb_schema_set_el_from_ldb_msg
There is no need to do a full ldb_match_msg() for a simple case
insensitive string.

Andrew Bartlett
2010-06-12 11:18:41 +10:00
Andrew Bartlett
d6f5c1ace2 s4:dsdb Provide a function to convert from DRS prefix maps to the LDB prefixmap
This allows us to push a prefixmap directly into the schema we
generate in the provision code.

Andrew Bartlett
2010-06-12 11:17:22 +10:00
Andrew Bartlett
e82836467c s4:dsdb Add more debugs to help track down failures to parse the prefixmap 2010-06-12 11:17:14 +10:00
Andrew Bartlett
c6bf8e4cad s4:dsdb Put back the reference and set_attributes in dsdb_reference_schema
I'm not sure why I removed these in fe3e1af901

Andrew Bartlett
2010-06-12 11:16:49 +10:00
Matthias Dieter Wallnöfer
bd910952ba s4:remove the "validate_update" LDB module - the task is now handled by the far more complete "objectclass_attrs" LDB module 2010-06-07 14:47:23 +02:00
Jelmer Vernooij
b8268cf7b0 s3: Remove use of iconv_convenience. 2010-05-18 11:45:31 +02:00
Jelmer Vernooij
f9ca9e46ad Finish removal of iconv_convenience in public API's. 2010-05-18 11:45:30 +02:00
Nadezhda Ivanova
e2e39117bc Replaced DS_FLAG_ATTR_IS_CRITICAL with SCHEMA_FLAG_ATTR_IS_CRITICAL. 2010-05-03 16:47:56 +02:00
Nadezhda Ivanova
15b42d6515 Added a function to check if an attribute can belong to a filtered replica. 2010-05-03 14:50:10 +02:00
Kamen Mazdrashki
59830d0a6e s4/dsdb: schemaInfo revision may be 0
In case schemaInfo value is still not set, WinAD supplies
schemaInfo blob with revision = 0 and GUID_ZERO
2010-04-29 04:54:07 +03:00
Kamen Mazdrashki
a8438015ca s4/dsdb: remove unused dsdb_schema_info_create() function 2010-04-29 04:54:07 +03:00
Kamen Mazdrashki
2264d917ae s4/dsdb: Update Schema cache with updated schemaInfo value
Error checking is simplified and my leave leeks.
I did it this way to make code more readable, and if we
get error in those lines, it will be WERR_NOMEM in which
case we are in a much deeper troubles than delayed freeing
of few bytes.
2010-04-29 04:54:07 +03:00
Kamen Mazdrashki
e41eac96af s4/samldb: Create initial schemaInfo value if it doesn't exists yet 2010-04-29 04:54:06 +03:00
Kamen Mazdrashki
546a727bd3 s4/dsdb: Use default schemaInfo value when no such value is given
Having no value for schemaInfo is totally OK as it turns out.
In such cases, we should use a default value with
all fields set to 0.
2010-04-29 04:54:06 +03:00
Kamen Mazdrashki
5bf12e101a Revert "s4/dsdb: Set schemaInfo attribute value during provisioning"
This reverts commit 8149094edd.

Windows implementation does not set schemaInfo attribute value
until first Schema update request.
This way, newly provisioned forest returns no schemaInfo value.

I think it won't be bad for us to have this value preset, but
I want to mimic Win AD behavior as close as possible.
2010-04-29 04:54:05 +03:00
Andrew Tridgell
1ecefd74a2 s4-dsdb: added dsdb_get_extended_dn_sid()
This will be used by the RODC code

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2010-04-22 19:36:15 +10:00
Andrew Tridgell
2dcc84432e s4-schema: allow revision numbers of zero
w2k8r2 sends a revision of zero in the initial schema replication
during a net vampire

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2010-04-21 13:35:56 +10:00
Matthias Dieter Wallnöfer
ad9e407357 Revert "s4:prefer "samdb_*_dn" basedn calls over the "ldb_get_*_dn" functions"
We should use the "ldb_get_*_basedn" calls since they are available in the LDB
library.
2010-04-13 08:55:15 +02:00
Andrew Bartlett
77267733ed s4:dsdb Don't use the permissive modify control on schemaInfo updates
The use of 'replace' is enough to wipe out the old value, whatever it
is, we don't need to set 'permissive modify' too.

Additionally, this seems to be causing trouble for the OpenLDAP backend

Andrew Bartlett
2010-04-10 21:41:57 +10:00
Kamen Mazdrashki
8149094edd s4/dsdb: Set schemaInfo attribute value during provisioning
After provisioning new Forest, schemaInfo should be set
to a value with revision=1 and current invocation_id
2010-04-09 12:21:34 +03:00
Kamen Mazdrashki
4ba2ac073d s4/dsdb: split writing of schemaInfo blob in two parts
ldb_msg preparation is moved into separate function
so that it can be used for implementing schemaInfo
updates both on module stack (dsdb_module_... functions)
and directly on ldb_context
2010-04-09 12:21:33 +03:00
Kamen Mazdrashki
fbef33fb73 s4/dsdb: Let caller to control if valid invocationId is critical or zero-guid is acceptable 2010-04-09 12:21:33 +03:00
Kamen Mazdrashki
5363b6e68b s4/dsdb: Use dsdb_schema_info object to create default schemaInfo values 2010-04-09 12:21:32 +03:00
Kamen Mazdrashki
c3d7798991 s4/dsdb: Use dsdb_schema_info object to verify schema_info blobs 2010-04-09 12:21:31 +03:00
Kamen Mazdrashki
9d1f8bcca9 s4/dsdb: dsdb_schema_info object implementation 2010-04-09 12:21:26 +03:00
Kamen Mazdrashki
37a6b66344 s4/dsdb: Define dsdb representation for schemaInfo attribute 2010-04-09 12:21:25 +03:00
Andrew Bartlett
f8019ff793 s4:dsdb Add a shortcut sequence number for schema reloads
This uses the ldb sequence number, in a hope to detect an unchanged
schema quicker.

Andrew Bartlett
2010-03-22 20:24:41 +11:00
Andrew Bartlett
fe3e1af901 s4:dsdb Rework schema loading and add schema reloading
This commit reworks Samba4's schema loading code to detect when it
needs to reload the schema.  This is done by watching the @REPLCHANGED
special DN.

The reload happens by means of a callback, which is only set when the
schema is loaded from the ldb - not when loaded from an LDIF file or
DRS.

We also rework the global schema handling - instead of storing the
pointer to the global schema in each ldb, we store a flag indicating
that the global schema should be returned at run time.  This makes it
much easier to switch to a new global schema.

Andrew Bartlett
2010-03-22 20:24:41 +11:00
Andrew Bartlett
639728a298 s4:schema Expand the schema structure
We now store the location of the schema in the schema, and provide
hooks for a future schema reloading mechanism.

Andrew Bartlett
2010-03-22 20:24:41 +11:00
Andrew Bartlett
2de07761e0 s4:dsdb Change dsdb_get_schema() callers to use new talloc argument
This choses an appropriate talloc context to attach the schema too,
long enough lived to ensure it does not go away before the operation
compleates.

Andrew Bartlett
2010-03-16 19:26:03 +11:00
Andrew Bartlett
1e6fee4185 s4:dsdb Add a memory context for dsdb_get_schema()
When specified, we talloc_reference onto this context to ensure that
pointers found in it are valid for the life of the objects they are
placed into.  (Such as the string form of LDAP attributes).

Andrew Bartlett
2010-03-16 19:25:14 +11:00
Matthias Dieter Wallnöfer
5a54b204c3 s4:schema - Change also here counters to "unsigned" where needed
Counters which are used in the way  "for (i = 0; array[i] != NULL; i++)" I
modified to "unsigned" since for sure we don't want to have negative array
indexes there.
2010-03-07 19:01:15 +01:00
Matthias Dieter Wallnöfer
bd5f08f3d1 s4:schema_syntax.c - Change also here counters to "unsigned" where needed
Counters which are used in the way  "for (i = 0; array[i] != NULL; i++)" I
modified to "unsigned" since for sure we don't want to have negative array
indexes there.

There were many counter variables typed "uint32_t". This isn't fully correct
since those count LDB objects. The amount is saved in a "num_*" variable which
is "unsigned" without a bitlength specification. Therefore change also these
counters to be plain "unsigned".
2010-03-07 19:00:32 +01:00
Stefan Metzmacher
4bad696f9e s4:dsdb/schema: fix validation of DNs
ldb_dn_extended_filter() removes all but the listed components,
I didn't noticed that when writting the code.
Doing a ldb_dn_remove_extended_components(dn2) is wrong.

This was hidden by some bugs in the ldb_dn code.

metze
2010-02-26 23:26:32 +01:00
Andrew Tridgell
90203f87e7 s4-dsdb: change samdb_replace() to dsdb_replace() and allow for dsdb_flags
This allows for controls to be added easily where they are needed.
2010-02-16 21:10:50 +11:00
Andrew Tridgell
5549190b37 s4-dsdb: use TYPESAFE_QSORT() in dsdb code 2010-02-13 22:36:12 +11:00
Stefan Metzmacher
1f2efef214 s4:dsdb/schema: add dsdb_syntax_OID_validate_ldb()
This is a very heavy weight way of checking this syntax,
but it's very complex and using the existing function
should be ok for now. We can optimize it later.

metze
2010-01-13 16:06:41 +01:00