The agent can connect to the controller but the controller cannot connect to the agent because of following reason: The server has rejected the client credentials. The logon attempt failed

In Visual Studio Team Lab Management Beta2, the above error message is observed on a testing capability enabled lab environment/lab system when the service account for test controller/agent are not properly configured. 

In this case, following error will be observed in the logs of failing test agent.

I, 3436, 4, 2009/11/12, 16:14:19.435, ASEEMB-TA8\QTAgentService.exe, AgentService: Failed to connect to controller. Microsoft.VisualStudio.TestTools.Exceptions.EqtException: The agent can connect to the controller but the controller cannot connect to the agent because of following reason: The server has rejected the client credentials.
The logon attempt failed

Server stack trace:
at Microsoft.VisualStudio.TestTools.Controller.AgentMachine.VerifyAgentConnection(Int32 timeout)
at Microsoft.VisualStudio.TestTools.Controller.AgentManager.BeforeConnectAgent(String agentName, String machineName, Boolean canPerformUITesting, IAgentService agentService)
at Microsoft.VisualStudio.TestTools.Controller.ControllerConfiguration.ConnectAgent(String agentName, String machineName, Boolean canPerformUITesting, IAgentService agentService)
at Microsoft.VisualStudio.TestTools.Controller.ControllerObject.ConnectAgent(String agentName, String machineName, Boolean canPerformUITesting, IAgentService agentService)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.VisualStudio.TestTools.Controller.IControllerCallback.ConnectAgent(String agentName, String machineName, Boolean canPerformUITesting, IAgentService agentObject)
at Microsoft.VisualStudio.TestTools.Agent.AgentService.ConnectToController(Boolean shouldThrow)

This error can occur in any of the following conditions: -

1. [RC only] The test controller service is running under the same account as the one specified as the service account in lab management configuration for the project collection. You can verify this by opening the Team Foundation Administration Console -> Project Collection -> Lab Management -> Service Account.

Causes 2 and 3 apply only if you are not using the service account described above on a RC build.

2. The account under which test controller is running is not known to the test agent machine. i.e. if test controller is running under a local machine account, then the corresponding shadow account (same username/same password) does not exist on the test agent machine.

3. The test controller is running under a local machine account which is shadowed on test agent machine, but while creation of this account on test agent machine, “User must change password at next logon” property was enabled.

newUser

This essentially means that the password for the shadowed account has actually expired and test controller cannot connect to test agent unless the password is changed or the account is recreated with this property unchecked.

4. [Beta 2 only] The test agent is running on windows xp machine and force guest policy is on.