[ActiveDirectory] Set logonHours ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

How can i set the LogonHours to users, using System.DirectoryServices?

I think I must create a byte array, but it doesn't work.


Thanks in advance, JBrek
 
How can i set the LogonHours to users, using System.DirectoryServices?
I think I must create a byte array, but it doesn't work.

Yes, that's exactly how you do it - can you show us the code that
you're using? What is not working? Do you get an error? Where, and
what exactly is it?

Marc
 
So, the code I used to send logonhours data to AD :

DirEntry.Properties["logonHours"].Value = baLogonHours as object; //
baLogonHours = byte[]

the code I used to create the byte array :
private byte[] ArrayTologonHours(bool[,] arrblnLogonHoursA)
{
byte[] byteLogonHour = new byte[21];

// Mise en forme avec changement de l'ordre de la semaine
int index21 = 0;
int index24 = 0;
for(int i=1; i <= 7; i++)
{
for(int j=1;j <= 3;j++)
{


byte byte8Hours = new byte();
for(int k=7; k >= 0; k--)
{
if (i < 7)
{
if (arrblnLogonHoursA[i,index24])
byte8Hours += (byte)Math.Pow(2, (double)k);
}
else
{
if (arrblnLogonHoursA[0,index24])
byte8Hours += (byte)Math.Pow(2, (double)k);

}
index24++;
}
byteLogonHour[index21] = byte8Hours;
index21++;
}
index24 = 0;
}
return byteLogonHour;
}

I got this error :
"Erreur non spécifiée
Active Directory at System.DirectoryServices.Interop.IAds.PutEx(Int32
lnControlCode, String bstrName, Object vProp)
at System.DirectoryServices.PropertyValueCollection.set_Value(Object
value)"

at the line where I send the datas to AD...

What is the problem ? Thank you in advance...
JBrek
 
Back
Top