s4-samldb: Do not allow deletion of objects with RID < 1000
[garming/samba-autobuild/.git] / source4 / dsdb / samdb / samdb.h
index 93068d66ef1dd4b47382c3445cd3bc54cef74c51..7f77d4e3827c2b5a424b4606029e4a8977f9475a 100644 (file)
@@ -27,44 +27,124 @@ struct dsdb_control_current_partition;
 struct dsdb_extended_replicated_object;
 struct dsdb_extended_replicated_objects;
 struct loadparm_context;
-struct event_context;
+struct tevent_context;
 
 #include "librpc/gen_ndr/security.h"
-#include "lib/ldb/include/ldb.h"
+#include <ldb.h>
 #include "lib/ldb-samba/ldif_handlers.h"
 #include "librpc/gen_ndr/samr.h"
 #include "librpc/gen_ndr/drsuapi.h"
 #include "librpc/gen_ndr/drsblobs.h"
 #include "dsdb/schema/schema.h"
 #include "dsdb/samdb/samdb_proto.h"
+#include "dsdb/common/dsdb_dn.h"
 #include "dsdb/common/proto.h"
-#include "dsdb/common/flags.h"
+#include "../libds/common/flags.h"
 
 #define DSDB_CONTROL_CURRENT_PARTITION_OID "1.3.6.1.4.1.7165.4.3.2"
 struct dsdb_control_current_partition {
        /* 
         * this is the version of the dsdb_control_current_partition
         * version 0: initial implementation
+        * version 1: got rid of backend and module fields
         */
-#define DSDB_CONTROL_CURRENT_PARTITION_VERSION 0
+#define DSDB_CONTROL_CURRENT_PARTITION_VERSION 1
        uint32_t version;
-
        struct ldb_dn *dn;
+};
 
-       const char *backend;
 
-       struct ldb_module *module;
-};
+/*
+  flags in dsdb_repl_flags to control replication logic
+ */
+#define DSDB_REPL_FLAG_PRIORITISE_INCOMING 1
+#define DSDB_REPL_FLAG_PARTIAL_REPLICA     2
+#define DSDB_REPL_FLAG_ADD_NCNAME         4
+
 
 #define DSDB_CONTROL_REPLICATED_UPDATE_OID "1.3.6.1.4.1.7165.4.3.3"
