See the question and my original answer on StackOverflow

If you search a bit with .NET Reflector, you will find that the code behind this dialog is located in the Microsoft.Web.Management.Iis.dll assembly. This assembly is located in the GAC (if you use Reflector, just do File / Open Global Assembly Cache, and choose this DLL).

To be more precise, the code is implemented in a the Microsoft.Web.Management.Iis.WebObjects.WebObjectsTestConnectionHelper class, method public PropertyBag TestConnection(PropertyBag bag).

Unfortunately this class is non public, as the code is quite specific to IIS, and not a general "unc connection testing code". However, the whole implementation is located here, so you can really understand what it's doing by looking at it using Reflector and 1) reproduce it using your own code, or 2) call it using reflection mechanisms. What must be in the input PropertyBag can be determined by looking at the method (and sub methods) body.