winbindd: allow all possible logon levels in wb_irpc_SamLogon()
[sfrench/samba-autobuild/.git] / source3 / winbindd / winbindd_irpc.c
index 9a9f75373f1dc91de57e1fb8249094f1fb4d67ec..ccff769170a54e02a31ee499c66af8e94bdbafc5 100644 (file)
@@ -133,15 +133,48 @@ static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
                                 struct winbind_SamLogon *req)
 {
        struct winbindd_domain *domain;
-       const char *target_domain_name;
-       if (req->in.logon.network == NULL) {
+       struct netr_IdentityInfo *identity_info;
+       const char *target_domain_name = NULL;
+
+       switch (req->in.logon_level) {
+       case NetlogonInteractiveInformation:
+       case NetlogonServiceInformation:
+       case NetlogonInteractiveTransitiveInformation:
+       case NetlogonServiceTransitiveInformation:
+               if (req->in.logon.password == NULL) {
+                       return NT_STATUS_REQUEST_NOT_ACCEPTED;
+               }
+               identity_info = &req->in.logon.password->identity_info;
+               break;
+
+       case NetlogonNetworkInformation:
+       case NetlogonNetworkTransitiveInformation:
+               if (req->in.logon.network == NULL) {
+                       return NT_STATUS_REQUEST_NOT_ACCEPTED;
+               }
+
+               identity_info = &req->in.logon.network->identity_info;
+               break;
+
+       case NetlogonGenericInformation:
+               if (req->in.logon.generic == NULL) {
+                       return NT_STATUS_REQUEST_NOT_ACCEPTED;
+               }
+
+               identity_info = &req->in.logon.generic->identity_info;
+               break;
+
+       default:
                return NT_STATUS_REQUEST_NOT_ACCEPTED;
        }
-       target_domain_name = req->in.logon.network->identity_info.domain_name.string;
+
+       target_domain_name = identity_info->domain_name.string;
 
        domain = find_auth_domain(0, target_domain_name);
        if (domain == NULL) {
-               return NT_STATUS_NO_SUCH_USER;
+               req->out.result = NT_STATUS_NO_SUCH_USER;
+               req->out.authoritative = 0;
+               return NT_STATUS_OK;
        }
 
        DEBUG(5, ("wb_irpc_SamLogon called\n"));
@@ -253,6 +286,24 @@ static NTSTATUS wb_irpc_GetForestTrustInformation(struct irpc_message *msg,
                                        domain, 45 /* timeout */);
 }
 
+static NTSTATUS wb_irpc_SendToSam(struct irpc_message *msg,
+                                 struct winbind_SendToSam *req)
+{
+       /* TODO make sure that it is RWDC */
+       struct winbindd_domain *domain = find_our_domain();
+       if (domain == NULL) {
+               return NT_STATUS_NO_SUCH_DOMAIN;
+       }
+
+       DEBUG(5, ("wb_irpc_SendToSam called\n"));
+
+       return wb_irpc_forward_rpc_call(msg, msg,
+                                       winbind_event_context(),
+                                       req, NDR_WINBIND_SENDTOSAM,
+                                       "winbind_SendToSam",
+                                       domain, IRPC_CALL_TIMEOUT);
+}
+
 NTSTATUS wb_irpc_register(void)
 {
        NTSTATUS status;
@@ -279,6 +330,11 @@ NTSTATUS wb_irpc_register(void)
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
+       status = IRPC_REGISTER(winbind_imessaging_context(), winbind, WINBIND_SENDTOSAM,
+                              wb_irpc_SendToSam, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        return NT_STATUS_OK;
 }