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

lualdap doesn't work #3

Open
evanchaoli opened this issue Jul 10, 2019 · 0 comments
Open

lualdap doesn't work #3

evanchaoli opened this issue Jul 10, 2019 · 0 comments

Comments

@evanchaoli
Copy link

evanchaoli commented Jul 10, 2019

I'm trying to use lualdap, but it doesn't work for me. My code is as below:

require 'lualdap'

ld = lualdap.open_simple("my-ldap-server", "user", "pass")
if ld == nil then
  print("LDAP not connected!")
  return 1
end

for dn, attribs in ld:search { base = "dc=mycompany,dc=com" } do
  print (string.format ("\t[%s]\n", dn))
  for name, values in pairs (attribs) do
    io.write ("["..name.."] : ")
    if type (values) == "string" then
      io.write (values)
    elseif type (values) == "table" then
      local n = table.getn(values)
      for i = 1, (n-1) do
        io.write (values[i]..",")
      end
      io.write (values[n])
    end
    io.write ("\n")
  end
end
ld:close()
print("Done!!")

In the meantime, if I use ldapsearch to do same search:

$ ldapsearch -D user -w pass -h my-ldap-server -b 'dc=mycompany,dc=com'

the ldapsearch command works, returning LDAP records.

Why's wrong with my code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant