ruby net/ldap not able to handle errors -


Recently I started coding in Ruby. Although I am able to successfully bind, I have problems with add operation. It is okay, I wanted to print an error message so that I could correct the error. But unfortunately I am not able to handle the LDAPER. Below is my code listed.


  def add_user (user) dn = "cn =" + user.email_id + "," + ConfigReader.instance.ldapBaseDn attr = {: cn = & gt; User.email_id,: sn = & gt; User.short_name ,: email = & gt; User.email_id ,:mail = & gt; User.email_id ,: employeename = & gt; User.jabber_passwd ,: buildingname = & gt; User.image_url,: gidNumber = & gt; User.age ,: title = & gt; User.title ,: l = & gt; User.location ,: TelephoneNumber = & gt; User.phone_no ,: info = & gt; User.facebook_id ,: dmdName = & gt; User.twitter_id ,: initials = & gt; User.linkedin_id,: memberuid = & gt; User.jabber_id ,: userpassword = & gt; ConfigReader.instance.userPassword: cum = & gt; User.organization, Description = & gt; User.biography ,: objectclass = & gt; ["Top", "person", "organizational person", "int org partner", "extensible object"]} begin the DN @ ldap_connection.add (: dn = & gt; dn ,: attributes = & gt; attr ) Rescue Net :: LDAP:: LdapError = & gt; The error asserts that puts "failed" error. Backtrace end # until @ ldap_connection.add (: dn = & gt; dn ,: attributes = & gt; attr) # puts "unable to create user" + user.email_id + "in ldap" # Make sure the block contains the following error Reporting:  

add_user ': Undefined method for the backtrace' zero: NilClass (No.methodError) from test.rb: 7: in the block & Lt; Main & gt; 'Test.rb: 5: each of From Test.rb: 5: in `'

I need' rubygems' requirement 'net / ldap' is required 'singleton'

By the way Please help me in this regard.

Good! After the operation fails, the reason is displayed using the code given below:

ldap_connection.get_operation_result.to_s


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -