View Issue Details

IDProjectCategoryView StatusLast Update
0011100mantisbtapi soappublic2010-02-22 14:34
Reporterwarden Assigned Torombert  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.1.7 
Target Version1.2.0Fixed in Version1.2.0 
Summary0011100: SOAP API login fails with LDAP
Description

Updated description:

<pre>
When I'm using standard mantis auth, it works fine.
But with ldap (and for sure correct credentials because mantis works fine) it fails with:
Error Type: SYSTEM WARNING,
Error Description:
Invalid argument supplied for foreach(),
Stack Trace:
mc_api.php L0 mc_error_handler()
ldap_api.php L428 ldap_simulation_get_user()
ldap_api.php L369 ldap_simulation_email_from_username()
ldap_api.php L285 ldap_authenticate_by_username()
authentication_api.php L342 ldap_authenticate()
authentication_api.php L273 auth_does_password_match()
mc_api.php L56 auth_attempt_script_login()
mc_issue_api.php L411 mci_check_login()
nusoap.php L0 mc_issue_add()
nusoap.php L4000 call_user_func_array()
nusoap.php L3689 invoke_method()
mantisconnect.php L1391 service()
mantisconnect.php L0 {main}()</pre>


When trying to use the mc_issue_add with:
issue = {
'project' : '1' ,
'summary' : 'SOAP Test 1' ,
'description' : 'SOAP Test 1',
'category': 'Some category'
}

you'll get an error that ... category is not defined, status is not defined, bla bla bla...
Whereas, the only required fields for creating a new issue is: category, summary, description and project.
Please be consistent because it turns out that mc_issue_add requires all the fields that are in WSDL for tns:issueData which is quite dumb...
or I am missing something..

TagsNo tags attached.
Attached Files
0001-Issue-11100-Avoid-warnings-when-the-ldap-simulation-.patch (878 bytes)   
From d78bb8fabb9c3fefe353bf5ae5855141b4eece94 Mon Sep 17 00:00:00 2001
From: Robert Munteanu <robert.munteanu@gmail.com>
Date: Sat, 31 Oct 2009 00:06:10 +0200
Subject: [PATCH] Issue #11100: Avoid warnings when the ldap simulation files is not found

---
 core/ldap_api.php |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/core/ldap_api.php b/core/ldap_api.php
index ec2f7ea..5d737e2 100644
--- a/core/ldap_api.php
+++ b/core/ldap_api.php
@@ -395,6 +395,10 @@ function ldap_simulation_get_user( $p_username ) {
 	$t_filename = config_get( 'ldap_simulation_file_path' );
 
 	$t_lines = file( $t_filename );
+	if ( $t_lines === false ) {
+		log_event( LOG_LDAP, "ldap_simulation_get_user: could not read simulation data from $t_filename." );
+		return null;
+	}
 
 	foreach ( $t_lines as $t_line ) {
 		$t_line = trim( $t_line, " \t\r\n" );
-- 
1.6.4.2

Activities

rombert

rombert

2009-10-30 10:13

reporter   ~0023489

Please try the the latest git snapshot from 1.2.x, as many fixes have been applied which will not be applied to 1.1 .

warden

warden

2009-10-30 10:20

reporter   ~0023490

Please check your mantis configuration........
I get all notification emails of comments in chinese!
what is quite irritating.

as far as the issue is concerned... I will test it and let you know. thx.

rombert

rombert

2009-10-30 10:28

reporter   ~0023491

My notification emails are in plain old english. Which is quite nice otherwise I would've deleted the email notifying me of this bug.

warden

warden

2009-10-30 10:30

reporter   ~0023492

That's indeed quite weird, because notification of a comment added by myself come in english.
But the notification of your comment or any other person comes in chinese... (got second one now if you want a forward ;) )

Anyway, about using 1.2.x, can you point me to any place describing upgrade?
http://docs.mantisbt.org/master/en/administration_guide.pdf
is not of much use...
And I cannot find any upgrade scripts as well for the database structure..

warden

warden

2009-10-30 10:35

reporter   ~0023493

Ok, found it, but... just to use install.php.
But there should be "upgrade" section in the docs.

Wow, in 1.2.x it's even worse:
* Incoming SOAP ****
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/&quot;
xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/&quot;>
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">Server</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Error Type: SYSTEM NOTICE,
Error Description:
Undefined index: handler,
Stack Trace:
mc_api.php L0 mc_error_handler()
nusoap.php L0 mc_issue_add()
nusoap.php L3997 call_user_func_array()
nusoap.php L3686 invoke_method()
mantisconnect.php L1390 service()
mantisconnect.php L0 {main}()
</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>


rombert

rombert

2009-10-30 11:22

reporter   ~0023495

I get the feeling you're using 1.2.0rc2. This particular issue was fixed in http://git.mantisbt.org/?p=mantisbt.git;a=commit;h=112122eddea6ee18cfa36b636239abb580793d5e . If you don't want to wait for an rc3 release, I suggest either clone the repository ( git clone git://git.mantisbt.org/mantisbt.git ) and checkout the master-1.2.x branch ( git checkout master-1.2.x ) or download a snapshot from http://git.mantisbt.org/?p=mantisbt.git;a=shortlog;h=refs/heads/master-1.2.x ( latest right now is http://git.mantisbt.org/?p=mantisbt.git;a=snapshot;h=087445cee12680c263f67f3907cc839a8c0cbe6e;sf=tgz ).

Up till now there have been quite a few changes since 1.2.0rc2:

<pre>087445cee12680c263f67f3907cc839a8c0cbe6e Fixes 0011015: mc_issue_update erases 'Due date' field
e5b7a744e1b8d365ae2cfa9f156d93a89e59380e Return a proper soap_fault if attachment retrieval fails
0f796cf7d44bf8e82a6e3bed1331366892145d6a Move all the base64_decode into the mc_xxx_attachment_api calls
475ecf2b8db4caa449bfcdfe4dfdc652cbac4984 Fix project attachment handling using the SOAP API
42b7a5daea1faa0e1cf691422a4e35c1ea4c0460 Issue 0005920: Don't log custom fields in bug_report
8faebae6ff9bb54a11ae466c6f3f7a1ad0d4d068 Fixes 0010592: mc_enum functions doesn't take customization into account
91ff59f375e17f15c893a7294b15d0c408e633bf convert ereg to preg
bfd2eae26b95c04344c74ed6846beb6b587400e7 Issue 0011061: SOAP issue tests fail
ef8e2a3903c689299e77d7d7ce8f351c1a41c117 Fixes 0011061: SOAP issue tests fail
f46bc275f8f87bd66deda43d0b0942f55698fe6d Fix 0010974: ereg is deprecated in PHP 5.3
5d821dd1a719b02f8b32056aa621b62d95915eba Fix 0010491: mc_issue_add incorrect access level check.
99d8bd0704ff16df797054a268d6dc07a9d0c442 Fix 0010878: bugnotes should be updated when mc_issue_update.</pre>

With at least one more expected fix for 0011081.

warden

warden

2009-10-30 12:05

reporter   ~0023497

Almost, but not there yet.
When I'm using standard mantis auth, it works fine.
But with ldap (and for sure correct credentials because mantis works fine) it fails with:
Error Type: SYSTEM WARNING,
Error Description:
Invalid argument supplied for foreach(),
Stack Trace:
mc_api.php L0 mc_error_handler()
ldap_api.php L428 ldap_simulation_get_user()
ldap_api.php L369 ldap_simulation_email_from_username()
ldap_api.php L285 ldap_authenticate_by_username()
authentication_api.php L342 ldap_authenticate()
authentication_api.php L273 auth_does_password_match()
mc_api.php L56 auth_attempt_script_login()
mc_issue_api.php L411 mci_check_login()
nusoap.php L0 mc_issue_add()
nusoap.php L4000 call_user_func_array()
nusoap.php L3689 invoke_method()
mantisconnect.php L1391 service()
mantisconnect.php L0 {main}()

vboctor

vboctor

2009-10-30 12:46

manager   ~0023498

@rombert, I'm wondering if we should consider back porting the applicable fixes + test cases to the 1.1.x branch. I typically wouldn't do that for normal features, but my feel is that this will allow more instances to use the robust a SOAP API which makes clients life easier and the experience much better.

Eventually, we can release 1.1.9 with such fixes.

On the other hand, I would classify this as lower priority compared to the focus on 1.2.x.

warden

warden

2009-10-30 12:56

reporter   ~0023499

As the 1.2 is in RC state, I would accept that, but... just make it work ;-)

Another thing, mc_issue_add should provide a method to set project by name and not ID.
Or... mc_get_project_list should be provided :/

rombert

rombert

2009-10-30 17:49

reporter   ~0023502

Last edited: 2009-10-30 17:49

@warden

  1. is that error on 1.2?
  2. if so, would you be willing to troubleshoot/apply patches since I don't have access to an ldap test env?
  3. ref. mc_get_project_list - perhaps you're looking for mc_projects_get_user_accessible?

@vboctor it should be possible to backport some of the fixes, I can't say for sure. Trying to cherry-pick some of them ended up messing things up.

warden

warden

2009-10-30 17:53

reporter   ~0023503

  1. yes
  2. ok, i'll try to fix the cause
  3. indeed... the name was a bit not what I expected :) thanks!
rombert

rombert

2009-10-30 18:08

reporter   ~0023504

@warden: can you please try the attached patch?

vboctor

vboctor

2009-10-30 21:14

manager   ~0023505

@rombert, I would prefer replacing:
if ( !$t_lines ) {

with:
if ( $t_lines === false ) {

This is the style that we usually follow for checking for mixed return values with bool false as the error case.

rombert

rombert

2009-11-01 08:17

reporter   ~0023518

@vboctor - patch updated. Need to see if this actually does solve the error though.

rombert

rombert

2009-11-01 15:33

reporter   ~0023521

@warden : It might be that you're using a LDAP simulation file with a relative path. In that case the web interface is using the mantis root to access the file, while the SOAP API is based in mantis root/api/soap, which causes the error. If that is the case, I'll update the documentation to reflect this.

warden

warden

2009-11-01 17:35

reporter   ~0023523

I can confirm that this patch solves this issue. Thanks :)

rombert

rombert

2009-11-01 17:42

reporter   ~0023524

This is excellent to know. Just to be on the safe side, was the problem a relative path setting, as I tried to guess above?

warden

warden

2009-11-01 17:47

reporter   ~0023525

Erm.. well, in fact I don't really know. I mean,from your sentence it looks like I would be setting the simulation file path by hand, but I didn't.
That was a plain normal LDAP mantis config :)

rombert

rombert

2009-11-01 17:53

reporter   ~0023526

I understand. Apparently even though simulation is not set, the warning generated when trying to access the file caused the SOAP API to break.

Thanks.

vboctor

vboctor

2009-11-01 17:58

manager   ~0023527

@rombert, we should only attempt to access the file if the file name is not blank.

if ( !is_blank( $t_filename ) ) {
// access file here.
}

This will be more efficient and is how it was supposed to work.

rombert

rombert

2009-11-01 18:02

reporter   ~0023528

@vboctor: You're right, I've added a is_blank guard before reading the file.

Thanks.

Related Changesets

MantisBT: master-1.2.x aa457a1a

2009-10-30 18:06

rombert


Details Diff
Issue 0011100: Avoid warnings when the ldap simulation files is not found Affected Issues
0011100
mod - core/ldap_api.php Diff File

MantisBT: master 94f40e2b

2009-10-30 18:06

rombert


Details Diff
Issue 0011100: Avoid warnings when the ldap simulation files is not found Affected Issues
0011100
mod - core/ldap_api.php Diff File

MantisBT: master-1.2.x c8666c4f

2009-11-01 18:02

rombert


Details Diff
Issue 0011100: Don't read the ldap simulation file if it is not set Affected Issues
0011100
mod - core/ldap_api.php Diff File

MantisBT: master 60dcfcda

2009-11-01 18:02

rombert


Details Diff
Issue 0011100: Don't read the ldap simulation file if it is not set Affected Issues
0011100
mod - core/ldap_api.php Diff File

MantisBT: master-1.2.x a4d98b0b

2009-11-02 02:53

vboctor


Details Diff
Fixes 0011100: SOAP API login fails with LDAP. -- the simulation code was called by production code. Affected Issues
0011100
mod - core/ldap_api.php Diff File

MantisBT: master 20f9c654

2009-11-02 02:53

vboctor


Details Diff
Fixes 0011100: SOAP API login fails with LDAP. -- the simulation code was called by production code. Affected Issues
0011100
mod - core/ldap_api.php Diff File