Forum: JRuby Reg: JRUBY to LDAP

6255b889d53f114e9a012375f9becd53?d=identicon&s=25 Sathya Prakash (Guest)
on 2014-02-03 14:55
(Received via mailing list)
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.
486ca04f06d968004643ce5b47376ded?d=identicon&s=25 Keith B. (keith_b)
on 2014-02-03 15:40
(Received via mailing list)
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
6255b889d53f114e9a012375f9becd53?d=identicon&s=25 Sathya Prakash (Guest)
on 2014-02-03 15:58
(Received via mailing list)
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.
A8f7c2b66fafa83e9537c1f82348f11d?d=identicon&s=25 Doug Hathaway (Guest)
on 2014-02-03 16:42
(Received via mailing list)
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
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-02-03 17:01
(Received via mailing list)
maybe you find that old project of mine useful
https://github.com/mkristian/dm-ldap-adapter

- christian
6255b889d53f114e9a012375f9becd53?d=identicon&s=25 Sathya Prakash (Guest)
on 2014-02-06 10:43
(Received via mailing list)
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:in `encodeFilter'
        from Filter.java:74:in `encodeFilterString'
        from LdapClient.java:547:in `search'
        from LdapCtx.java:1985:in `doSearch'
        from LdapCtx.java:1847:in `searchAux'
        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}"
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.