Sunday, March 29, 2015

Unable to establish secure connection with the server

I was recently working on using Forms Authentication with Active Directory when I suddenly received the following error message:

Unable to establish secure connection with the server

I double checked my connectivity to the server and everything looked OK to me.  However, the computer that I was testing with was not connected to the target Domain.

Was there any workaround other than joining my workstation to the same Domain as the Active Directory server?

Well, as it turns out there is!

You can simply add the following setting to the Active Directory membership provider configuration in the Web.config file:

<membership defaultProvider="ADMembershipProvider">
    <clear />
    <add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" connectionUsername="mydomain\domainuser" connectionPassword="domainPassword!"  />

Then, you may have to switch the LDAP/Active Directory connection string to the following:


<add name="ADConnectionString" connectionString="LDAP://,DC=com"  />


After doing this, I was able to connect successfully to the Domain even when my computer/workstation was not joined to the Domain!