Ldap search not succeding in a single attempt

Discussion in 'Ruby' started by rahulc1982@gmail.com, Aug 17, 2007.

  1. Guest

    I am writing a code for user authentication from ldapserver in ruby.
    For that first i am doing an anonymous search on bluepages
    ldap_con = Net::LDAP.new
    ldap_con.host = 'X.Y.com'
    ldap_con.port = 389
    treebase = "ou=X,o=Y.com"
    user_filter = Net::LDAP::Filter.eq("notesShortName",username)
    dn = String.new
    @res = ldap_con.search( :base => treebase, :filter =>
    user_filter) do |entry|
    dn = entry.dn

    then getting "dn" and after that doing authentication with passwd and

    unless dn.empty?
    ldap_con.auth dn,password
    if ldap_con.bind
    login_succeeded = true
    But I am getting strange results. Some times the ldap search was
    successful some times not. Then i tried with putting the ldap search
    in a for loop and tried also to get the return code so I found like

    #<OpenStruct code=50, message="Insufficient Access Rights">
    #<OpenStruct code=50, message="Insufficient Access Rights">
    #<OpenStruct code=0, message="Success">

    I dont know why it is happening for same search( same parameters)

    Can you help me in this( why the search is not successful in first
    iteration) ?
    I also wants to tell you few Things
    1- First of all i was testing(doing anonymous ldap search) with
    A.Y.com and there was no problem with
    this server at all or i can say 100% results i got if intranetid/
    passwd were correct.
    2- I tried on command line ( "cmd" on windows ) with this
    ldapsearch -h A.Y.com -b o=Y.com emailaddress=
    ldapsearch -h X.Y.com -b o=Y.com emailaddress=
    both were giving me 100 % results.
    3- Then with the help of a ldap person in pune i tried with a ldap
    server here and there also i did not got any problem.

    Problem is there only with bluepages and how it can possible that for
    anonymous search it gives
    #<OpenStruct code=50, message="Insufficient Access Rights">
    #<OpenStruct code=50, message="Insufficient Access Rights">
    #<OpenStruct code=0, message="Success">

    Previously i was suspecting timeout but from the above lines it is
    clear that it is access permission related issue.
    Please help me in resolving this issue.

    One thing i forgot that the problem is only with ldapsearch, if we get
    correct "dn" there is no issues i faced in
    authentication means 100 % successful.

    Is it possible if i can see the logs on bluepages, that what is
    happening with my anonymous search on bluepages.

    Or do you have any idea about it?
    , Aug 17, 2007
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    Raymond DeCampo
    Feb 21, 2006
  2. rcmn
    Nov 6, 2006
  3. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
  4. Ian Macdonald
    Ian Macdonald
    Mar 15, 2005
  5. GMI
    Tad McClellan
    Jun 19, 2005

Share This Page