Hello all
Attached is the better patch for the same problem (see my previous mail below).
- According to RFC 2251 newSuperior should be sent as context-specific 0 type rather than octet string.

- Create an instance of RfcModifyDNRequest for LdapModifyDNRequest using new type for newSuprerior parameter - RfcLdapSuperDN (encoded as context-specific 0 type).

If no one objects, I'm going to commit.

Thanks,
Boris



Boris Kirzner wrote:
Hello all
Attached is a patch for RfcModifyDNRequest class :
- According to RFC 2251 newSuperior should be sent as context-specific 0 type rather than octet string.

If no one objects, I'm going to commit.
Boris


Index: RfcModifyDNRequest.cs =================================================================== --- RfcModifyDNRequest.cs (revision 42306) +++ RfcModifyDNRequest.cs (working copy) @@ -52,6 +52,16 @@ //************************************************************************* // Constructors for ModifyDNRequest //************************************************************************* + + // according to RFC 2251 : + // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE { + // entry LDAPDN, + // newrdn RelativeLDAPDN, + // deleteoldrdn BOOLEAN, + // newSuperior [0] LDAPDN OPTIONAL + // } + // i.e. newSuperior is a context-specific 0. + static readonly Asn1Identifier superiorId = new Asn1Identifier(Asn1Identifier.CONTEXT,false,0x0); /// <summary> </summary> public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN newrdn, Asn1Boolean deleteoldrdn):this(entry, newrdn, deleteoldrdn, null) @@ -64,8 +74,10 @@ add(entry); add(newrdn); add(deleteoldrdn); - if (newSuperior != null) + if (newSuperior != null) { + newSuperior.setIdentifier(superiorId); add(newSuperior); + } } /// <summary> Constructs a new Delete Request copying from the ArrayList of

-- 
Boris Kirzner
Mainsoft Corporation
http://www.mainsoft.com


//
// Novell.Directory.Ldap.Rfc2251.RfcLdapSuperDN.cs
//
// Author:
//   Boris Kirzner ([EMAIL PROTECTED])
//

using System;
using Novell.Directory.Ldap.Asn1;

namespace Novell.Directory.Ldap.Rfc2251
{
        ///<summary>Represents an [0] LDAP DN OPTIONAL used as newSuperior 
attribute of
        /// ModifyDNRequest (For more detail on this Syntax refer to rfc2251).
        /// </summary>
        public class RfcLdapSuperDN : Asn1Tagged
        {
                private sbyte[] content;
        
                /// <summary>
                /// ASN.1 [0] LDAP DN OPTIONAL tag definition.
                /// </summary>
                public static readonly int TAG = 0x00;

                /// <summary> ID is added for Optimization.
                /// Id needs only be one Value for every instance, thus we 
create it only once.
                /// </summary>
                protected static readonly Asn1Identifier ID = new 
Asn1Identifier(Asn1Identifier.CONTEXT, false, TAG);
           
                /// <summary> Constructs an RfcLDAPSuperDN object from a String 
object.
                /// </summary>
                /// <param name="content"> A string value that will be 
contained in the this RfcLDAPSuperDN object </param>
                public RfcLdapSuperDN(String s) : base(ID, new 
Asn1OctetString(s), false) //type is encoded IMPLICITLY 
                {                       
                        try {
                                System.Text.Encoding encoder = 
System.Text.Encoding.GetEncoding("utf-8"); 
                                byte[] ibytes = encoder.GetBytes(s);
                                sbyte[] 
sbytes=SupportClass.ToSByteArray(ibytes);

                                this.content = sbytes;
                        } 
                        catch(System.IO.IOException uee) {
                                throw new 
System.SystemException(uee.ToString());
                        }
                }
                
                /// <summary> Constructs an RfcLDAPSuperDN object from a byte 
array. </summary>
                /// <param name="content"> A byte array representing the string 
that will be contained in the this RfcLDAPSuperDN object </param>
                [CLSCompliantAttribute(false)]
                public RfcLdapSuperDN(sbyte[] ba) : base(ID, new 
Asn1OctetString(ba), false) //type is encoded IMPLICITLY 
                {                       
                        this.content = ba;
                }
        
