Index: source/smbd/service.c
===================================================================
--- source/smbd/service.c	(revision 16676)
+++ source/smbd/service.c	(working copy)
@@ -763,6 +763,11 @@
 		smb_panic("make_connection: PANIC ERROR. Called as nonroot\n");
 	}
 
+	if (conn_num_open() > 2047) {
+		*status = NT_STATUS_INSUFF_SERVER_RESOURCES;
+		return NULL;
+	}
+
 	if(lp_security() != SEC_SHARE) {
 		vuser = get_valid_user_struct(vuid);
 		if (!vuser) {