--- a/source3/librpc/rpc/rpc_common.c
+++ b/source3/librpc/rpc/rpc_common.c
@@ -95,9 +95,11 @@ static bool initialize_interfaces(void)
 	if (!smb_register_ndr_interface(&ndr_table_lsarpc)) {
 		return false;
 	}
+#ifdef ACTIVE_DIRECTORY
 	if (!smb_register_ndr_interface(&ndr_table_dssetup)) {
 		return false;
 	}
+#endif
 	if (!smb_register_ndr_interface(&ndr_table_samr)) {
 		return false;
 	}
@@ -141,9 +143,11 @@ static bool initialize_interfaces(void)
 	if (!smb_register_ndr_interface(&ndr_table_epmapper)) {
 		return false;
 	}
+#ifdef ACTIVE_DIRECTORY
 	if (!smb_register_ndr_interface(&ndr_table_drsuapi)) {
 		return false;
 	}
+#endif
 	return true;
 }
 
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -918,6 +918,7 @@ static bool netdfs_init_cb(void *ptr)
 	return true;
 }
 
+#ifdef ACTIVE_DIRECTORY
 static bool dssetup_init_cb(void *ptr)
 {
 	struct dcesrv_ep_context *ep_ctx =
@@ -966,6 +967,7 @@ static bool dssetup_init_cb(void *ptr)
 
 	return true;
 }
+#endif
 
 static bool wkssvc_init_cb(void *ptr)
 {
@@ -1172,12 +1174,14 @@ bool dcesrv_ep_setup(struct tevent_conte
 	}
 #endif
 
+#ifdef ACTIVE_DIRECTORY
 	dssetup_cb.init         = dssetup_init_cb;
 	dssetup_cb.shutdown     = NULL;
 	dssetup_cb.private_data = ep_ctx;
 	if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
 		return false;
 	}
+#endif
 
 	wkssvc_cb.init         = wkssvc_init_cb;
 	wkssvc_cb.shutdown     = NULL;
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -133,7 +133,9 @@ static void exit_server_common(enum serv
 
 	if (am_parent) {
 		rpc_wkssvc_shutdown();
+#ifdef ACTIVE_DIRECTORY
 		rpc_dssetup_shutdown();
+#endif
 #ifdef DEVELOPER
 		rpc_rpcecho_shutdown();
 #endif
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -2874,12 +2874,14 @@ NTSTATUS cli_rpc_pipe_open_noauth_transp
 	status = rpc_pipe_bind(result, auth);
 	if (!NT_STATUS_IS_OK(status)) {
 		int lvl = 0;
+#ifdef ACTIVE_DIRECTORY
 		if (ndr_syntax_id_equal(interface,
 					&ndr_table_dssetup.syntax_id)) {
 			/* non AD domains just don't have this pipe, avoid
 			 * level 0 statement in that case - gd */
 			lvl = 3;
 		}
+#endif
 		DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe "
 			    "%s failed with error %s\n",
 			    get_pipe_name_from_syntax(talloc_tos(), interface),
