diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am
index 7b9ad6ec6a9085176cf9596cce9630e87e1b6561..9f7d1a85f1f9b6a7a9d72839ae85d614ffffa017 100644
--- a/testsuite/expect/Makefile.am
+++ b/testsuite/expect/Makefile.am
@@ -511,6 +511,7 @@ EXTRA_DIST = \
 	test21.35			\
 	test21.36			\
 	test21.37			\
+	test21.38			\
 	inc21.30.1                      \
 	inc21.30.2                      \
 	inc21.30.3                      \
diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in
index fa3bebaa163faa9fbe58c7bf2012193fe2555029..dade8d2556830993f833c7075918a464040081c2 100644
--- a/testsuite/expect/Makefile.in
+++ b/testsuite/expect/Makefile.in
@@ -935,6 +935,7 @@ EXTRA_DIST = \
 	test21.35			\
 	test21.36			\
 	test21.37			\
+	test21.38			\
 	inc21.30.1                      \
 	inc21.30.2                      \
 	inc21.30.3                      \
diff --git a/testsuite/expect/README b/testsuite/expect/README
index 41a7bc57a36b65c34fbf7a2f101532d52c9fa991..5b314ecc0408244c4b372c6328d77758c291a05e 100644
--- a/testsuite/expect/README
+++ b/testsuite/expect/README
@@ -674,6 +674,7 @@ test21.34  Validate that partition and job qos limits are enforced
 test21.35  Validate DenyOnLimit QoS flag is enforced on QoS and Associations.
 test21.36  Validate that sacctmgr lost jobs fixes lost jobs.
 test21.37  sacctmgr show stats
+test21.38  sacctmgr modify limits for nested accounts with multiple users
 
 test22.#   Testing of sreport commands and options.
 	   These also test the sacctmgr archive dump/load functions.
diff --git a/testsuite/expect/globals_accounting b/testsuite/expect/globals_accounting
index 7d8354ef133b2b6c0335a8654ba72cdef4f4e3c4..00b6d18259322d824323f9eb4861295a5bbe8652 100644
--- a/testsuite/expect/globals_accounting
+++ b/testsuite/expect/globals_accounting
@@ -412,19 +412,20 @@ proc remove_acct { cluster name } {
 #
 ########################################################################
 #
-# IN: acct_mod_desc_in - consist of the cluster,
+# IN: name - name of acct to modify
+#
+#     acct_mod_desc_in - consist of the cluster,
 #     description, organization, and parent.
 #     Stuff before the where.
 #
-#     acct_mod_acct_vals_in - account values consist of parent,
-#     organization, description
-#
 #     acct_mod_assoc_vals_in - association consist of
 #     fairshare, grpcpumin, grpcpurunmins, grpcpu, grpjob
 #     grpmemory, grpnode, grpsubmit, grpwall, maxcpumin
 #     maxcpu, maxjob, maxnode, maxsubmit, maxwall. Stuff
 #     after the set
 #
+#     acct_mod_acct_vals_in - account values consist of parent,
+#     organization, description
 ########################################################################
 proc mod_acct { name acct_mod_desc_in acct_mod_assoc_vals_in acct_mod_acct_vals_in } {
 
diff --git a/testsuite/expect/test21.38 b/testsuite/expect/test21.38
new file mode 100755
index 0000000000000000000000000000000000000000..af3a2b0e48fa113f298edbaff8aa7f1b26ecc670
--- /dev/null
+++ b/testsuite/expect/test21.38
@@ -0,0 +1,256 @@
+#!/usr/bin/env expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          sacctmgr modify limits for nested accounts with multiple users
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2017 SchedMD LLC.
+# Written by Marshall Garey <marshall@schedmd.com>
+#
+# This file is part of SLURM, a resource management program.
+# For details, see <https://slurm.schedmd.com/>.
+# Please also read the included file: DISCLAIMER.
+#
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals_accounting
+
+set test_id     "21.38"
+set exit_code   0
+set tc1         "test$test_id-cluster-1"
+set ta1         "test$test_id-account.1"
+set ta2         "test$test_id-account.2"
+set ta3         "test$test_id-account.3"
+set tu1         "test$test_id-user.1"
+set tu2         "test$test_id-user.2"
+set cpusval1    2
+set cpusval2    3
+set nodesval    5
+set access_err  0
+
+# Cluster
+array set clus_req {}
+
+# Accounts
+array set acct_req {}
+set acct_req(cluster) $tc1
+
+# User
+array set user_req {}
+set user_req(cluster) $tc1
+set user_req(account) $ta1,$ta2,$ta3
+
+# Mod account 1
+array set acct_mod_desc {}
+set acct_mod_desc(cluster) $tc1
+array set acct_mod_acct_vals {}
+array set acct_mod_assoc_vals {}
+set acct_mod_assoc_vals(parent) $ta1
+
+# Mod account 2
+array set acct_mod_desc2 {}
+array set acct_mod_acct_vals2 {}
+array set acct_mod_assoc_vals2 {}
+set acct_mod_assoc_vals2(maxcpus) $cpusval1
+
+# Mod account 3
+array set acct_mod_desc3 {}
+array set acct_mod_acct_vals3 {}
+array set acct_mod_assoc_vals3 {}
+set acct_mod_assoc_vals3(maxcpus) $cpusval2
+
+# Mod account 4
+array set acct_mod_desc4 {}
+array set acct_mod_acct_vals4 {}
+array set acct_mod_assoc_vals4 {}
+set acct_mod_assoc_vals4(maxnodes) $nodesval
+
+# Mod User 1
+array set user_mod_info {}
+set user_mod_info(cluster) $tc1
+array set user_mod_acct {
+	adminlevel    Operator
+}
+set user_mod_acct(defaultaccount) $ta2
+array set user_mod_assoc {}
+
+proc _clean_exit { exit_code } {
+	variable tu1
+	variable tu2
+	variable ta1
+	variable ta2
+	variable ta3
+	variable tc1
+	variable access_err
+	variable test_id
+
+	# Clean up and print success or failure.
+	incr exit_code [remove_user "" "" "$tu1,$tu2"]
+	incr exit_code [remove_acct "" "$ta1,$ta2,$ta3"]
+	incr exit_code [remove_cluster "$tc1"]
+	if {$exit_code == 0} {
+		print_success $test_id
+	} else {
+		send_user "\nFAILURE\n"
+	}
+	exit $exit_code
+}
+
+#
+# Check accounting config and bail if not found.
+#
+if { [test_account_storage] == 0 } {
+	send_user "\nWARNING: This test can't be run without a usable AccountStorageType\n"
+	exit 0
+}
+
+# Make sure we have a clean system
+remove_user "" "" "$tu1,$tu2"
+remove_acct "" "$ta1,$ta2"
+remove_cluster "$tc1"
+if {$access_err != 0} {
+	send_user "\nWARNING: not authorized to perform this test\n"
+	exit $exit_code
+}
+
+# Add the cluster
+incr exit_code [add_cluster "$tc1" [array get clus_req]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Add the accounts (3 of them)
+incr exit_code [add_acct "$ta1,$ta2,$ta3" [array get acct_req]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Add the users (2 of them)
+incr exit_code [add_user "$tu1,$tu2" [array get user_req]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Modify the 2nd and 3rd accounts - make them children of the first
+# No need to check the changes. This is done in a different test.
+incr exit_code [mod_acct "$ta2,$ta3" [array get acct_mod_desc] [array get acct_mod_assoc_vals] [array get acct_mod_acct_vals]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Modify the top account (give it TRESlimit=cpu=number)
+incr exit_code [mod_acct "$ta1" [array get acct_mod_desc2] [array get acct_mod_assoc_vals2] [array get acct_mod_acct_vals2]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Check the changes
+set matches 0
+set my_pid [spawn $sacctmgr -n -P list assoc account=$ta1,$ta2,$ta3 format="account,user,maxtres"]
+expect {
+	-re "There was a problem" {
+		send_user "FAILURE: there was a problem with the sacctmgr command\n"
+		incr exit_code
+	}
+	-re "(($ta1|$ta2|$ta3)\\|($tu1|$tu2){0,6}\\|cpu=$cpusval1)" {
+		incr matches
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr list associations not responding\n"
+		slow_kill $my_pid
+		incr exit_code
+	}
+	eof {
+		wait
+	}
+}
+if {$matches != 9} {
+	send_user "\nFAILURE:  Account modification 1 incorrect with only $matches out of 9.\n\n"
+	incr exit_code
+	[_clean_exit $exit_code]
+}
+
+# Modify the child account (give it TRESlimit=cpu)
+incr exit_code [mod_acct "$ta2" [array get acct_mod_desc3] [array get acct_mod_assoc_vals3] [array get acct_mod_acct_vals3]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Check the changes
+set matches 0
+set my_pid [spawn $sacctmgr -n -P list assoc account=$ta1,$ta2,$ta3 format="account,user,maxtres"]
+expect {
+	-re "There was a problem" {
+		send_user "FAILURE: there was a problem with the sacctmgr list assoc command\n"
+		incr exit_code
+	}
+	-re "(($ta1|$ta3)\\|($tu1|$tu2){0,6}\\|cpu=$cpusval1)|($ta2\\|($tu1|$tu2){0,6}\\|cpu=$cpusval2)" {
+		incr matches
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE:sacctmgr list associations not responding\n\n"
+		slow_kill $my_pid
+		incr exit_code
+		[_clean_exit $exit_code]
+	}
+	eof {
+		wait
+	}
+}
+if {$matches != 9} {
+	send_user "\nFAILURE:  Account modification 2 incorrect with only $matches out of 9.\n\n"
+	incr exit_code
+	[_clean_exit $exit_code]
+}
+
+# Modify the child accounts (give them TRESlimit=node_limit)
+incr exit_code [mod_acct "$ta2,$ta3" [array get acct_mod_desc4] [array get acct_mod_assoc_vals4] [array get acct_mod_acct_vals4]]
+if { $exit_code } {
+	[_clean_exit $exit_code]
+}
+
+# Check the changes
+set matches 0
+set my_pid [spawn $sacctmgr -n -P list assoc account=$ta1,$ta2,$ta3 format="account,user,maxtres"]
+expect {
+	-re "There was a problem" {
+		send_user "FAILURE: there was a problem with the sacctmgr list assoc command\n"
+		incr exit_code
+	}
+	-re "($ta1\\|($tu1|$tu2){0,6}\\|cpu=$cpusval1)|($ta2\\|($tu1|$tu2){0,6}\\|cpu=$cpusval2,node=$nodesval)|($ta3\\|($tu1|$tu2){0,6}\\|cpu=$cpusval1,node=$nodesval)" {
+		incr matches
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE:sacctmgr list associations not responding\n\n"
+		slow_kill $my_pid
+		incr exit_code
+	}
+	eof {
+		wait
+	}
+}
+if {$matches != 9} {
+	send_user "\nFAILURE:  Account modification 3 incorrect with only $matches out of 9.\n\n"
+	incr exit_code
+	[_clean_exit $exit_code]
+}
+
+[_clean_exit $exit_code]