r17968: Consolidate the DSSETUP and LSA pipes into a single file, as DSSETUP
authorAndrew Bartlett <abartlet@samba.org>
Thu, 31 Aug 2006 13:10:11 +0000 (13:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:16:59 +0000 (14:16 -0500)
is just one call.

This simplifies the one remaining DSSETUP call, and removes another
user of the dnsDomain attribute.

Andrew Bartlett
(This used to be commit 6a54711564b67891c368c09ead3f7389ad40111f)

source4/rpc_server/config.mk
source4/rpc_server/dssetup/dcesrv_dssetup.c [deleted file]
source4/rpc_server/lsa/dcesrv_lsa.c

index 292a86de5b5a2621332298de4391b10b69f78989..23245218a4299d7a3c7abff4a4a550a7a974f44b 100644 (file)
@@ -133,7 +133,7 @@ PUBLIC_DEPENDENCIES = \
 ################################################
 # Start MODULE dcerpc_lsa
 [MODULE::dcerpc_lsarpc]
-INIT_FUNCTION = dcerpc_server_lsarpc_init
+INIT_FUNCTION = dcerpc_server_lsa_init
 SUBSYSTEM = dcerpc_server
 OBJ_FILES = \
                lsa/dcesrv_lsa.o
@@ -174,20 +174,6 @@ PUBLIC_DEPENDENCIES = \
 # End MODULE dcerpc_drsuapi
 ################################################
 
-################################################
-# Start MODULE dcerpc_dssetup
-[MODULE::dcerpc_dssetup]
-INIT_FUNCTION = dcerpc_server_dssetup_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
-               dssetup/dcesrv_dssetup.o
-PUBLIC_DEPENDENCIES = \
-               SAMDB \
-               DCERPC_COMMON \
-               NDR_DSSETUP
-# End MODULE dcerpc_dssetup
-################################################
-
 ################################################
 # Start SUBSYSTEM dcerpc_server
 [MODULE::dcerpc_server]
@@ -204,7 +190,6 @@ PUBLIC_DEPENDENCIES = \
                LIBCLI_AUTH \
                LIBNDR \
                dcerpc
-               
 #
 # End SUBSYSTEM DCERPC
 ################################################
diff --git a/source4/rpc_server/dssetup/dcesrv_dssetup.c b/source4/rpc_server/dssetup/dcesrv_dssetup.c
deleted file mode 100644 (file)
index 582b1f6..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-
-   endpoint server for the dssetup pipe
-
-   Copyright (C) Andrew Tridgell 2004
-   
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "rpc_server/dcerpc_server.h"
-#include "librpc/gen_ndr/ndr_samr.h"
-#include "librpc/gen_ndr/ndr_dssetup.h"
-#include "rpc_server/common/common.h"
-#include "ldb/include/ldb.h"
-#include "dsdb/samdb/samdb.h"
-#include "db_wrap.h"
-/* 
-  dssetup_DsRoleGetPrimaryDomainInformation 
-*/
-static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call, 
-                                                       TALLOC_CTX *mem_ctx,
-                                                       struct dssetup_DsRoleGetPrimaryDomainInformation *r)
-{
-       union dssetup_DsRoleInfo *info;
-
-       info = talloc(mem_ctx, union dssetup_DsRoleInfo);
-       W_ERROR_HAVE_NO_MEMORY(info);
-
-       switch (r->in.level) {
-       case DS_ROLE_BASIC_INFORMATION:
-       {
-               void *sam_ctx;
-               const char * const attrs[] = { "dnsDomain", "nTMixedDomain", "objectGUID", "name", NULL };
-               int ret;
-               struct ldb_message **res;
-               enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
-               uint32_t flags = 0;
-               const char *domain = NULL;
-               const char *dns_domain = NULL;
-               const char *forest = NULL;
-               struct GUID domain_guid;
-
-               ZERO_STRUCT(domain_guid);
-
-               switch (lp_server_role()) {
-               case ROLE_STANDALONE:
-                       role            = DS_ROLE_STANDALONE_SERVER;
-                       break;
-               case ROLE_DOMAIN_MEMBER:
-                       role            = DS_ROLE_MEMBER_SERVER;
-                       break;
-               case ROLE_DOMAIN_BDC:
-                       role            = DS_ROLE_BACKUP_DC;
-                       break;
-               case ROLE_DOMAIN_PDC:
-                       role            = DS_ROLE_PRIMARY_DC;
-                       break;
-               }
-
-               switch (lp_server_role()) {
-               case ROLE_STANDALONE:
-                       domain          = talloc_strdup(mem_ctx, lp_workgroup());
-                       W_ERROR_HAVE_NO_MEMORY(domain);
-                       break;
-               case ROLE_DOMAIN_MEMBER:
-                       domain          = talloc_strdup(mem_ctx, lp_workgroup());
-                       W_ERROR_HAVE_NO_MEMORY(domain);
-                       /* TODO: what is with dns_domain and forest and guid? */
-                       break;
-               case ROLE_DOMAIN_BDC:
-               case ROLE_DOMAIN_PDC:
-                       sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info); 
-                       if (!sam_ctx) {
-                               return WERR_SERVER_UNAVAILABLE;
-                       }
-
-                       ret = gendb_search_dn(sam_ctx, mem_ctx, NULL, &res, attrs);
-                       if (ret != 1) {
-                               return WERR_SERVER_UNAVAILABLE;
-                       }
-
-                       flags           = DS_ROLE_PRIMARY_DS_RUNNING;
-
-                       if (samdb_result_uint(res[0], "nTMixedDomain", 0) == 1) {
-                               flags   |= DS_ROLE_PRIMARY_DS_MIXED_MODE;
-                       }
-                       
-                       domain          = samdb_search_string(sam_ctx, mem_ctx, NULL, "nETBIOSName", 
-                                                             "(&(objectclass=crossRef)(ncName=%s))", 
-                                                             ldb_dn_linearize(mem_ctx, samdb_base_dn(sam_ctx)));
-       
-                       dns_domain      = samdb_result_string(res[0], "dnsDomain", NULL);
-                       forest          = samdb_result_string(res[0], "dnsDomain", NULL);
-
-                       domain_guid     = samdb_result_guid(res[0], "objectGUID");
-                       flags   |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
-                       break;
-               }
-
-               info->basic.role        = role; 
-               info->basic.flags       = flags;
-               info->basic.domain      = domain;
-               info->basic.dns_domain  = dns_domain;
-               info->basic.forest      = forest;
-               info->basic.domain_guid = domain_guid;
-
-               r->out.info = info;
-               return WERR_OK;
-       }
-       case DS_ROLE_UPGRADE_STATUS:
-       {
-               info->upgrade.upgrading     = DS_ROLE_NOT_UPGRADING;
-               info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
-
-               r->out.info = info;
-               return WERR_OK;
-       }
-       case DS_ROLE_OP_STATUS:
-       {
-               info->opstatus.status = DS_ROLE_OP_IDLE;
-
-               r->out.info = info;
-               return WERR_OK;
-       }
-       default:
-               return WERR_INVALID_PARAM;
-       }
-
-       return WERR_INVALID_PARAM;
-}
-
-
-/*****************************************
-NOTE! The remaining calls below were
-removed in w2k3, so the DCESRV_FAULT()
-replies are the correct implementation. Do
-not try and fill these in with anything else
-******************************************/
-
-/* 
-  dssetup_DsRoleDnsNameToFlatName 
-*/
-static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                       struct dssetup_DsRoleDnsNameToFlatName *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleDcAsDc 
-*/
-static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                            struct dssetup_DsRoleDcAsDc *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleDcAsReplica 
-*/
-static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                 struct dssetup_DsRoleDcAsReplica *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleDemoteDc 
-*/
-static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                              struct dssetup_DsRoleDemoteDc *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleGetDcOperationProgress 
-*/
-static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                            struct dssetup_DsRoleGetDcOperationProgress *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleGetDcOperationResults 
-*/
-static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                           struct dssetup_DsRoleGetDcOperationResults *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleCancel 
-*/
-static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                            struct dssetup_DsRoleCancel *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleServerSaveStateForUpgrade 
-*/
-static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                               struct dssetup_DsRoleServerSaveStateForUpgrade *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleUpgradeDownlevelServer 
-*/
-static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                            struct dssetup_DsRoleUpgradeDownlevelServer *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* 
-  dssetup_DsRoleAbortDownlevelServerUpgrade 
-*/
-static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                                                 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
-{
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
-}
-
-
-/* include the generated boilerplate */
-#include "librpc/gen_ndr/ndr_dssetup_s.c"
index 5b3de2c22b2150a1749a47b30e0b06935bfafe21..a3157e74a58789daa653c057204baab03dedb2ea 100644 (file)
@@ -32,6 +32,7 @@
 #include "libcli/auth/libcli_auth.h"
 #include "passdb/secrets.h"
 #include "db_wrap.h"
+#include "librpc/gen_ndr/ndr_dssetup.h"
 
 /*
   this type allows us to distinguish handle types
@@ -59,6 +60,7 @@ struct lsa_policy_state {
        struct dom_sid *domain_sid;
        struct GUID domain_guid;
        struct dom_sid *builtin_sid;
+       int mixed_domain;
 };
 
 
@@ -274,6 +276,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
        const char *dom_attrs[] = {
                "objectSid", 
                "objectGUID", 
+               "nTMixedDomain",
                NULL
        };
        struct ldb_result *ref_res;
@@ -330,6 +333,8 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
                return NT_STATUS_NO_SUCH_DOMAIN;                
        }
 
+       state->mixed_domain = ldb_msg_find_attr_as_uint(dom_res->msgs[0], "nTMixedDomain", 0);
+
        talloc_free(dom_res);
 
        ref_filter = talloc_asprintf(state, "(&(objectclass=crossRef)(ncName=%s))", 
@@ -388,6 +393,110 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
        return NT_STATUS_OK;
 }
 
+/* 
+  dssetup_DsRoleGetPrimaryDomainInformation 
+*/
+static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call, 
+                                                TALLOC_CTX *mem_ctx,
+                                                struct dssetup_DsRoleGetPrimaryDomainInformation *r)
+{
+       union dssetup_DsRoleInfo *info;
+
+       info = talloc(mem_ctx, union dssetup_DsRoleInfo);
+       W_ERROR_HAVE_NO_MEMORY(info);
+
+       switch (r->in.level) {
+       case DS_ROLE_BASIC_INFORMATION:
+       {
+               enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
+               uint32_t flags = 0;
+               const char *domain = NULL;
+               const char *dns_domain = NULL;
+               const char *forest = NULL;
+               struct GUID domain_guid;
+               struct lsa_policy_state *state;
+
+               NTSTATUS status = lsa_get_policy_state(dce_call, mem_ctx, &state);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return ntstatus_to_werror(status);
+               }
+
+               ZERO_STRUCT(domain_guid);
+
+               switch (lp_server_role()) {
+               case ROLE_STANDALONE:
+                       role            = DS_ROLE_STANDALONE_SERVER;
+                       break;
+               case ROLE_DOMAIN_MEMBER:
+                       role            = DS_ROLE_MEMBER_SERVER;
+                       break;
+               case ROLE_DOMAIN_BDC:
+                       role            = DS_ROLE_BACKUP_DC;
+                       break;
+               case ROLE_DOMAIN_PDC:
+                       role            = DS_ROLE_PRIMARY_DC;
+                       break;
+               }
+
+               switch (lp_server_role()) {
+               case ROLE_STANDALONE:
+                       domain          = talloc_strdup(mem_ctx, lp_workgroup());
+                       W_ERROR_HAVE_NO_MEMORY(domain);
+                       break;
+               case ROLE_DOMAIN_MEMBER:
+                       domain          = talloc_strdup(mem_ctx, lp_workgroup());
+                       W_ERROR_HAVE_NO_MEMORY(domain);
+                       /* TODO: what is with dns_domain and forest and guid? */
+                       break;
+               case ROLE_DOMAIN_BDC:
+               case ROLE_DOMAIN_PDC:
+                       flags           = DS_ROLE_PRIMARY_DS_RUNNING;
+
+                       if (state->mixed_domain == 1) {
+                               flags   |= DS_ROLE_PRIMARY_DS_MIXED_MODE;
+                       }
+                       
+                       domain          = state->domain_name;
+                       dns_domain      = state->domain_dns;
+                       forest          = state->domain_dns;
+
+                       domain_guid     = state->domain_guid;
+                       flags   |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
+                       break;
+               }
+
+               info->basic.role        = role; 
+               info->basic.flags       = flags;
+               info->basic.domain      = domain;
+               info->basic.dns_domain  = dns_domain;
+               info->basic.forest      = forest;
+               info->basic.domain_guid = domain_guid;
+
+               r->out.info = info;
+               return WERR_OK;
+       }
+       case DS_ROLE_UPGRADE_STATUS:
+       {
+               info->upgrade.upgrading     = DS_ROLE_NOT_UPGRADING;
+               info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
+
+               r->out.info = info;
+               return WERR_OK;
+       }
+       case DS_ROLE_OP_STATUS:
+       {
+               info->opstatus.status = DS_ROLE_OP_IDLE;
+
+               r->out.info = info;
+               return WERR_OK;
+       }
+       default:
+               return WERR_INVALID_PARAM;
+       }
+
+       return WERR_INVALID_PARAM;
+}
+
 /* 
   lsa_OpenPolicy2
 */
@@ -3299,3 +3408,130 @@ static NTSTATUS lsa_LSARADTREPORTSECURITYEVENT(struct dcesrv_call_state *dce_cal
 
 /* include the generated boilerplate */
 #include "librpc/gen_ndr/ndr_lsa_s.c"
+
+
+
+/*****************************************
+NOTE! The remaining calls below were
+removed in w2k3, so the DCESRV_FAULT()
+replies are the correct implementation. Do
+not try and fill these in with anything else
+******************************************/
+
+/* 
+  dssetup_DsRoleDnsNameToFlatName 
+*/
+static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                       struct dssetup_DsRoleDnsNameToFlatName *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleDcAsDc 
+*/
+static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                            struct dssetup_DsRoleDcAsDc *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleDcAsReplica 
+*/
+static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                 struct dssetup_DsRoleDcAsReplica *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleDemoteDc 
+*/
+static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                              struct dssetup_DsRoleDemoteDc *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleGetDcOperationProgress 
+*/
+static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                            struct dssetup_DsRoleGetDcOperationProgress *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleGetDcOperationResults 
+*/
+static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                           struct dssetup_DsRoleGetDcOperationResults *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleCancel 
+*/
+static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                            struct dssetup_DsRoleCancel *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleServerSaveStateForUpgrade 
+*/
+static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                               struct dssetup_DsRoleServerSaveStateForUpgrade *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleUpgradeDownlevelServer 
+*/
+static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                            struct dssetup_DsRoleUpgradeDownlevelServer *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* 
+  dssetup_DsRoleAbortDownlevelServerUpgrade 
+*/
+static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                                                 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
+{
+       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+}
+
+
+/* include the generated boilerplate */
+#include "librpc/gen_ndr/ndr_dssetup_s.c"
+
+NTSTATUS dcerpc_server_lsa_init(void)
+{
+       NTSTATUS ret;
+       
+       ret = dcerpc_server_dssetup_init();
+       if (!NT_STATUS_IS_OK(ret)) {
+               return ret;
+       }
+       ret = dcerpc_server_lsarpc_init();
+       if (!NT_STATUS_IS_OK(ret)) {
+               return ret;
+       }
+       return ret;
+}