Re: Does anyone know if BerConverter class runs on Win 2000 server

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



IMO your encode blob is not valid.
When I decode your blob on XP SP2 or W2K3 I get :
BerConversionException:An error occurred during the BER conversion.

The encoded string should look libe this, notice the header 48, 132, 0, 0,
0, 62 where 0,0,0,62 is the length of the blob

48, 132, 0, 0, 0, 62, 2, 1, 0, 2, 1, 1, 2, 1, 1, 27, 3, 53, 56, 53, 2, 1,
1, 27, 0, 27, 11, 47, 98, 105, 110, 47, 115, 104, 101, 108, 108, 115, 27,
16, 47, 116, 109, 112, 47, 104, 111, 109, 101, 47, 100, 105, 114, 105, 118,
101, 27, 4, 49, 54, 49, 50

Try following program using the modified blob you'll see what I mean.

using System;
using System.IO;
using System.Threading;
using System.Security;
//
// csc.exe /r:System.DirectoryServices.Protocols.dll Berprobl.cs

using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Globalization;

using System.DirectoryServices.Protocols;
namespace Willys
{
class Tester
{
//
// Converts a byte[] to a hex string
//
public static string ByteArrayToStringInHex(byte[] bytes)
{
StringBuilder s = new StringBuilder(bytes.Length/2);
foreach(byte b in bytes)
{
s.Append(String.Format(CultureInfo.InvariantCulture, "0x{0:X2},"
,b));
}
string retStr = s.ToString();

// remove the last comma character
retStr = retStr.Remove(retStr.Length-1,1);
return retStr;
}
static void Main()
{
byte[] berEncodedValue = {
48, 132, 0, 0, 0, 62, 2, 1, 0, 2, 1, 1, 2, 1, 1, 27, 3, 53, 56, 53, 2, 1,
1, 27, 0, 27, 11, 47, 98, 105, 110, 47, 115, 104, 101, 108, 108, 115, 27,
16, 47, 116, 109, 112, 47, 104, 111, 109, 101, 47, 100, 105, 114, 105, 118,
101, 27, 4, 49, 54, 49, 50
};
try
{
Console.WriteLine("\r\nBer decoding the byte array...");
object[] decodedObjects = BerConverter.Decode("{iiiaiaaaa}",
berEncodedValue);

Console.WriteLine("\r\nThe decoded objects are:");
foreach(object o in decodedObjects)
{
if(o is byte[])
{
Console.WriteLine(ByteArrayToStringInHex((byte[])o));
}
else if (o is byte[][])
{
byte[][] byteArrays = (byte[][])o;
for(int i=0;i<byteArrays.Length;i++)
{
Console.Write(ByteArrayToStringInHex(byteArrays[i])
+ " - ");
}
Console.WriteLine();
}
else if(o is string[])
{
string[] strArray = (string[])o;
for(int i=0;i<strArray.Length;i++)
{
Console.Write(strArray[i] + " - ");
}
Console.WriteLine();
}
else
{
Console.WriteLine(o);
}
}
}
catch(BerConversionException e)
{
Console.WriteLine("BerConversionException:" + e.Message);
}
catch(ArgumentException e)
{
Console.WriteLine("ArgumentException:" + e.Message);
}
}
}
}

Seems like your problem relates to the encoding done outside the managed
memory space.

Willy.


"Pucca" <Pucca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C0675E42-D326-4AF9-B7A1-697962CCB749@xxxxxxxxxxxxxxxx
| Hi Willy, The meetingBlob property was encoded in my C++ application.
Here
| is the content I got during the Debug mode in C#. Thank you.
|
| - enMeetingBlob {Dimensions:[58]} byte[]
| [0] 96 byte
| [1] 56 byte
| [2] 2 byte
| [3] 1 byte
| [4] 0 byte
| [5] 2 byte
| [6] 1 byte
| [7] 1 byte
| [8] 2 byte
| [9] 1 byte
| [10] 1 byte
| [11] 27 byte
| [12] 3 byte
| [13] 53 byte
| [14] 56 byte
| [15] 53 byte
| [16] 2 byte
| [17] 1 byte
| [18] 1 byte
| [19] 27 byte
| [20] 0 byte
| [21] 27 byte
| [22] 11 byte
| [23] 47 byte
| [24] 98 byte
| [25] 105 byte
| [26] 110 byte
| [27] 47 byte
| [28] 115 byte
| [29] 104 byte
| [30] 101 byte
| [31] 108 byte
| [32] 108 byte
| [33] 115 byte
| [34] 27 byte
| [35] 16 byte
| [36] 47 byte
| [37] 116 byte
| [38] 109 byte
| [39] 112 byte
| [40] 47 byte
| [41] 104 byte
| [42] 111 byte
| [43] 109 byte
| [44] 101 byte
| [45] 47 byte
| [46] 100 byte
| [47] 105 byte
| [48] 114 byte
| [49] 105 byte
| [50] 118 byte
| [51] 101 byte
| [52] 27 byte
| [53] 4 byte
| [54] 49 byte
| [55] 54 byte
| [56] 49 byte
| [57] 50 byte
|
| --
| Thanks.
|
|
| "Willy Denoyette [MVP]" wrote:
|
| > From what you posted I see that you are simply passing the meetingBlob
| > property, this property isn't ber encoded, right!
| > What I would like to see is the real contents of the blob (the byte
array);
| >
| > Willy.
| >
| >
| > "Pucca" <Pucca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
| > news:151E3AD4-10B0-4B7C-91B2-1E7EF760B3C9@xxxxxxxxxxxxxxxx
| > | Hi Willy,
| > | Thank you for the reply and here is more information about my code and
the
| > | problem I'm having.
| > |
| > | I'm getting the following error message in the catch
| > | "BerConversionException: An error occurred during the BER conversion."
| > |
| > | Here is the calling code. I'm passing the meetingBlob attribute of
the
| > | meeting class in Active Directory Schema to decode:
| > | enMeetingBlob =
| > | ((byte[])child.Properties["meetingBlob"].Value);
| > | meetingBlob =
| > | CUnityDS.DecodeMeetingBlob(enMeetingBlob);
| > |
| > | Here is the method that decodes it I got the error at the following
line
| > of
| > | code:
| > | object[] decodedObjects = BerConverter.Decode("{iiiaiaaaa}",
| > | encodedMeetingBlob);
| > |
| > |
| > | public static string DecodeMeetingBlob(byte[] encodedMeetingBlob)
| > | {
| > | string meetingBlob = null;
| > | //Decode it
| > | object[] decodedObjects = BerConverter.Decode("{iiiaiaaaa}",
| > | encodedMeetingBlob);
| > | foreach (object o in decodedObjects)
| > | {
| > | if (o is byte[])
| > | {
| > | meetingBlob += (ByteArrayToStringInHex((byte[])o));
| > | }
| > | else if (o is byte[][])
| > | {
| > | byte[][] byteArrays = (byte[][])o;
| > | for (int i = 0; i < byteArrays.Length; i++)
| > | {
| > | meetingBlob +=
| > (CUnityDS.ByteArrayToStringInHex(byteArrays[i])
| > | + " - ");
| > | }
| > | //Console.WriteLine();
| > | }
| > | else if (o is string[])
| > | {
| > | string[] strArray = (string[])o;
| > | for (int i = 0; i < strArray.Length; i++)
| > | {
| > | meetingBlob += (strArray[i] + " - ");
| > | }
| > | //Console.WriteLine();
| > | }
| > | else
| > | {
| > | meetingBlob += "\n";
| > | //Console.WriteLine(o);
| > | }
| > | }
| > | string test = meetingBlob;
| > | return meetingBlob;
| > | }
| > | }//end CUnityDS
| > | --
| > | Thanks.
| > |
| > |
| > | "Willy Denoyette [MVP]" wrote:
| > |
| > | > Just checked and I see no reason it should not work on W2K, mind to
post
| > a
| > | > short but complete sample that illustrates your issue.
| > | >
| > | > Willy.
| > | >
| > | > "Pucca" <Pucca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
| > | > news:8F165064-081E-4B0D-986B-FD91502FC62A@xxxxxxxxxxxxxxxx
| > | > | I'm getting an error when I tried to use this BerConverter class
in my
| > C#
| > | > | code. Even though the Interent doc says that it runs on Win2000
sp4,
| > I
| > | > just
| > | > | thgouth I'll double check. Does anyone know if BerConverter is
| > supported
| > | > for
| > | > | Win2000 server?
| > | > |
| > | >
| >
http://msdn2.microsoft.com/en-us/library/system.directoryservices.protocols.berconverter.decode.aspx
| > | > | --
| > | > | Thanks.
| > | >
| > | >
| > | >
| >
| >
| >


.



Relevant Pages

  • Re: Need a bit of information about Compression
    ... either encode a full length, or a length mod some constant. ... Yes, full Length coding, arithmetic coding which is certainly better ... if you are decoding, say, 1024 symbols, then you stop as soon as you decode ... less common is to set up some special condition, where the eof is ...
    (comp.compression)
  • Re: Sending floats over a client-server in Smalltalk
    ... The trick is knowing what to decode them ... Then encode the number in the remaining bytes. ... ByteString>>floatAt: byteIndex ... I could then take a string ...
    (comp.lang.smalltalk)
  • Re: How to flip a coin over e-mail?
    ... >between these outcomes. ... You encode the room descriptions with your key A, coding each entry ... there's one entry left on the list which you can decode to ...
    (sci.math)
  • Re: Beginners thread
    ... So I am now encoding and decoding Million Digit binary file. ... So fingers crossed that all goes well but I see the same decode data ... I am suggesting Encode be ...
    (comp.compression)
  • Re: unicode and hashlib
    ... Of course my dyslexia sticks out here as I get encode and decode exactly ... Characters are "encoded" to a byte format. ... You decode from on character set to a unicode object ...
    (comp.lang.python)