ImpersonateLoggedOnUser failed error

Hello,

I have a scheduled task that execute the following JS script : 

var CRMUserName = "##username##";
var CRMPassword = "##password##";
var CRMInstance = "CRM";
var eWare = CRM = new ActiveXObject("eWare." + CRMInstance);
eWare.FastLogon = 3;
eWare.Logon(CRMUserName, CRMPassword);

var sid = eWare.SessionId;

var aspFileUrl = "##url_to_asp_file##?SID=" + sid;

var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");

xmlhttp.open("GET", aspFileUrl, false);
xmlhttp.send();

eWare.Logoff();

I already used this method on another client, but in this CRM i get the following error message on the connection :

juin 7 2023 14:19:09.053    25980    21744    1    startup,version,dllsize,dlldate,exehost,imagebase,reference    Sage CRM 2021  R2.2 1220    12189336    déc. 20 2021 13:34:18.000    C:\windows\syswow64\wscript.exe    1A93B9D0    #line#
juin 7 2023 14:19:09.288    25980    21744    5    CRM is now loading system params into memory.
juin 7 2023 14:19:11.945    25980    21744    5    CRM is now finished loading system params into memory.
juin 7 2023 14:19:21.572    25980    21744    1    Metadata    12281
juin 7 2023 14:19:21.783    25980    21744    5    TMetadata.Create finished.
juin 7 2023 14:19:21.783    25980    21744    5    Will now actually do the login for user admin
juin 7 2023 14:19:22.252    25980    21744    5    TUserSession.Create finished.
juin 7 2023 14:19:22.514    25980    21744    5    LoadUserSession: RemoteAddress not found
juin 7 2023 14:19:22.672    25980    21744    1    PrepImpersonatefail,Error    OpenThreadToken failed<BR>Tentative de référence à un jeton qui n’existe pas<BR>
juin 7 2023 14:19:22.672    25980    21744    1    ** Created global user activity thread **
juin 7 2023 14:19:22.674    25980    22820    1    ImpersonateThread.Impersonate,Error    ImpersonateLoggedOnUser failed<BR>Descripteur non valide<BR>

I compared both CRM settings (user's and system behaviour) but everything seems fine.

Does anyone ever got this error ?
What other configuration should I check ?
Do you use another method to call asp files from scheduled tasks ?