Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BindAsync on Linux #104

Open
Mariastakh opened this issue Nov 10, 2020 · 4 comments
Open

BindAsync on Linux #104

Mariastakh opened this issue Nov 10, 2020 · 4 comments
Labels
bug Something isn't working linux

Comments

@Mariastakh
Copy link

Hello,

Great library so far, got a little issue.

The bug
Running BindAsync on Linux causes a null reference exception

An unhandled exception has occurred while executing the request.
System.NullReferenceException: Object reference not set to an instance of an object.
   at LdapForNet.Native.LdapNativeLinux.<>c__DisplayClass10_0.<BindSimpleAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at LdapForNet.Native.LdapNativeLinux.BindSimpleAsync(SafeHandle ld, String userDn, String password, LDAP_TIMEVAL timeout)
   at LdapForNet.LdapConnection.BindAsync(LdapAuthType authType, LdapCredential ldapCredential)
   at LdapClient.Hello() in /path/to/the/Project/LdapClient.cs:line 16

To Reproduce

using var cn = new LdapConnection();
cn.Connect(new Uri("ldaps://example.co.uk"));
await cn.BindAsync(LdapAuthType.Simple, new LdapCredential());

Expected behaviour
Expected bind to be successful and to receive search results, however got a null reference exception from BindAsync(). The non async version of Bind() works fine by the way.

Desktop:

  • OS: [Linux]
  • Library version [2.7.11]
  • .NET\core\mono version [3.1]
  • LDAP server [OpenLdap 2.4.54-1]
@flamencist
Copy link
Owner

Hello! For simple auth binding you should specify username/dn and password.

@Mariastakh
Copy link
Author

Mariastakh commented Nov 11, 2020

Hi! Thank you for your swift reply

It still fails with

await cn.BindAsync(LdapAuthType.Anonymous, new LdapCredential());

With the same error

System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace:
     at LdapForNet.Native.LdapNativeLinux.<>c__DisplayClass10_0.<BindSimpleAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at LdapForNet.Native.LdapNativeLinux.BindSimpleAsync(SafeHandle ld, String userDn, String password, LDAP_TIMEVAL timeout)
   at LdapForNet.LdapConnection.BindAsync(LdapAuthType authType, LdapCredential ldapCredential)
   at LdapClient.Hello() in path/to/Project/LdapClient.cs:line 16

It works with BindAsync on windows, and it works with Bind but not BindAsync on Linux.

We have managed to replicate the issue in docker and the set up is

FROM mcr.microsoft.com/dotnet/core/sdk:3.1
RUN apt-get update
RUN apt-get install ldap-utils -y

@flamencist
Copy link
Owner

What linux distributive ?

@Mariastakh
Copy link
Author

The distribution is Manjaro

We've just uploaded a repository over here with an example that reproduces the error

https://github.com/millsaj/ldapfornet-test

From trying to isolate the issue, it looks like BindAsync on Linux either doesn't like binding using LdapAuthType.Anonymous, or it does not like connecting over secure LDAP

@flamencist flamencist added bug Something isn't working linux labels Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linux
Projects
None yet
Development

No branches or pull requests

2 participants