1--- a/source3/rpc_server/rpc_ep_setup.c
2+++ b/source3/rpc_server/rpc_ep_setup.c
3@@ -409,6 +409,7 @@ static bool epmapper_shutdown_cb(void *p
4 	return true;
5 }
6 
7+#ifdef WINREG_SUPPORT
8 static bool winreg_init_cb(void *ptr)
9 {
10 	struct dcesrv_ep_context *ep_ctx =
11@@ -456,6 +457,7 @@ static bool winreg_init_cb(void *ptr)
12 
13 	return true;
14 }
15+#endif
16 
17 static bool srvsvc_init_cb(void *ptr)
18 {
19@@ -710,10 +712,12 @@ static bool svcctl_init_cb(void *ptr)
20 					   "epmapper",
21 					   "none");
22 
23+#ifdef WINREG_SUPPORT
24 	ok = svcctl_init_winreg(ep_ctx->msg_ctx);
25 	if (!ok) {
26 		return false;
27 	}
28+#endif
29 
30 	/* initialize the control hooks */
31 	init_service_op_table();
32@@ -785,10 +789,12 @@ static bool eventlog_init_cb(void *ptr)
33 					   "epmapper",
34 					   "none");
35 
36+#ifdef WINREG_SUPPORT
37 	ok = eventlog_init_winreg(ep_ctx->msg_ctx);
38 	if (!ok) {
39 		return false;
40 	}
41+#endif
42 
43 	if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
44 	    StrCaseCmp(rpcsrv_type, "daemon") == 0) {
45@@ -1077,12 +1083,14 @@ bool dcesrv_ep_setup(struct tevent_conte
46 		}
47 	}
48 
49+#ifdef WINREG_SUPPORT
50 	winreg_cb.init         = winreg_init_cb;
51 	winreg_cb.shutdown     = NULL;
52 	winreg_cb.private_data = ep_ctx;
53 	if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
54 		return false;
55 	}
56+#endif
57 
58 	srvsvc_cb.init         = srvsvc_init_cb;
59 	srvsvc_cb.shutdown     = NULL;
60--- a/source3/smbd/server_exit.c
61+++ b/source3/smbd/server_exit.c
62@@ -150,7 +150,9 @@ static void exit_server_common(enum serv
63 #endif
64 
65 		rpc_srvsvc_shutdown();
66+#ifdef WINREG_SUPPORT
67 		rpc_winreg_shutdown();
68+#endif
69 
70 		rpc_netlogon_shutdown();
71 		rpc_samr_shutdown();
72--- a/source3/librpc/rpc/rpc_common.c
73+++ b/source3/librpc/rpc/rpc_common.c
74@@ -112,9 +112,11 @@ static bool initialize_interfaces(void)
75 	if (!smb_register_ndr_interface(&ndr_table_wkssvc)) {
76 		return false;
77 	}
78+#ifdef WINREG_SUPPORT
79 	if (!smb_register_ndr_interface(&ndr_table_winreg)) {
80 		return false;
81 	}
82+#endif
83 #ifdef PRINTER_SUPPORT
84 	if (!smb_register_ndr_interface(&ndr_table_spoolss)) {
85 		return false;
86--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
87+++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
88@@ -95,9 +95,11 @@ bool init_service_op_table( void )
89 	svcctl_ops[i].ops  = &netlogon_svc_ops;
90 	i++;
91 
92+#ifdef WINREG_SUPPORT
93 	svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" );
94 	svcctl_ops[i].ops  = &winreg_svc_ops;
95 	i++;
96+#endif
97 
98 	svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" );
99 	svcctl_ops[i].ops  = &wins_svc_ops;
100--- a/source3/services/svc_winreg_glue.c
101+++ b/source3/services/svc_winreg_glue.c
102@@ -88,6 +88,10 @@ struct security_descriptor *svcctl_get_s
103 	NTSTATUS status;
104 	WERROR result = WERR_OK;
105 
106+#ifndef WINREG_SUPPORT
107+	return NULL;
108+#endif
109+
110 	key = talloc_asprintf(mem_ctx,
111 			      "%s\\%s\\Security",
112 			      TOP_LEVEL_SERVICES_KEY, name);
113@@ -161,6 +165,10 @@ bool svcctl_set_secdesc(struct messaging
114 	NTSTATUS status;
115 	WERROR result = WERR_OK;
116 
117+#ifndef WINREG_SUPPORT
118+	return false;
119+#endif
120+
121 	tmp_ctx = talloc_stackframe();
122 	if (tmp_ctx == NULL) {
123 		return false;
124@@ -272,6 +280,10 @@ const char *svcctl_get_string_value(TALL
125 	NTSTATUS status;
126 	WERROR result = WERR_OK;
127 
128+#ifndef WINREG_SUPPORT
129+	return NULL;
130+#endif
131+
132 	tmp_ctx = talloc_stackframe();
133 	if (tmp_ctx == NULL) {
134 		return NULL;
135--- a/source3/rpcclient/rpcclient.c
136+++ b/source3/rpcclient/rpcclient.c
137@@ -642,7 +642,9 @@ static struct cmd_set *rpcclient_command
138 	drsuapi_commands,
139 	eventlog_commands,
140 #endif
141+#ifdef WINREG_SUPPORT
142 	winreg_commands,
143+#endif
144 	NULL
145 };
146 
147