s4:dcesrv_samr - prevent "ldb_modify" on a possibly empty message
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Mon, 12 Oct 2009 22:48:15 +0000 (00:48 +0200)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Mon, 12 Oct 2009 22:53:47 +0000 (00:53 +0200)
In this code part under certain circumstances we can end up with an empty message.
Since our new behaviour denies them (like the real AD) we need to bypass them
on LDB modify calls.

source4/rpc_server/samr/dcesrv_samr.c

index b73add66c9ff16ccfe5323779c8a2b569b736555..00820a3ab26b1728fecde300bc8bce67a4a95d64 100644 (file)
@@ -3611,14 +3611,16 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL
        }
 
        /* modify the samdb record */
-       ret = ldb_modify(a_state->sam_ctx, msg);
-       if (ret != LDB_SUCCESS) {
-               DEBUG(1,("Failed to modify record %s: %s\n",
-                        ldb_dn_get_linearized(a_state->account_dn),
-                        ldb_errstring(a_state->sam_ctx)));
-
-               /* we really need samdb.c to return NTSTATUS */
-               return NT_STATUS_UNSUCCESSFUL;
+       if (msg->num_elements > 0) {
+               ret = ldb_modify(a_state->sam_ctx, msg);
+               if (ret != LDB_SUCCESS) {
+                       DEBUG(1,("Failed to modify record %s: %s\n",
+                                ldb_dn_get_linearized(a_state->account_dn),
+                                ldb_errstring(a_state->sam_ctx)));
+
+                       /* we really need samdb.c to return NTSTATUS */
+                       return NT_STATUS_UNSUCCESSFUL;
+               }
        }
 
        return NT_STATUS_OK;