AnsweredAssumed Answered

Password errors when logging in with REST and LDAP

Question asked by Hong Hong on Jun 16, 2014
Hi, I am having trouble to login a ldap user via REST-API. I follow the code example in the documentation (http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.5/02_Application_Framework/Web_Services/Examples/REST/PHP/Logging_In/)
but instead of PHP I use Javascript. I can already login as a normal user via REST-API.
Here is my javascript code:
// password generation for ldap user
var ldap_key = "secret";
ldap_key = md5(ldap_key).substr(0,24);
var pw = CryptoJS.TripleDES.encrypt(password, ldap_key,{mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.ZeroPadding});

// pw.toString return hex value in this case:
password = pw.toString();

// defining payload
var params = {
               user_auth:{
                          user_name:userName,
                          password:password
               },
               application: "test client"
              };
var json = JSON.stringify(params);

$.ajax({
   url: "https://someurl",
   type: "POST",
   data: {
    method: "login",
    input_type: "JSON",
    response_type: "JSON",
    rest_data: json
   },
   dataType: "json",
   success: function (result) {
    // do something here
   }
     });
Any ideas, what I did wrong?

Update: 

Sorry, forgot to mention that I receive the message that login or password are incorrect when I use the code above.

Update:
Description was: "Login attempt failed please check the username and password".

Outcomes