Protocol correction for rename (context-sensitive encoding for new_superior) #32

MikeWillCook opened this Issue Feb 21, 2012 · 1 comment

2 participants


It looks like the rename method needs to specify the "new_superior" attribute with context-specific encoding. From RFC2251 section 4.9 we see:

ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
        entry           LDAPDN,
        newrdn          RelativeLDAPDN,
        deleteoldrdn    BOOLEAN,
        newSuperior     [0] LDAPDN OPTIONAL }
I've confirmed this fix then matches other LDAP clients, and I can successfully perform an object move in AD. Here's a quick patch which corrects this problem, for your consideration:
--- lib/net/ldap.rb
+++ lib/net/ldap.rb
@@ -1537,7 +1537,7 @@ def rename args
     new_superior = args[:new_superior]
     request = [old_dn.to_ber, new_rdn.to_ber, delete_attrs.to_ber]
-    request << new_superior.to_ber unless new_superior == nil
+    request << new_superior.to_ber_contextspecific(0) unless new_superior == nil
     pkt = [next_msgid.to_ber, request.to_ber_appsequence(12)].to_ber_sequence
     @conn.write pkt
@RoryO RoryO pushed a commit that referenced this issue Feb 29, 2012
Rory OConnell Correction for rename #32 51597ea

Looks reasonable, thanks!

@RoryO RoryO closed this Feb 29, 2012
@mikegee mikegee added a commit to ASCTech/ruby-net-ldap that referenced this issue Jun 27, 2012
Rory OConnell Correction for rename #32 016273e
@astratto astratto pushed a commit to astratto/ruby-net-ldap that referenced this issue Dec 18, 2015
Rory OConnell Correction for rename #32 592a764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment