Below is a quick C# method for validating a XenServer API login, give the server name/IP address, username and password using the XenServer .Net SDK.

If you need the XenServer .NET SDK you can get it from the nuget.org package system within visual studio by searching for XenServer or by clicking on the direct link