Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Converting Octet String to byte array for LogonHours attribute

$
0
0
Hi everyone,

I'm attempting to set the Logon Hours attribute for Active Directory with C# but I'm running into problems.

The Logon Hours attribute is bascially has an OctetString syntax. A typical value would be "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" (for all hours allowed). This in turn has to be converted into a byte array before it can be set as a Logon Hours attribute as shown below:

string logonHours = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";

byte[] hours = ToByteArray(logonHours);

public static byte[] ToByteArray(string str)
{
    System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
    return encoding.GetBytes(str);
}

However, this simply fails. I've been trawling through the web for some sorta solution but nothing has been forthcoming. I'm basically trying to convert an Octet String into a byte array. Can anyone point me to the right direction in this? Thanks!

Ryan

Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>