Rayhan Muktader
Rayhan Muktader

Reputation: 2106

How do I debug ruby-ldap when a method only returns false?

My goal is to move an account to another OU. My understanding is that the following code should do the job. However, it returns false. There is no error, warning or exceptions. How do I debug why this isn't working?

secure_ldap.rename(
    olddn: self.dn, 
    newrdn: "CN=#{self.cn}", 
    delete_attributes: true, 
    new_superior: "#{ou}"
  )

Upvotes: 0

Views: 302

Answers (2)

lacostenycoder
lacostenycoder

Reputation: 11226

The error is not a ruby error. When dealing with ruby standard lib interfaces to system programs such as LDAP, refer to it's own documentation source.

In your case you're probably looking for https://ldap.com/ldap-dns-and-rdns/ which explains strings to use and which ones need to be escaped.

Upvotes: 0

anothermh
anothermh

Reputation: 10556

Well, one approach might be to add pry and pry-byebug to your application. Modify your code to include binding.pry then run your application:

Frame number: 0/0

From: ./test.rb @ line 1 :

 => 1: binding.pry
    2: secure_ldap.rename(
    3:   olddn: self.dn,
    4:   newrdn: "CN=#{self.cn}",
    5:   delete_attributes: true,
    6:   new_superior: "#{ou}"

=> 

Now use step to step through the execution line by line. It will allow you to step into the rename method call inside of net-ldap, and for example inspect the local variables within that method call.

Upvotes: 1

Related Questions