2006-12-17 02:19:56 +00:00
/*
2020-08-09 16:14:02 +02:00
Unix SMB / CIFS Implementation .
2006-12-17 02:19:56 +00:00
DSDB schema header
2007-03-14 19:10:21 +00:00
Copyright ( C ) Stefan Metzmacher < metze @ samba . org > 2006
2006-12-17 02:19:56 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2006-12-17 02:19:56 +00:00
( at your option ) any later version .
This program 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 General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-12-17 02:19:56 +00:00
*/
# ifndef _DSDB_SCHEMA_H
# define _DSDB_SCHEMA_H
2009-10-18 21:31:37 +03:00
# include "prefixmap.h"
2011-08-01 17:47:34 +10:00
enum dsdb_dn_format {
DSDB_NORMAL_DN ,
DSDB_BINARY_DN ,
DSDB_STRING_DN ,
DSDB_INVALID_DN
} ;
2006-12-30 11:51:35 +00:00
struct dsdb_attribute ;
struct dsdb_class ;
struct dsdb_schema ;
2010-10-10 21:37:58 +02:00
struct dsdb_dn ;
2006-12-30 11:51:35 +00:00
2010-08-17 03:21:46 +03:00
struct dsdb_syntax_ctx {
struct ldb_context * ldb ;
const struct dsdb_schema * schema ;
2010-08-18 03:06:53 +03:00
/* set when converting objects under Schema NC */
bool is_schema_nc ;
2010-11-09 04:12:16 +02:00
/* remote prefixMap to be used for drsuapi_to_ldb conversions */
const struct dsdb_schema_prefixmap * pfm_remote ;
2010-08-17 03:21:46 +03:00
} ;
2006-12-29 10:35:44 +00:00
struct dsdb_syntax {
const char * name ;
const char * ldap_oid ;
uint32_t oMSyntax ;
struct ldb_val oMObjectClass ;
const char * attributeSyntax_oid ;
2008-08-18 10:16:45 +10:00
const char * equality ;
const char * substring ;
const char * comment ;
2008-08-18 20:30:27 +10:00
const char * ldb_syntax ;
2006-12-30 11:51:35 +00:00
2010-08-17 04:20:46 +03:00
WERROR ( * drsuapi_to_ldb ) ( const struct dsdb_syntax_ctx * ctx ,
2006-12-30 11:51:35 +00:00
const struct dsdb_attribute * attr ,
const struct drsuapi_DsReplicaAttribute * in ,
TALLOC_CTX * mem_ctx ,
struct ldb_message_element * out ) ;
2010-08-17 04:12:54 +03:00
WERROR ( * ldb_to_drsuapi ) ( const struct dsdb_syntax_ctx * ctx ,
2006-12-30 11:51:35 +00:00
const struct dsdb_attribute * attr ,
const struct ldb_message_element * in ,
TALLOC_CTX * mem_ctx ,
struct drsuapi_DsReplicaAttribute * out ) ;
2010-08-17 03:58:26 +03:00
WERROR ( * validate_ldb ) ( const struct dsdb_syntax_ctx * ctx ,
2009-09-29 18:57:01 +02:00
const struct dsdb_attribute * attr ,
const struct ldb_message_element * in ) ;
2011-08-09 14:41:20 +10:00
bool auto_normalise ;
2013-09-24 10:12:24 -07:00
bool userParameters ; /* Indicates the syntax userParameters should be forced to */
2006-12-29 10:35:44 +00:00
} ;
2006-12-17 02:19:56 +00:00
struct dsdb_attribute {
struct dsdb_attribute * prev , * next ;
const char * cn ;
const char * lDAPDisplayName ;
const char * attributeID_oid ;
uint32_t attributeID_id ;
struct GUID schemaIDGUID ;
uint32_t mAPIID ;
2010-01-07 02:46:25 +02:00
uint32_t msDS_IntId ;
2006-12-17 02:19:56 +00:00
struct GUID attributeSecurityGUID ;
2009-11-16 18:40:24 +11:00
struct GUID objectGUID ;
2006-12-17 02:19:56 +00:00
uint32_t searchFlags ;
uint32_t systemFlags ;
2007-08-27 18:10:19 +00:00
bool isMemberOfPartialAttributeSet ;
2006-12-17 02:19:56 +00:00
uint32_t linkID ;
const char * attributeSyntax_oid ;
uint32_t attributeSyntax_id ;
uint32_t oMSyntax ;
struct ldb_val oMObjectClass ;
2007-08-27 18:10:19 +00:00
bool isSingleValued ;
2008-11-13 21:32:04 +01:00
uint32_t * rangeLower ;
uint32_t * rangeUpper ;
2007-08-27 18:10:19 +00:00
bool extendedCharsAllowed ;
2006-12-17 02:19:56 +00:00
uint32_t schemaFlagsEx ;
struct ldb_val msDs_Schema_Extensions ;
2007-08-27 18:10:19 +00:00
bool showInAdvancedViewOnly ;
2006-12-17 02:19:56 +00:00
const char * adminDisplayName ;
const char * adminDescription ;
const char * classDisplayName ;
2007-08-27 18:10:19 +00:00
bool isEphemeral ;
bool isDefunct ;
bool systemOnly ;
2006-12-29 10:35:44 +00:00
2011-08-01 13:54:58 +10:00
bool one_way_link ;
2023-03-01 11:30:55 +01:00
bool bl_maybe_invisible ;
2011-08-01 17:47:34 +10:00
enum dsdb_dn_format dn_format ;
2011-08-01 13:54:58 +10:00
2006-12-29 10:35:44 +00:00
/* internal stuff */
const struct dsdb_syntax * syntax ;
2009-04-02 16:42:21 +11:00
const struct ldb_schema_attribute * ldb_schema_attribute ;
2006-12-17 02:19:56 +00:00
} ;
struct dsdb_class {
struct dsdb_class * prev , * next ;
const char * cn ;
const char * lDAPDisplayName ;
const char * governsID_oid ;
uint32_t governsID_id ;
struct GUID schemaIDGUID ;
2009-11-16 18:40:24 +11:00
struct GUID objectGUID ;
2006-12-17 02:19:56 +00:00
uint32_t objectClassCategory ;
const char * rDNAttID ;
const char * defaultObjectCategory ;
const char * subClassOf ;
2006-12-28 13:06:29 +00:00
const char * * systemAuxiliaryClass ;
2006-12-17 02:19:56 +00:00
const char * * systemPossSuperiors ;
const char * * systemMustContain ;
const char * * systemMayContain ;
2006-12-28 13:06:29 +00:00
const char * * auxiliaryClass ;
2006-12-17 02:19:56 +00:00
const char * * possSuperiors ;
const char * * mustContain ;
const char * * mayContain ;
2007-07-27 03:08:15 +00:00
const char * * possibleInferiors ;
2009-09-24 15:12:49 -07:00
const char * * systemPossibleInferiors ;
2006-12-17 02:19:56 +00:00
const char * defaultSecurityDescriptor ;
uint32_t schemaFlagsEx ;
2011-05-03 20:38:13 +04:00
uint32_t systemFlags ;
2006-12-17 02:19:56 +00:00
struct ldb_val msDs_Schema_Extensions ;
2007-08-27 18:10:19 +00:00
bool showInAdvancedViewOnly ;
2006-12-17 02:19:56 +00:00
const char * adminDisplayName ;
const char * adminDescription ;
const char * classDisplayName ;
2007-08-27 18:10:19 +00:00
bool defaultHidingValue ;
bool isDefunct ;
bool systemOnly ;
2009-04-08 23:18:49 +10:00
2009-07-02 14:49:40 +10:00
uint32_t subClassOf_id ;
uint32_t * systemAuxiliaryClass_ids ;
uint32_t * auxiliaryClass_ids ;
uint32_t * systemMayContain_ids ;
uint32_t * systemMustContain_ids ;
uint32_t * possSuperiors_ids ;
uint32_t * mustContain_ids ;
uint32_t * mayContain_ids ;
uint32_t * systemPossSuperiors_ids ;
2009-09-15 08:14:54 -07:00
/* An ordered index showing how this subClass fits into the
* subClass tree . that is , an objectclass that is not
* subClassOf anything is 0 ( just in case ) , and top is 1 , and
* subClasses of top are 2 , subclasses of those classes are
* 3 */
uint32_t subClass_order ;
2013-01-17 14:40:24 +01:00
struct {
const char * * supclasses ;
const char * * subclasses ;
const char * * subclasses_direct ;
const char * * posssuperiors ;
} tmp ;
2006-12-17 02:19:56 +00:00
} ;
2017-11-22 12:34:01 +13:00
enum schema_set_enum {
SCHEMA_MEMORY_ONLY = 0 ,
SCHEMA_WRITE = 1 ,
SCHEMA_COMPARE = 2 ,
} ;
2010-03-23 02:32:14 +02:00
/**
* data stored in schemaInfo attribute
*/
struct dsdb_schema_info {
uint32_t revision ;
struct GUID invocation_id ;
} ;
2006-12-21 20:51:50 +00:00
2006-12-17 02:19:56 +00:00
struct dsdb_schema {
2009-10-26 00:31:28 +02:00
struct dsdb_schema_prefixmap * prefixmap ;
2006-12-21 20:51:50 +00:00
/*
* the last element of the prefix mapping table isn ' t a oid ,
* it starts with 0xFF and has 21 bytes and is maybe a schema
* version number
2006-12-23 10:39:26 +00:00
*
* this is the content of the schemaInfo attribute of the
* Schema - Partition head object .
2006-12-21 20:51:50 +00:00
*/
2016-08-04 10:03:14 +02:00
struct dsdb_schema_info * schema_info ;
2006-12-21 20:51:50 +00:00
2006-12-17 02:19:56 +00:00
struct dsdb_attribute * attributes ;
struct dsdb_class * classes ;
2008-02-19 13:39:27 +01:00
2013-01-26 23:42:10 -08:00
struct dsdb_attribute * * attributes_to_remove ;
uint32_t attributes_to_remove_size ;
struct dsdb_class * * classes_to_remove ;
uint32_t classes_to_remove_size ;
2009-04-02 16:42:21 +11:00
/* lists of classes sorted by various attributes, for faster
access */
uint32_t num_classes ;
struct dsdb_class * * classes_by_lDAPDisplayName ;
struct dsdb_class * * classes_by_governsID_id ;
struct dsdb_class * * classes_by_governsID_oid ;
struct dsdb_class * * classes_by_cn ;
/* lists of attributes sorted by various fields */
uint32_t num_attributes ;
struct dsdb_attribute * * attributes_by_lDAPDisplayName ;
struct dsdb_attribute * * attributes_by_attributeID_id ;
struct dsdb_attribute * * attributes_by_attributeID_oid ;
struct dsdb_attribute * * attributes_by_linkID ;
2023-03-30 16:00:59 +13:00
struct dsdb_attribute * * attributes_by_cn ;
2010-06-19 00:00:08 +03:00
uint32_t num_int_id_attr ;
struct dsdb_attribute * * attributes_by_msDS_IntId ;
2009-04-02 16:42:21 +11:00
2008-07-01 16:35:13 +02:00
struct {
bool we_are_master ;
2011-11-11 12:12:17 +01:00
bool update_allowed ;
2008-07-01 16:35:13 +02:00
struct ldb_dn * master_dn ;
} fsmo ;
2010-03-22 15:41:51 +11:00
/* Was this schema loaded from ldb (if so, then we will reload it when we detect a change in ldb) */
bool refresh_in_progress ;
2012-05-22 16:25:50 -07:00
time_t ts_last_change ;
2012-06-10 22:44:12 -07:00
/* This 'opaque' is stored in the metadata and is used to check if the currently
* loaded schema needs a reload because another process has signaled that it has been
* requested to reload the schema ( either due through DRS or via the schemaUpdateNow ) .
2012-05-22 15:13:04 -07:00
*/
uint64_t metadata_usn ;
2010-06-09 20:52:02 +10:00
/* Should the syntax handlers in this case handle all incoming OIDs automatically, assigning them as an OID if no text name is known? */
bool relax_OID_conversions ;
2016-08-08 09:10:13 +02:00
/*
* we ' re currently trying to construct a working_schema
* in order to replicate the schema partition .
*
* We use this in order to avoid temporary failure DEBUG messages
*/
bool resolving_in_progress ;
2006-12-17 02:19:56 +00:00
} ;
2016-10-14 15:43:46 +13:00
# define DSDB_SCHEMA_COMMON_ATTRS \
" objectClass " , \
" cn " , \
" lDAPDisplayName " , \
" schemaIDGUID " , \
" objectGUID " , \
" systemFlags " , \
" schemaFlagsEx " , \
" msDs-Schema-Extensions " , \
" showInAdvancedViewOnly " , \
" adminDisplayName " , \
" adminDescription " , \
" isDefunct " , \
" systemOnly "
# define DSDB_SCHEMA_ATTR_ATTRS \
" attributeID " , \
" msDS-IntId " , \
" mAPIID " , \
" attributeSecurityGUID " , \
" searchFlags " , \
" isMemberOfPartialAttributeSet " , \
" linkID " , \
" attributeSyntax " , \
" oMSyntax " , \
" oMObjectClass " , \
" isSingleValued " , \
" rangeLower " , \
" rangeUpper " , \
" extendedCharsAllowed " , \
" classDisplayName " , \
" isEphemeral "
# define DSDB_SCHEMA_CLASS_ATTRS \
" governsID " , \
" objectClassCategory " , \
" rDNAttID " , \
" defaultObjectCategory " , \
" subClassOf " , \
" systemAuxiliaryClass " , \
" auxiliaryClass " , \
" systemMustContain " , \
" systemMayContain " , \
" mustContain " , \
" mayContain " , \
" systemPossSuperiors " , \
" possSuperiors " , \
" defaultSecurityDescriptor " , \
" classDisplayName " , \
" defaultHidingValue "
2008-07-10 15:52:44 +10:00
enum dsdb_attr_list_query {
DSDB_SCHEMA_ALL_MAY ,
DSDB_SCHEMA_ALL_MUST ,
DSDB_SCHEMA_SYS_MAY ,
DSDB_SCHEMA_SYS_MUST ,
DSDB_SCHEMA_MAY ,
2008-07-11 15:11:32 +10:00
DSDB_SCHEMA_MUST ,
DSDB_SCHEMA_ALL
2008-07-10 15:52:44 +10:00
} ;
2008-08-15 20:40:57 +10:00
enum dsdb_schema_convert_target {
TARGET_OPENLDAP ,
TARGET_FEDORA_DS ,
TARGET_AD_SCHEMA_SUBENTRY
} ;
2014-05-14 20:12:03 +12:00
struct ldb_module ;
typedef struct dsdb_schema * ( * dsdb_schema_refresh_fn ) ( struct ldb_module * module ,
struct tevent_context * ev ,
struct dsdb_schema * schema , bool is_global_schema ) ;
2007-12-17 04:22:44 +01:00
# include "dsdb/schema/proto.h"
2006-12-17 02:19:56 +00:00
# endif /* _DSDB_SCHEMA_H */