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