http://bugs.winehq.org/show_bug.cgi?id=19529
Summary: .NET 2.0: LDAP authorization fails (bug report + solution) Product: Wine Version: 1.1.26 Platform: PC OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: a.romanek@no.pl
Created an attachment (id=22726) --> (http://bugs.winehq.org/attachment.cgi?id=22726) Patched search.c file from wine/dlls/wldap32
In the company where I work we use our own internal software written in .NET 2.0. This software authenticates users using LDAP. When I was trying to run this software under Ubuntu 9.04 using WINE 1.26 authentication always failed. I started debugging the problem and I found that a .NET API call to "System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)" throws an exception. A debug was also printed on the console log says that "A bad parameter was passed to a routine". According to this website - http://msdn.microsoft.com/en-us/library/aa367014%28VS.85%29.aspx - it is the error message representation of the LDAP_PARAM_ERROR return code from WinLDAP library.
I was digging further and I found that in WINE "SendRequest(DirectoryRequest request)" method calls "ldap_search_extW()" WINE API function (http://source.winehq.org/source/dlls/wldap32/search.c#L238). This function calls ldap_search_ext from OpenLDAP API. A quick look in the source code (http://www.openldap.org/devel/cvsweb.cgi/~checkout~/libraries/libldap/search...) and I got it - see ldap_pvt_search():
if( timeout != NULL ) { if( timeout->tv_sec == 0 && timeout->tv_usec == 0 ) { return LDAP_PARAM_ERROR; }
I went back to 'ldap_search_extW()'. Here it is: the 'tv_sec' member of 'struct timeval tv' is always filled with the value of timelimit argument, even if this value is 0. Then the address of the structure is ALWAYS passed to 'ldap_search_ext()'. As a consequence (see above) LDAP_PARAM_ERROR is returned. If we make a change in call to 'ldap_search_ext()' and pass NULL as timeout argument when 'timelimit' is 0 instead of passing 'tv' structure address everything works perfectly. I think this is how this 'timelimit' argument is handled in WinLDAP library.
And what's the most important, this solves the problem of authentication in my company's software.
http://bugs.winehq.org/show_bug.cgi?id=19529
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com 2009-07-31 05:47:50 --- Hi, Adam.
Could you please add a test for different return values (to prevent regressions in future)?
Thanks.
http://bugs.winehq.org/show_bug.cgi?id=19529
--- Comment #2 from Adam Romanek a.romanek@no.pl 2009-07-31 07:12:28 --- Created an attachment (id=22731) --> (http://bugs.winehq.org/attachment.cgi?id=22731) Regression test for ldap_search_extW function
Simple regression test added.
Enjoy.
http://bugs.winehq.org/show_bug.cgi?id=19529
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Summary|.NET 2.0: LDAP |.NET 2.0: LDAP |authorization fails (bug |authorization fails |report + solution) |
--- Comment #3 from Vitaliy Margolen vitaliy@kievinfo.com 2009-07-31 08:08:39 --- Test case needs a bit more work. Also using external server for a test is iffy. Is there another way to verify the patch?
http://bugs.winehq.org/show_bug.cgi?id=19529
--- Comment #4 from Adam Romanek a.romanek@no.pl 2009-07-31 08:24:07 --- I do not know this API to well so the tests are pretty simple.
In reference to this external server, I was patterning myself on the tests in wine/dlls/wldap32/tests/parse.c. I don't know any other way to test this functionality than using existing LDAP server.
http://bugs.winehq.org/show_bug.cgi?id=19529
--- Comment #5 from Juan Lang juan_lang@yahoo.com 2009-07-31 11:38:08 --- (In reply to comment #4)
In reference to this external server, I was patterning myself on the tests in wine/dlls/wldap32/tests/parse.c. I don't know any other way to test this functionality than using existing LDAP server.
Since the existing tests use the same server, I'm sure this is fine. You'd want to send the test in git format to wine-patches@winehq.org.
Also, the tests: ok( !ret, "ldap_search_extW failed 0x%08x\n", ret ); assume your patch is already in the tree, yes?
A better way might be to add the test first, with todo_wine before the tests that fail with unpatched wine. Something like: todo_wine ok( !ret, "ldap_search_extW failed 0x%08x\n", ret );
A subsequent patch that fixes the search function can remove the todo_wine.
http://bugs.winehq.org/show_bug.cgi?id=19529
Xavier Vachon xvachon@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |xvachon@gmail.com
--- Comment #6 from Xavier Vachon xvachon@gmail.com 2010-08-11 11:34:21 --- Is there a way to test this bug in current git?
http://bugs.winehq.org/show_bug.cgi?id=19529
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |dotnet CC| |focht@gmx.net
--- Comment #7 from Anastasius Focht focht@gmx.net 2010-08-11 14:01:07 --- Hello,
adding 'dotnet' keyword.
Regards
http://bugs.winehq.org/show_bug.cgi?id=19529
Hans Leidekker hans@meelstraat.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |hans@meelstraat.net Resolution| |FIXED
--- Comment #8 from Hans Leidekker hans@meelstraat.net 2010-08-19 02:05:35 --- Fixed by 3fbf6bdf113a5fe1768aca146f8062cc96c208d5.
http://bugs.winehq.org/show_bug.cgi?id=19529
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Alexandre Julliard julliard@winehq.org 2010-08-20 12:39:01 --- Closing bugs fixed in 1.3.1.
http://bugs.winehq.org/show_bug.cgi?id=19529
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |3fbf6bdf113a5fe1768aca146f8 | |062cc96c208d5 Component|-unknown |wldap32