s3-libnet-samsync: add samsync_ops to all samsync modules.
[samba.git] / source3 / libnet / libnet_samsync.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  libnet Support
4  *  Copyright (C) Guenther Deschner 2008
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 enum net_samsync_mode {
22         NET_SAMSYNC_MODE_FETCH_PASSDB = 0,
23         NET_SAMSYNC_MODE_FETCH_LDIF = 1,
24         NET_SAMSYNC_MODE_FETCH_KEYTAB = 2,
25         NET_SAMSYNC_MODE_DUMP = 3
26 };
27
28 struct samsync_context;
29
30 typedef NTSTATUS (*samsync_delta_fn_t)(TALLOC_CTX *,
31                                        enum netr_SamDatabaseID,
32                                        struct netr_DELTA_ENUM_ARRAY *,
33                                        bool,
34                                        struct samsync_context *);
35 struct samsync_ops {
36         NTSTATUS (*startup)(TALLOC_CTX *mem_ctx,
37                             struct samsync_context *ctx,
38                             enum netr_SamDatabaseID id,
39                             uint64_t *sequence_num);
40         NTSTATUS (*process_objects)(TALLOC_CTX *mem_ctx,
41                                     enum netr_SamDatabaseID id,
42                                     struct netr_DELTA_ENUM_ARRAY *array,
43                                     bool last_query,
44                                     struct samsync_context *ctx);
45         NTSTATUS (*finish)(TALLOC_CTX *mem_ctx,
46                            struct samsync_context *ctx,
47                            enum netr_SamDatabaseID id,
48                            uint64_t sequence_num);
49 };
50
51 struct samsync_object {
52         uint16_t database_id;
53         uint16_t object_type;
54         union {
55                 uint32_t rid;
56                 const char *name;
57                 struct dom_sid sid;
58         } object_identifier;
59 };
60
61 struct samsync_context {
62         enum net_samsync_mode mode;
63         const struct dom_sid *domain_sid;
64         const char *domain_sid_str;
65         const char *domain_name;
66         const char *output_filename;
67
68         const char *username;
69         const char *password;
70
71         char *result_message;
72         char *error_message;
73
74         bool single_object_replication;
75         bool force_full_replication;
76         bool clean_old_entries;
77
78         uint32_t num_objects;
79         struct samsync_object *objects;
80
81         struct rpc_pipe_client *cli;
82
83         const struct samsync_ops *ops;
84
85         samsync_delta_fn_t delta_fn;
86         void *private_data;
87 };
88
89 extern const struct samsync_ops libnet_samsync_ldif_ops;
90 extern const struct samsync_ops libnet_samsync_keytab_ops;
91 extern const struct samsync_ops libnet_samsync_display_ops;
92 extern const struct samsync_ops libnet_samsync_passdb_ops;
93
94 NTSTATUS fetch_sam_entries_ldif(TALLOC_CTX *mem_ctx,
95                                 enum netr_SamDatabaseID database_id,
96                                 struct netr_DELTA_ENUM_ARRAY *r,
97                                 bool last_query,
98                                 struct samsync_context *ctx);
99 NTSTATUS fetch_sam_entries(TALLOC_CTX *mem_ctx,
100                            enum netr_SamDatabaseID database_id,
101                            struct netr_DELTA_ENUM_ARRAY *r,
102                            bool last_query,
103                            struct samsync_context *ctx);
104 NTSTATUS display_sam_entries(TALLOC_CTX *mem_ctx,
105                              enum netr_SamDatabaseID database_id,
106                              struct netr_DELTA_ENUM_ARRAY *r,
107                              bool last_query,
108                              struct samsync_context *ctx);
109 NTSTATUS fetch_sam_entries_keytab(TALLOC_CTX *mem_ctx,
110                                   enum netr_SamDatabaseID database_id,
111                                   struct netr_DELTA_ENUM_ARRAY *r,
112                                   bool last_query,
113                                   struct samsync_context *ctx);