473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

[ActiveDirectory] Set logonHours ?

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
Nov 17 '05 #1
2 3879
>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
Nov 17 '05 #2
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.s et_Value(Object
value)"

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

What is the problem ? Thank you in advance...
JBrek
"Marc Scheuner [MVP ADSI]" wrote:
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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dirk Hagemann | last post by:
Hi! I'm working in an ActiveDirectory Network and want to get some information about a user-account or computer (OS for example) account. I think this works with the win32com.client module and the...
2
by: bob | last post by:
Hi, Is this the right place to dicuss Visual Studio 2005 and .Net 2? I am try to implement a class (already using Windows Authentication) where I am given a user name and I return a list of...
4
by: Sargas Atum | last post by:
Hi all, I am trying to get the field "lastLogon" out of ActiveDirectory. It should be trivial I thought, but it is not, as I have experienced. private DataRow FillDataRow( DataRow dataRow, ...
0
by: dhnriverside | last post by:
Hi guys I want to find out which of my ActiveDirectory users is logged on to a particular ActiveDirectory Computer. I can get what Computer a user is logged on to with ...
0
by: Uchi | last post by:
I was able to get the full details about the user by searching. but it does nt have a value called logonhours. how do i get the logonhours of a user using ldap in php Thanks. Uchi
0
by: =?Utf-8?B?dGhsMTAwMA==?= | last post by:
Hi, i need help getting the logonHours from AD for a specific user. I found a vbscript doing exactly what i want: On Error Resume Next Dim arrLogonHoursBytes(20) Dim arrLogonHoursBits(167)...
6
by: =?Utf-8?B?dGhsMTAwMA==?= | last post by:
Hi NG, i need to list the logonHours for a specific user. I'm trying to convert code from vbscript (is working) to vb.net, but the vb.net code does not work. Here are the code listings: 1:...
0
by: richardaz | last post by:
I have been working on a project to search for 250,000 different records in ActiveDirectory. The process takes a long time and I have tried everything to make it faster. Currently using...
0
by: myth0s | last post by:
Hi, The question: Is it possible to have two differents ActiveDirectory Membership Provider in web.config and change at run-time from the default provider to the second provider if the first one...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.