Reg: JRUBY to LDAP

Hi ,

I am new to JRUBY.

I would like to connect with LDAP to check user status.

Can Someone help with code and steps to execute.

I have installed JRUBY and ran a sample program. Try to understanding
the
flow. As i am from JAVA background.

Sathya -

I have no experience with this, but I just googled ruby ldap and got
some hits. Ruby Toolbox was one of them; its a helpful site, with
information and ratings on gems. Here is a page that might help:

https://www.ruby-toolbox.com/categories/ldap

Theres one (net-ldap) that is the overwhelming favorite there.

Aside from that, if you already use a Java library for this, you could
always use thatand even if you dont already use a Java library for this,
it might be worth looking intoit might be better quality than the Ruby
gem (I dont know, Im just raising the possibility).

  • Keith

Keith R. Bennett
http://about.me/keithrbennett

Sathya,
The gem that Keith referenced has its own mailing list, perhaps that
would be a better source for example code?

Gem: https://github.com/ruby-ldap/ruby-net-ldap
*List: *https://groups.google.com/forum/#!forum/ruby-ldap

Thanks Keith for responding to my post!!

Jruby ldap is available.Googled and found many pages but i am looking
for
exist steps…

If anybody has used jruby ldap. Kindly Guide me.

I can see in the mailing list there are some post in archive with old
dates
i.e., 5 years now.

Regards,
Sathya Prakash.

maybe you find that old project of mine useful
https://github.com/mkristian/dm-ldap-adapter

  • christian

Please find the below code in ruby… I am getting below error.

I have established ldap connection because i did not got any error
regarding the connection.

Any one help in setting parameter to search and employee by email/ name.

Error Message ::
Filter.java:330:in encodeSimpleFilter': javax.naming.directory.InvalidSearchFilterException: Missing 'equals'; from Filter.java:171:inencodeFilter’
from Filter.java:74:in encodeFilterString' from LdapClient.java:547:insearch’
from LdapCtx.java:1985:in doSearch' from LdapCtx.java:1847:insearchAux’
from LdapCtx.java:1772:in `c_search’

Code/Program :

require ‘ldap’
class LDAPCheck
def authenticate
puts “Step 1”

LDAP Details

ldap_host = ‘CSCDC8BLR001.asiapac.globalcsc.net
ldap_port =389
ldap_base_dn = ‘CN=Sathya Prakash Mullangi
chenchu,OU=Users,OU=Bangalore’ #
remove few details for secuirty purpose
ldap_base1_dn = ‘CN=Prakash ,OU=Users,OU=Bangalore’ # remove few
details
for secuirty purpose

ldap_filter=’(objectclass=sathya)’
ldap_attrs=nil
scope = LDAP::LDAP_SCOPE_SUBTREE
filter = ‘(objectclass=)’
attrs = [‘sn’, ‘cn’]

def print_entry(entry)
puts “IN Enter section”
puts “#{entry.vals(‘uid’)},#{entry.vals(‘givenName’)},
#{entry.vals(‘sn’)}, # {entry.vals(‘mail’)}”
end

puts “Step 2”

puts “I am trying to connect to #{ldap_host} :::port #{ldap_port}”
ldap_conn = LDAP::Conn.new(ldap_host, ldap_port)
ldap_conn.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 )

puts “ldap connection :::#{ldap_conn}”
ldap_conn.bind(ldap_base_dn, ‘My Password’) do |conn|
conn.search(ldap_base1_dn, LDAP::LDAP_SCOPE_SUBTREE,
“*.com”,[“name”,“mail”]) do |entry|
puts “#{entry.inspect}”
end
end

end
end
check = LDAPCheck.new

puts “#{check.authenticate}”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs