First of all, you cannot simply use the results from AccountUser retrieval to execute further updates of the same AccountUser. You have to change the format of the values as well. You can check out this answer for better understanding.
Then, once you would adjust the format for the update, you would hit the same wall of "User [n] does not have permission to edit ACCOUNTUSERS on account [MID]" that is actually still not fixed, even though SF says it is. This eliminates any usage of WSProxy with Create and Update method on AccountUser object.
Therefore, you need to prepare a SOAP envelope to update your user and execute API call. The logic you would need:
- Find the AccountUsers by their email and retrieve their AccountUserIDs and MIDs (Client.ID) they belong to.
- Retrieve an Access Token
- For each separate user do a SOAP call via HTTP.Post SSJS function where you have to specify AccountUserID and MID as identifiers and also ActiveFlag = false to switch off the user
<script language="javascript" runat="server">
Platform.Load("Core", "1")
// Required variables for the code
var Domain = "";
var AccessToken = "";
var MID = "";
var AccountUserID = "";
var URL = 'https://' + Domain + '.soap.marketingcloudapis.com/Service.asmx';
var ContentType = 'text/xml';
var Payload = '';
Payload += '<?xml version="1.0" encoding="UTF-8"?>';
Payload += '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
Payload += '<s:Header>';
Payload += '<a:Action s:mustUnderstand="1">Create</a:Action>';
Payload += '<a:To s:mustUnderstand="1">https://' + Domain + '.soap.marketingcloudapis.com/Service.asmx</a:To>';
Payload += '<fueloauth xmlns="http://exacttarget.com">' + AccessToken + '</fueloauth>';
Payload += '</s:Header>';
Payload += '<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">';
Payload += '<CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">';
Payload += '<Options>';
Payload += '<SaveOptions>';
Payload += '<SaveOption>';
Payload += '<PropertyName>*</PropertyName>';
Payload += '<SaveAction>UpdateAdd</SaveAction>';
Payload += '</SaveOption>';
Payload += '</SaveOptions>';
Payload += '</Options> ';
Payload += '<Objects xsi:type="AccountUser">';
Payload += '<PartnerKey xsi:nil="true"></PartnerKey>';
Payload += '<ObjectID xsi:nil="true"></ObjectID>';
Payload += '<Client>';
Payload += '<ID>' + MID + '</ID>'; // Paste MID
Payload += '</Client>';
Payload += '<AccountUserID>' + AccountUserID + '</AccountUserID>'; // Paste AccountUserID
Payload += '<ActiveFlag>false</ActiveFlag>';
Payload += '</Objects>';
Payload += '</CreateRequest>';
Payload += '</s:Body>';
Payload += '</s:Envelope>';
var HttpPost = HTTP.Post(URL, ContentType, Payload);
</script>