s3:winbindd: add wb_irpc_GetForestTrustInformation()
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Jan 2015 12:32:37 +0000 (13:32 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 8 Jul 2015 16:38:22 +0000 (18:38 +0200)
This allows the netlogon server to forward netr_DrsGetForestTrustInformation()
to winbindd in order to do the work.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/winbindd/winbindd_irpc.c

index a30f9bf52fda1c1be43c2dcd7607c12f1ea42ad8..1f2d3adcba50b7b560eb6f14ffd07558c45217cb 100644 (file)
@@ -213,6 +213,46 @@ static NTSTATUS wb_irpc_LogonControl(struct irpc_message *msg,
                                        domain, 45 /* timeout */);
 }
 
+static NTSTATUS wb_irpc_GetForestTrustInformation(struct irpc_message *msg,
+                                    struct winbind_GetForestTrustInformation *req)
+{
+       struct winbindd_domain *domain = NULL;
+
+       if (req->in.trusted_domain_name == NULL) {
+               req->out.result = WERR_NO_SUCH_DOMAIN;
+               return NT_STATUS_OK;
+       }
+
+       domain = find_domain_from_name_noinit(req->in.trusted_domain_name);
+       if (domain == NULL) {
+               req->out.result = WERR_NO_SUCH_DOMAIN;
+               return NT_STATUS_OK;
+       }
+
+       /*
+        * checking for domain->internal and domain->primary
+        * makes sure we only do some work when running as DC.
+        */
+
+       if (domain->internal) {
+               req->out.result = WERR_NO_SUCH_DOMAIN;
+               return NT_STATUS_OK;
+       }
+
+       if (domain->primary) {
+               req->out.result = WERR_NO_SUCH_DOMAIN;
+               return NT_STATUS_OK;
+       }
+
+       DEBUG(5, ("wb_irpc_GetForestTrustInformation called\n"));
+
+       return wb_irpc_forward_rpc_call(msg, msg,
+                                       winbind_event_context(),
+                                       req, NDR_WINBIND_GETFORESTTRUSTINFORMATION,
+                                       "winbind_GetForestTrustInformation",
+                                       domain, 45 /* timeout */);
+}
+
 NTSTATUS wb_irpc_register(void)
 {
        NTSTATUS status;
@@ -233,6 +273,12 @@ NTSTATUS wb_irpc_register(void)
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
+       status = IRPC_REGISTER(winbind_imessaging_context(), winbind,
+                              WINBIND_GETFORESTTRUSTINFORMATION,
+                              wb_irpc_GetForestTrustInformation, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        return NT_STATUS_OK;
 }