-/* DSDB_CONTROL_REPLICATED_UPDATE_OID has NULL data */
+struct dsdb_control_replicated_update {
+       uint32_t dsdb_repl_flags;
+};
+
+#define DSDB_CONTROL_DN_STORAGE_FORMAT_OID "1.3.6.1.4.1.7165.4.3.4"
+/* DSDB_CONTROL_DN_STORAGE_FORMAT_OID has NULL data and behaves very
+ * much like LDB_CONTROL_EXTENDED_DN_OID when the DB stores an
+ * extended DN, and otherwise returns normal DNs */
+
+#define DSDB_CONTROL_PASSWORD_CHANGE_STATUS_OID "1.3.6.1.4.1.7165.4.3.8"
+
+struct dsdb_control_password_change_status {
+       struct {
+               uint32_t pwdProperties;
+               uint32_t pwdHistoryLength;
+               int64_t maxPwdAge;
+               int64_t minPwdAge;
+               uint32_t minPwdLength;
+               bool store_cleartext;
+               const char *netbios_domain;
+               const char *dns_domain;
+               const char *realm;
+       } domain_data;
+       enum samPwdChangeReason reject_reason;
+};
+
+#define DSDB_CONTROL_PASSWORD_HASH_VALUES_OID "1.3.6.1.4.1.7165.4.3.9"
+
+#define DSDB_CONTROL_PASSWORD_CHANGE_OID "1.3.6.1.4.1.7165.4.3.10"
+struct dsdb_control_password_change {
+       const struct samr_Password *old_nt_pwd_hash;
+       const struct samr_Password *old_lm_pwd_hash;
+};
+
+/**
+   DSDB_CONTROL_APPLY_LINKS is internal to Samba4 - a token passed between repl_meta_data and linked_attributes modules
+*/
+#define DSDB_CONTROL_APPLY_LINKS "1.3.6.1.4.1.7165.4.3.11"
+
+/*
+ * this should only be used for importing users from Samba3
+ */
+#define DSDB_CONTROL_BYPASS_PASSWORD_HASH_OID "1.3.6.1.4.1.7165.4.3.12"
+
+/**
+  OID used to allow the replacement of replPropertyMetaData.
+  It is used when the current replmetadata needs to be edited.
+*/
+#define DSDB_CONTROL_CHANGEREPLMETADATA_OID "1.3.6.1.4.1.7165.4.3.14"
+
+/* passed when we want to get the behaviour of the non-global catalog port */
+#define DSDB_CONTROL_NO_GLOBAL_CATALOG "1.3.6.1.4.1.7165.4.3.17"
+
+/* passed when we want special behaviour for partial replicas */
+#define DSDB_CONTROL_PARTIAL_REPLICA "1.3.6.1.4.1.7165.4.3.18"
+
+/* passed when we want special behaviour for dbcheck */
+#define DSDB_CONTROL_DBCHECK "1.3.6.1.4.1.7165.4.3.19"
+
+/* passed when dbcheck wants to modify a read only replica (very special case) */
+#define DSDB_CONTROL_DBCHECK_MODIFY_RO_REPLICA "1.3.6.1.4.1.7165.4.3.19.1"
+
+/* passed when importing plain text password on upgrades */
+#define DSDB_CONTROL_PASSWORD_BYPASS_LAST_SET_OID "1.3.6.1.4.1.7165.4.3.20"
+
+/*
+ * passed from the descriptor module in order to
+ * store the recalucated nTSecurityDescriptor without
+ * modifying the replPropertyMetaData.
+ */
+#define DSDB_CONTROL_SEC_DESC_PROPAGATION_OID "1.3.6.1.4.1.7165.4.3.21"
 
 #define DSDB_EXTENDED_REPLICATED_OBJECTS_OID "1.3.6.1.4.1.7165.4.4.1"
 struct dsdb_extended_replicated_object {
        struct ldb_message *msg;
        struct ldb_val guid_value;
+       struct ldb_val parent_guid_value;
        const char *when_changed;
        struct replPropertyMetaDataBlob *meta_data;
+
+       /* Only used for internal processing in repl_meta_data */
+       struct ldb_dn *last_known_parent;
 };
 
 struct dsdb_extended_replicated_objects {
@@ -72,9 +152,12 @@ struct dsdb_extended_replicated_objects {
         * this is the version of the dsdb_extended_replicated_objects
         * version 0: initial implementation
         */
-#define DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION 0
+#define DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION 2
        uint32_t version;
 
+       /* DSDB_REPL_FLAG_* flags */
+       uint32_t dsdb_repl_flags;
+
        struct ldb_dn *partition_dn;
 
        const struct repsFromTo1 *source_dsa;
@@ -82,16 +165,14 @@ struct dsdb_extended_replicated_objects {
 
        uint32_t num_objects;
        struct dsdb_extended_replicated_object *objects;
-};
 
-struct dsdb_naming_fsmo {
-       bool we_are_master;
-       struct ldb_dn *master_dn;
+       uint32_t linked_attributes_count;
+       const struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
 };
 
-struct dsdb_pdc_fsmo {
-       bool we_are_master;
-       struct ldb_dn *master_dn;
+#define DSDB_EXTENDED_CREATE_PARTITION_OID "1.3.6.1.4.1.7165.4.4.4"
+struct dsdb_create_partition_exop {
+       struct ldb_dn *new_dn;
 };
 
 /*
@@ -100,4 +181,70 @@ struct dsdb_pdc_fsmo {
  */
 #define DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID "1.3.6.1.4.1.7165.4.4.2"
 
+#define DSDB_EXTENDED_SCHEMA_UPGRADE_IN_PROGRESS_OID "1.3.6.1.4.1.7165.4.4.6"
+
+#define DSDB_OPENLDAP_DEREFERENCE_CONTROL "1.3.6.1.4.1.4203.666.5.16"
+
+struct dsdb_openldap_dereference {
+       const char *source_attribute;
+       const char **dereference_attribute;
+};
+
+struct dsdb_openldap_dereference_control {
+       struct dsdb_openldap_dereference **dereference;
+};
+
+struct dsdb_openldap_dereference_result {
+       const char *source_attribute;
+       const char *dereferenced_dn;
+       int num_attributes;
+       struct ldb_message_element *attributes;
+};
+
+struct dsdb_openldap_dereference_result_control {
+       struct dsdb_openldap_dereference_result **attributes;
+};
+
+struct samldb_msds_intid_persistant {
+       uint32_t msds_intid;
+       uint64_t usn;
+};
+
+#define SAMLDB_MSDS_INTID_OPAQUE "SAMLDB_MSDS_INTID_OPAQUE"
+
+#define DSDB_PARTITION_DN "@PARTITION"
+#define DSDB_PARTITION_ATTR "partition"
+
+#define DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME "dsdb_extended_dn_store_format"
+struct dsdb_extended_dn_store_format {
+       bool store_extended_dn_in_ldb;
+};
+
+#define DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME "DSDB_OPAQUE_LAST_SCHEMA_UPDATE"
+#define DSDB_OPAQUE_PARTITION_MODULE_MSG_OPAQUE_NAME "DSDB_OPAQUE_PARTITION_MODULE_MSG"
+
+/* this takes a struct dsdb_fsmo_extended_op */
+#define DSDB_EXTENDED_ALLOCATE_RID_POOL "1.3.6.1.4.1.7165.4.4.5"
+
+struct dsdb_fsmo_extended_op {
+       uint64_t fsmo_info;
+       struct GUID destination_dsa_guid;
+};
+
+/*
+ * passed from the descriptor module in order to
+ * store the recalucated nTSecurityDescriptor without
+ * modifying the replPropertyMetaData.
+ */
+#define DSDB_EXTENDED_SEC_DESC_PROPAGATION_OID "1.3.6.1.4.1.7165.4.4.7"
+struct dsdb_extended_sec_desc_propagation_op {
+       struct ldb_dn *nc_root;
+       struct ldb_dn *dn;
+       bool include_self;
+};
+
+#define DSDB_ACL_CHECKS_DIRSYNC_FLAG 0x1
+#define DSDB_SAMDB_MINIMUM_ALLOWED_RID   1000
+
+#define DSDB_METADATA_SCHEMA_SEQ_NUM   "SCHEMA_SEQ_NUM"
 #endif /* __SAMDB_H__ */