Run Script Performane

To all the experts out there.

I am trying to retrieve basic user details from our AD server using a Run Script action in Workflow. The script systematically takes between 14-20 seconds to run in Workflow to return the output succesfully.

Outside the Workflow but from the same machine, it takes about 1 second to run and returns the result to the console.

Am I missing anything? How can I get the below script to run faster within Workflow?

var oConnection = new ActiveXObject(“ADODB.Connection”);
oConnection.Open(“Provider=ADsDSOObject”);
var oCommand = new ActiveXObject(“ADODB.Command”);
oCommand.ActiveConnection = oConnection;
oCommand.Properties(“Page Size”) = 100;
var userName = ‘testuser1’;
oCommand.CommandText =“SELECT name, mail, sAMAccountName From ‘LDAP://adserver.com:333’ WHERE objectClass=‘User’ and sAMAccountName='”+userName+“'”;
oRS = oCommand.Execute;
if(!oRS.EOF){
oRS.MoveFirst;
Watch.Log("name " + oRS.Fields(“name”).Value,2);
}
oRS.Close();

Thank you,
Robyr

The first time you run the script, it takes longer. I would assume that’s because Windows somehow caches the first response after that. In Workflow, the first run takes almost 10 seconds… after which I get almost instant responses. And that behavior is the same when I run the script from the desktop.