Intermittent SSO failures via API

Hey all,

Has anyone ever encountered intermittent failures when logging in to datasources via the API with SSO? We've switched to using SSO vs a logical account to log in with some of our C# Windows Services code. Most of the time, the login works just fine. However, what we are seeing is that sometimes logins fail, with the following message

58063 Cannot login to the datasource           Invalid user name and password combination.

We've constructed a testing service that reproduces the problem. The login psuedo code in the test program looks like this:

aaApi_Initialize(0);
aaApi_SetModuleFlags(AAMODULEF_NON_UI_MODE);

aaApi_SetErrorLogFile("logfile.txt", false);

if (!(aaApi_AdminLogin(0, PWDataSource, null, null)))
{
string errmsg = PWInterface.GetLastErrorDetail();
WriteToFile("[PWService] - " + errmsg);
Debug.WriteLine("[PWService] - " + errmsg);
}
else
{

Debug.WriteLine("[PWService] - Logged in OK");
WriteToFile("[PWService] - Logged in OK");

}

The login code will continue to fail until the service is restarted. This is the real problem as we have to intervene to get it to start working again.

Has anyone else run into this? Is there a way to get more debugging information out of the API? The information logged to the error file specified in aaApi_SetErrorLogFile isn't very helpful. I can't see anything in the API that would control the logging level.