web stats
Accessing appliance API prompts for LDAP? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2018, 05:36 AM
amble amble is offline
OBX.2 Kenobi
 
Join Date: Nov 2015
Posts: 95
amble is on a distinguished road
Default Accessing appliance API prompts for LDAP?

We have an appliance using MCv3.5.2 and appliance CP v3.11.1 - I'm trying to authenticate externally to the REST API using basic authentication. If I load up the appliance API

http://ipaddress:8443/api

I can log in as admin/admin. Using these credentials I can also test the _login method which gives me

Code:
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/xml' -d 'username=admin&password=admin' 'https:/applianceip:8443/api/users/_login'

<com.mirth.connect.model.LoginStatus>
    <status>SUCCESS</status>
    <message></message>
    <updatedUsername>admin</updatedUsername>
</com.mirth.connect.model.LoginStatus>

Code: 200
OK, So i use a piece of code to try and do the same from a webpage, the code is here:

HTML Code:
<html>
<head>
<script type="text/javascript">
	function CallWebAPI(){
var request = new XMLHttpRequest(),
	data = 'username=admin&password=admin';
request.open('POST', 'https://applianceIP:8443/api/users/_login', false)
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
request.setRequestHeader("Accept", "application/xml")
request.onreadystatechange = function() 
{
       console.log(request.responseText);
}
request.send();
}
</script>
</head>
<body>
<div>
<div id="response">
</div>
<input type="button" class="btn btn-primary" value="Call Web API" onclick="javascript:CallWebAPI();" />
</body>
</html>
But the response I get back is:

HTML Code:
<com.mirth.connect.model.LoginStatus>
	<status>FAIL</status>
	<message>There was an error connecting to the LDAP server. Please log in as the recovery user and verify that the LDAP configuration is correct.</message>
</com.mirth.connect.model.LoginStatus>
We do have LDAP enabled on the appliance for mirth connect. I have also tried a username of an LDAP account returned for the GET /users method as well and I still get the same response. Any ideas?
Reply With Quote
  #2  
Old 10-01-2018, 08:44 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

You aren't passing data to request.send()
Reply With Quote
  #3  
Old 10-01-2018, 08:46 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

There are also multiple readyState changes that will trigger your handler other than just when it is finished.

https://developer.mozilla.org/en-US/...d#Example_POST
Reply With Quote
  #4  
Old 10-01-2018, 09:25 AM
amble amble is offline
OBX.2 Kenobi
 
Join Date: Nov 2015
Posts: 95
amble is on a distinguished road
Default

ahhhh and that was it - working now, cheers agermano, huge oversight. Yeah I took out the readystates just for testing.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:47 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation