s3-libnet: better separate headers.
[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 struct samsync_ops {
31         NTSTATUS (*startup)(TALLOC_CTX *mem_ctx,
32                             struct samsync_context *ctx,
33                             enum netr_SamDatabaseID id,
34                             uint64_t *sequence_num);
35         NTSTATUS (*process_objects)(TALLOC_CTX *mem_ctx,
36                                     enum netr_SamDatabaseID id,
37                                     struct netr_DELTA_ENUM_ARRAY *array,
38                                     uint64_t *sequence_num,
39                                     struct samsync_context *ctx);
40         NTSTATUS (*finish)(TALLOC_CTX *mem_ctx,
41                            struct samsync_context *ctx,
42                            enum netr_SamDatabaseID id,
43                            uint64_t sequence_num);
44 };
45
46 struct samsync_object {
47         uint16_t database_id;
48         uint16_t object_type;
49         union {
50                 uint32_t rid;
51                 const char *name;
52                 struct dom_sid sid;
53         } object_identifier;
54 };
55
56 struct samsync_context {
57         enum net_samsync_mode mode;
58         const struct dom_sid *domain_sid;
59         const char *domain_sid_str;
60         const char *domain_name;
61         const char *output_filename;
62
63         const char *username;
64         const char *password;
65
66         char *result_message;
67         char *error_message;
68
69         bool single_object_replication;
70         bool force_full_replication;
71         bool clean_old_entries;
72
73         uint32_t num_objects;
74         struct samsync_object *objects;
75
76         struct rpc_pipe_client *cli;
77
78         const struct samsync_ops *ops;
79
80         void *private_data;
81 };
82
83 extern const struct samsync_ops libnet_samsync_ldif_ops;
84 extern const struct samsync_ops libnet_samsync_keytab_ops;
85 extern const struct samsync_ops libnet_samsync_display_ops;
86 extern const struct samsync_ops libnet_samsync_passdb_ops;
87
88 /* The following definitions come from libnet/libnet_samsync.c  */
89
90 NTSTATUS libnet_samsync_init_context(TALLOC_CTX *mem_ctx,
91                                      const struct dom_sid *domain_sid,
92                                      struct samsync_context **ctx_p);
93 NTSTATUS libnet_samsync(enum netr_SamDatabaseID database_id,
94                         struct samsync_context *ctx);
95 NTSTATUS pull_netr_AcctLockStr(TALLOC_CTX *mem_ctx,
96                                struct lsa_BinaryString *r,
97                                struct netr_AcctLockStr **str_p);