LDAD over SSL Error on a Server

Hello Everyone,

I was wondering if someone can help me solve this riddle.  I need to authenticate a user against LDAP over SSL.  I have written the following method:

//////////////////////////////////////
 public static bool UserAuthetication(string userName, string password, string domain)
 {
  bool authentic = false;
         
  try
  {
        DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain, userName, password,  AuthenticationTypes.SecureSocketsLayer | AuthenticationTypes.Secure);
                object nativeObject = entry.NativeObject;
                authentic = true;
  }
  catch (Exception e)
  {
        authentic = false;
        return authentic;
  }
        return authentic;
}

////////////////////////////////

The method is called from the code as follows:
   
UserAuthetication("myUser", "myPassW", "rootDSE");

So here is my problem.  The mehod works correctly from multiple Workstations.  However, this code runs on a server and the code errors out everytime I run it on the server.  The code is used t authenticate an incoming request on a server.  I am guessing it has to do with the SSL certificates on the server but I am not sure where to start looking or which certificate it could be.  

Any ideas?
KozelaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stacy SpearPresident/Principal ConsultantCommented:
Whats the error?
0
KozelaAuthor Commented:
darkstar3d:  Sorry for the delay.

On the Server I get:
The certificate received from the remote server does not contain the expected name.  It is therefore not possible to determine whether we are connecting to the correct server.  The server name we are expecting is [Domain.corp.com].  The SSL connection request has failed.

On the program the exception that is thrown is:
Logon failure:unknown user name or babd password,

The weird part is that this program works fine on the workstations but not on the servers.  ????

0
KozelaAuthor Commented:
Assuming that the domain controller has been configured correctly with the CA certificate and you can connect to LDAP on port 636, the code above can be used with a few minor tweaks.

First Update the code as follows:

public static bool UserAuthetication(string userName, string password, string domain)
 {
  bool authentic = false;
         
  try
  {
        DirectoryEntry entry = new DirectoryEntry("LDAP://rootDSE", domain +"\\"+ userName, password, AuthenticationTypes.SecureSocketsLayer);
                entry.RefreshCache();

                authentic = true;
  }
  catch (Exception e)
  {
        authentic = false;
        return authentic;
  }
        return authentic;
}
 
 Then call the method as follows:

UserAuthetication("myUser", "myPassW", "[Windows Domain]");

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.