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
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