views:

1081

answers:

3

I'm importing data into an LDAP store. The attribute in question is of type OctetString. I have a normal string that I need to get into that attribute.

I'm using C# (.net 3.5)

How do I do it?

A: 

An OctetString appears to simply be a string represented as an array of bytes (hence octets).

The MSDN page on Octet String (SID) Property Type provides the following example for writing an Octet String:

byte[] usrSID = (byte[])usr.Properties["objectSid"].Value;
usr.Properties["objectSid "].Clear();
usr.Properties["objectSid "].Value = usrSID;
usr.CommitChanges();
Noldorin
A: 

As far as I know, an OctetString is just a byte array. Not to be confused with Octal (base 8)

Completely open to correction but some random googling would seem to agree... This will convert your string to a byte array

byte[] octets = System.Text.Encoding.ASCII.GetBytes("abcd");
Eoin Campbell
A: 
System.Text.Encoding utf8 = System.Text.Encoding.UTF8;
byte[] octets = utf8.GetBytes("Réne");
Demi