问题
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}"
)
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/53891073/how-do-i-debug-ruby-ldap-when-a-method-only-returns-false