ldap4net: Search doesnt work on Linux

Describe the bug Search for objects dose not work on linux(ubuntu 18.04).

To Reproduce

add-type -AssemblyName /mnt/c/Users/kiranna/Source/LdapForNet.dll
$cn = [LdapForNet.LdapConnection]::new()
$cn.Connect("ldap://server.example.com:389",[LdapForNet.Native.Native+LdapVersion]::LDAP_VERSION3)
$base = "dc=example,dc=com"
$filter = "(&(objectcategory=person)(name=kiran*))"
$ldapcred = [LdapForNet.LdapCredential]::new()
$ldapcred.UserName = "admin"
$ldapcred.Password = "password"
$ldapcred.Realm = "example.com"
$cn.Bind([LdapForNet.Native.Native+LdapAuthType]::Digest,$ldapcred)
$cn.Search($base,$filter,"Name",[LdapForNet.Native.Native+LdapSearchScope]::LDAP_SCOPE_SUBTREE)

Expected behavior The search function completes showing the returned objects.

Actual behavior The search function seems to get stuck and never returns or times out.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04
  • Library version :2.7.2
  • .NET\core\mono version - netstandard 2.0
  • LDAP server : Active Directory

Additional context The search works perfectly fine on windows with the same ldap server its only on linux that its failing. Also the search works with ad lds on linux so something seems to be going wrong specifically with AD.I have also tried changing the ad server but same result. Perhaps I am missing some parameter or setting something incorrectly on linux. Would appreciate an example where it works with AD on linux.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 25 (13 by maintainers)

Most upvoted comments

I had issues with referrals on linux. I found out, that the correct way to disable them on linux is: connection.SetOption(Native.LdapOption.LDAP_OPT_REFERRALS, IntPtr.Zero);

On windows it was working for me either way.

@flamencist - Yes it did 😃 on linux Ubuntu 18.04 I was waiting to test it on a Mac but I am sure it will work there too.

@gergodrazsdik - thank you for posting the solution.