1--- a/source3/rpc_server/rpc_ep_setup.c
2+++ b/source3/rpc_server/rpc_ep_setup.c
3@@ -881,6 +881,7 @@ static bool rpcecho_init_cb(void *ptr) {
4 
5 #endif
6 
7+#ifdef DFS_SUPPORT
8 static bool netdfs_init_cb(void *ptr)
9 {
10 	struct dcesrv_ep_context *ep_ctx =
11@@ -928,6 +929,7 @@ static bool netdfs_init_cb(void *ptr)
12 
13 	return true;
14 }
15+#endif
16 
17 #ifdef ACTIVE_DIRECTORY
18 static bool dssetup_init_cb(void *ptr)
19@@ -1173,12 +1175,14 @@ bool dcesrv_ep_setup(struct tevent_conte
20 		return false;
21 	}
22 
23+#ifdef DFS_SUPPORT
24 	netdfs_cb.init         = netdfs_init_cb;
25 	netdfs_cb.shutdown     = NULL;
26 	netdfs_cb.private_data = ep_ctx;
27 	if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
28 		return false;
29 	}
30+#endif
31 
32 #ifdef DEVELOPER
33 	rpcecho_cb.init         = rpcecho_init_cb;
34--- a/source3/librpc/rpc/rpc_common.c
35+++ b/source3/librpc/rpc/rpc_common.c
36@@ -122,9 +122,11 @@ static bool initialize_interfaces(void)
37 		return false;
38 	}
39 #endif
40+#ifdef DFS_SUPPORT
41 	if (!smb_register_ndr_interface(&ndr_table_netdfs)) {
42 		return false;
43 	}
44+#endif
45 #ifdef DEVELOPER
46 	if (!smb_register_ndr_interface(&ndr_table_rpcecho)) {
47 		return false;
48--- a/source3/smbd/server_exit.c
49+++ b/source3/smbd/server_exit.c
50@@ -138,7 +138,9 @@ static void exit_server_common(enum serv
51 #ifdef DEVELOPER
52 		rpc_rpcecho_shutdown();
53 #endif
54+#ifdef DFS_SUPPORT
55 		rpc_netdfs_shutdown();
56+#endif
57 		rpc_initshutdown_shutdown();
58 #ifdef EXTRA_SERVICES
59 		rpc_eventlog_shutdown();
60--- a/source3/rpcclient/rpcclient.c
61+++ b/source3/rpcclient/rpcclient.c
62@@ -629,7 +629,9 @@ static struct cmd_set *rpcclient_command
63 #endif
64 	netlogon_commands,
65 	srvsvc_commands,
66+#ifdef DFS_SUPPORT
67 	dfs_commands,
68+#endif
69 #ifdef DEVELOPER
70 	echo_commands,
71 #endif
72