net-ldap authentication format in rails? -


 def authenticate(username, password)         require 'net-ldap'         ldap = net::ldap.new         ldap.host = 'server.local'         ldap.port = 389         ldap.base = 'cn=users, dc=server, dc=local'         ldap.auth username, password         if ldap.bind             puts "authentication succeeded"             else             puts "authentication failed"         end 

the above code use in method , not sure why attempts fail. trying authenticate user. not find going wrong? puts authentication failed every time. why? please me.

first see if computer using can talk ldap server

telnet server.local 389 

obviously want replacing server.local actual server details. if can't log server way port 389 isn't open , may need running on ssl port 636. try previous command 636 rather 389 see if case.

if unable telnet server on either of ports you've either got firewall rule blocking talking it, ldap configured on non standard port or else wrong.

a working port 636 mean need run following.

require "net-ldap" ldap = net::ldap.new(     host: "server.local"     port: 636     encryption: :simple_tls ) ldap.auth username, password 

failing of error message going pretty useful try running

if ldap.bind     # yay! else     puts ldap.get_operation_result end 

with results maybe can bit more.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -