Still not working...To help clairify I have incuded a complete code example. This example does NOT work! I can NOT get authenticated soap to ldap. I authenticate fine soap to sugar db. I also authenticate fine when going from the sugar login screen to ldap. Also included below my code is the code example provided on sugar forum written in php and using a mcrypt function. I can't tell exactly what the php auther is doing with the MD5 hash but I have tried to both return the byte array and a hex string.
Code:
Private Sub LoginLdapUser()
' abc123 is the text entered into the ldap encryption key field
Dim _ldapKey As String = "abc123"
Dim _userName As String = "jherington"
Dim _userPassword As String = "password"
Dim _sessionId As String = String.Empty
Dim _intSeamlessLogin As Integer = 0
Dim builder As StringBuilder
' SugarCRM user authentication object
Dim _user As New user_auth
' Build MD5 hash from Ldap Key
Dim md5 As MD5 = md5.Create()
Dim _inputBuffer As Byte() = System.Text.Encoding.ASCII.GetBytes(_ldapKey)
Dim _outputBuffer As Byte() = md5.ComputeHash(_inputBuffer)
' I tried this also...
' Convert the byte() to a hex-string
'builder = New StringBuilder(_outputBuffer.Length)
'For i As Integer = 0 To _outputBuffer.Length - 1
' builder.Append(_outputBuffer(i).ToString("X2"))
'Next
'_outputBuffer = ASCIIEncoding.ASCII.GetBytes(builder.ToString.Substring(0, 24))
' 3DES Encrypt user password using MD5 Ldap Key and the word "password" as the iv
Dim cryptoProvider As TripleDES = TripleDES.Create("TripleDES")
cryptoProvider.Mode = CipherMode.CBC
cryptoProvider.Key = _outputBuffer
cryptoProvider.IV = System.Text.Encoding.ASCII.GetBytes("password")
Dim buff As Byte() = ASCIIEncoding.ASCII.GetBytes(_userPassword)
buff = cryptoProvider.CreateEncryptor.TransformFinalBlock(buff, 0, buff.Length)
' Convert binary to hex
Dim _len As Integer = buff.Length
builder = New StringBuilder(_len)
For i As Integer = 0 To _len - 1
builder.Append(buff(i).ToString("X2"))
Next
Dim _3DESPassword As String = builder.ToString
_user.user_name = _userName
_user.password = _3DESPassword
Dim auth_result As set_entry_result = sugarSoap.login(_user, "Home")
If Not Convert.ToInt32(auth_result.error.number) = 0 Then
' An error occured
_soapError = String.Concat(auth_result.error.name, ": ", auth_result.error.description)
' Clear the existing sessionId
_sessionId = String.Empty
UltraWebTab1.Tabs.GetTab(0).ContentPane.TargetUrl = _
"http://itsa2.sugdomain.sug/sugarcrm/index.php?action=Authenticate&module=Users&user_name=" & _
"jherington&user_password=password&login_theme=Sugar&login_language=en_us&login_module=Accounts&login_action=index"
Else ' Success
' Set the sessionId
_sessionId = auth_result.id
_intSeamlessLogin = sugarSoap.seamless_login(_sessionId)
If _intSeamlessLogin <> 0 Then
UltraWebTab1.Tabs.GetTab(0).ContentPane.TargetUrl = _
"http://itsa2.sugdomain.sug/sugarcrm/index.php?module=Home&action=index&MSID=" & _sessionId
End If
End If
End Sub Code example provided on sugar forum which I assume works?
Code:
require_once('./path/to/nusoap.php');
$soap_client = new soapclient('http://someurl.com/sugar/soap.php?wsdl');
$user_name = 'matt';
$user_password = 'mygoodsecret123';
$app_name = 'myniceprogram';
$key = 'abc123'; // LDAP Key as entered in Sugar
$key = substr(md5($key),0,24);
$iv = 'password'; // note that this is the word password, not the user's password or hash...
$ldap_hash = bin2hex(mcrypt_cbc(MCRYPT_3DES, $key, $user_password, MCRYPT_ENCRYPT, $iv));
$soap_client->call('login',array('user_auth'=>array('user_name'=>$user_name, 'password'=>$ldap_hash,'version'=>'.1'), 'application_name'=>$app_name)); Also...I have a very simple openLdap nothing fancy is there any thing in particular that Sugar is assuming about the openLdap setup such as some sort of encryption setup or somthing else?
Also...Is there anything special I have to do with Apache or PHP besides enable php-mcrypt (which I already did)...like enable any sort of encryption option or what ever?
Bookmarks