                /// <summary> Encodes the current instance into the
                /// specified output stream using the specified encoder object.
                /// 
                /// </summary>
                /// <param name="enc">Encoder object to use when encoding self.
                /// 
                /// </param>
                /// <param name="out">The output stream onto which the encoded 
byte
                /// stream is written.
                /// </param>
                public override void  encode(Asn1Encoder enc, System.IO.Stream 
out_Renamed)
                {
                        enc.encode(this, out_Renamed);
                        return ;
                }

                /// <summary> Returns the content of this RfcLdapSuperDN as a 
byte array.</summary>
                [CLSCompliantAttribute(false)]
                public sbyte[] byteValue()
                {
                        return content;
                }
                
                
                /// <summary> Returns the content of this RfcLdapSuperDN as a 
String.</summary>
                public System.String stringValue()
                {
                        System.String s = null;
                        try {
                                System.Text.Encoding encoder = 
System.Text.Encoding.GetEncoding("utf-8"); 
                                char[] dchar = 
encoder.GetChars(SupportClass.ToByteArray(content));
                                s = new String(dchar);
                        }
                        catch (System.IO.IOException uee) {
                                throw new 
System.SystemException(uee.ToString());
                        }                       
                        return s;
                }
                
                
                /// <summary> Return a String representation of this 
RfcLdapSuperDN.</summary>
                public override System.String ToString()
                {
                        return base.ToString() + " " + stringValue();
                }

        }
}
Index: RfcModifyDNRequest.cs
===================================================================
--- RfcModifyDNRequest.cs       (revision 42505)
+++ RfcModifyDNRequest.cs       (working copy)
@@ -52,30 +52,19 @@
                
//*************************************************************************
                // Constructors for ModifyDNRequest
                
//*************************************************************************
-
-               // according to RFC 2251 :
-               // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-               //   entry           LDAPDN,
-               //   newrdn          RelativeLDAPDN,
-               //   deleteoldrdn    BOOLEAN,
-               //   newSuperior     [0] LDAPDN OPTIONAL
-               // }
-               // i.e. newSuperior is a context-specific 0.
-               static readonly Asn1Identifier superiorId = new 
Asn1Identifier(Asn1Identifier.CONTEXT,false,0x0);
-               
+       
                /// <summary> </summary>
                public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN 
newrdn, Asn1Boolean deleteoldrdn):this(entry, newrdn, deleteoldrdn, null)
                {
                }
                
                /// <summary> </summary>
-               public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN 
newrdn, Asn1Boolean deleteoldrdn, RfcLdapDN newSuperior):base(4)
+               public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN 
newrdn, Asn1Boolean deleteoldrdn, RfcLdapSuperDN newSuperior):base(4)
                {
                        add(entry);
                        add(newrdn);
                        add(deleteoldrdn);
                        if (newSuperior != null) {
-                               newSuperior.setIdentifier(superiorId);
                                add(newSuperior);
                        }
                }
Index: LdapModifyDNRequest.cs
===================================================================
--- LdapModifyDNRequest.cs      (revision 42505)
+++ LdapModifyDNRequest.cs      (working copy)
@@ -139,7 +139,7 @@
                /// <param name="cont">           Any controls that apply to 
the modifyDN request,
                /// or null if none.
                /// </param>
-               public LdapModifyDNRequest(System.String dn, System.String 
newRdn, System.String newParentdn, bool deleteOldRdn, LdapControl[] 
cont):base(LdapMessage.MODIFY_RDN_REQUEST, new RfcModifyDNRequest(new 
RfcLdapDN(dn), new RfcRelativeLdapDN(newRdn), new Asn1Boolean(deleteOldRdn), 
((System.Object) newParentdn != null)?new RfcLdapDN(newParentdn):null), cont)
+               public LdapModifyDNRequest(System.String dn, System.String 
newRdn, System.String newParentdn, bool deleteOldRdn, LdapControl[] 
cont):base(LdapMessage.MODIFY_RDN_REQUEST, new RfcModifyDNRequest(new 
RfcLdapDN(dn), new RfcRelativeLdapDN(newRdn), new Asn1Boolean(deleteOldRdn), 
((System.Object) newParentdn != null)?new RfcLdapSuperDN(newParentdn):null), 
cont)
                {
                        return ;
                }

Reply via email to