Click here to Skip to main content
15,887,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an application that is attempt to validate an LDAP SSL account. When I execute the code to authenticate the LDAP SSL connection directly through the application, it works. However, when the ValidateLDAP connection method is in the business rules and executed through the webservice - it fails.

private void cmdValidateLDAP_Click(object sender, EventArgs e)
{
  string errormsg = null;

  LDAPSettingsObject ldapSettingsObj = new LDAPSettingsObject();

  // assign values to ldap object
  ldapSettingsObj.Group_string = txtGrpString.Text;
  ldapSettingsObj.IP_Address = txtLDAPIPAddress.Text;
  ldapSettingsObj.Login_Attribute = txtLoginAttribute.Text;
  ldapSettingsObj.Password = txtLDAPPassword.Text;

  if (txtPort.Text != "" && Convert.ToInt32(txtPort.Text) > 0)
      ldapSettingsObj.Port = Convert.ToInt32(txtPort.Text);

  ldapSettingsObj.Search_base = txtSearchBase.Text;
  ldapSettingsObj.serverType =LDAPSettingsObject.LDAPServerType.ACTIVE_DIRECTORY;
  ldapSettingsObj.Username = txtLDAPUserName.Text;
  ldapSettingsObj.SSL = cbLDAPSSL.Checked;

  // testing this w/out webservice
  LdapConnection ldc = null;
  LDAPStatusCode lsc = LDAPStatusCode.OpSuccess;
  bool _bSuccess = ConnectToActiveDirectory(ldapSettingsObj,
                     ldapSettingsObj.Username, ldapSettingsObj.Password, 
                     ref ldc, ref lsc);

  // test this WITH webservice
  // bool _bSuccess = GetController.wsController.Security_ValidateLDAP(
  //                    ldapSettingsObj, ref errormsg);

  if (_bSuccess == true)
  {
    // success, display success msg
    MessageBox.Show("Connection to LDAP Server Successful",
                              MessageBoxButtons.OK);
  }
  else if (_bSuccess == false && errormsg != null)
  {
    // failure, display error message
    MessageBox.Show(errormsg.ToString(), MessageBoxButtons.OK);
  }
  else
  {
    // failure, no error, display generic message
    MessageBox.Show("Connection to LDAP Server Unsuccessful",
                              MessageBoxButtons.OK);
  }

  return;
}


The cert was installed with the administrator account. The webservice is run under the ASPNET account. I have tried to execute WinHttpCertCfg with no success.

Next I tried the FindPrivateKey which also didn't work.

Can anyone help? Thanks!
Posted
Comments
aidin Tajadod 9-Jan-12 17:50pm    
From what you say, It seems you have permission problem. To check this, If possible, I would change aspnet user to be Administrator for a very short time and the check it again. (Giving aspnet administrators privilages might be very dangerous, So do it on your test server)

1 solution

Found the solution after additional searching. It was a permissions problem but not something that could be resolved through a UI tool.

http://support.microsoft.com/kb/901183

Installing the certificate in the Local store is the key.

Thanks!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900