In a VSTO Add-In when invoking the UserPrincipal.Current.GivenName function, a timeout of 14s occurs and then the following error is generated:
"The specified domain does not exist or cannot be contacted."
The PC is under a firewall and it might be that some request are blocked but Fiddler does not show any error. Can someone tell me.
- What are the prerequisites for the function to work? Does the PC needs to be within the domain? Is there any network ports/protocols which need to be open? How does the function locates the LDAP service?
- Is there any way to inspect if the domain is available without suffering from the 14s timeout?
Investigations:
- Inside a domain the function works perfectly
- A fiddler trace does not show any failed connection to a LDAP service.
- Reference: https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.accountmanagement.userprincipal?view=netframework-4.8#constructors
- Setting a timeout for the connection: Not possible according to How to set connection time out when establishing context - PrincipalContext