2
Unix SMB/CIFS mplementation.
4
DSDB replication service - FSMO role change
6
Copyright (C) Nadezhda Ivanova 2010
7
Copyright (C) Andrew Tridgell 2010
8
Copyright (C) Andrew Bartlett 2010
9
Copyright (C) Anatoliy Atanasov 2010
11
based on drepl_ridalloc.c
13
This program is free software; you can redistribute it and/or modify
14
it under the terms of the GNU General Public License as published by
15
the Free Software Foundation; either version 3 of the License, or
16
(at your option) any later version.
18
This program is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
23
You should have received a copy of the GNU General Public License
24
along with this program. If not, see <http://www.gnu.org/licenses/>.
29
#include "dsdb/samdb/samdb.h"
30
#include "smbd/service.h"
31
#include "dsdb/repl/drepl_service.h"
32
#include "param/param.h"
34
static void drepl_role_callback(struct dreplsrv_service *service,
36
enum drsuapi_DsExtendedError ext_err,
39
if (!W_ERROR_IS_OK(werr)) {
40
DEBUG(0,(__location__ ": Failed role transfer - %s - extended_ret[0x%X]\n",
41
win_errstr(werr), ext_err));
43
DEBUG(0,(__location__ ": Successful role transfer\n"));
47
static bool fsmo_master_cmp(struct ldb_dn *ntds_dn, struct ldb_dn *role_owner_dn)
49
if (ldb_dn_compare(ntds_dn, role_owner_dn) == 0) {
50
DEBUG(0,("\nWe are the FSMO master.\n"));
57
see which role is we are asked to assume, initialize data and send request
59
WERROR dreplsrv_fsmo_role_check(struct dreplsrv_service *service,
60
enum drepl_role_master role)
62
struct ldb_dn *role_owner_dn, *fsmo_role_dn, *ntds_dn;
63
TALLOC_CTX *tmp_ctx = talloc_new(service);
64
uint64_t fsmo_info = 0;
65
enum drsuapi_DsExtendedOperation extended_op = DRSUAPI_EXOP_NONE;
68
ntds_dn = samdb_ntds_settings_dn(service->samdb);
70
return WERR_DS_DRA_INTERNAL_ERROR;
73
werr = dsdb_get_fsmo_role_info(tmp_ctx, service->samdb, role,
74
&fsmo_role_dn, &role_owner_dn);
75
if (!W_ERROR_IS_OK(werr)) {
80
case DREPL_NAMING_MASTER:
81
case DREPL_INFRASTRUCTURE_MASTER:
82
case DREPL_SCHEMA_MASTER:
83
extended_op = DRSUAPI_EXOP_FSMO_REQ_ROLE;
85
case DREPL_RID_MASTER:
86
extended_op = DRSUAPI_EXOP_FSMO_RID_REQ_ROLE;
88
case DREPL_PDC_MASTER:
89
extended_op = DRSUAPI_EXOP_FSMO_REQ_PDC;
92
return WERR_DS_DRA_INTERNAL_ERROR;
95
if (fsmo_master_cmp(ntds_dn, role_owner_dn) ||
96
(extended_op == DRSUAPI_EXOP_NONE)) {
97
DEBUG(0,("FSMO role check failed for DN %s and owner %s ",
98
ldb_dn_get_linearized(fsmo_role_dn),
99
ldb_dn_get_linearized(role_owner_dn)));
103
werr = drepl_request_extended_op(service,
111
if (W_ERROR_IS_OK(werr)) {
112
dreplsrv_run_pending_ops(service);
114
DEBUG(0,("%s: drepl_request_extended_op() failed with %s",
115
__FUNCTION__, win_errstr(werr)));