Discussion:
logonHours
(too old to reply)
Candi Suriano
2006-04-27 08:56:02 UTC
Permalink
I sure hope this is the last thing I struggle with :)

I'm trying to restrict the logon hours for a user. Here's the relevant
pieces of my code (that doesn't work). The strUserDN is correct as I set a
lot of other properties with this object.

Dim hour() As Byte = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0}
user = New DirectoryEntry(strUserDN)
user.Properties("logonHours").Value = hour
user.CommitChanges()

As always, thanks in advance.
--
Candi
Joe Kaplan (MVP - ADSI)
2006-04-27 15:50:51 UTC
Permalink
Unfortunately, there is no documentation for the binary format of the
logonHours attribute, so I'm not sure how to set it manually. I think
reverse engineering from AD U&C is the only way to go.

Joe K.
Post by Candi Suriano
I sure hope this is the last thing I struggle with :)
I'm trying to restrict the logon hours for a user. Here's the relevant
pieces of my code (that doesn't work). The strUserDN is correct as I set a
lot of other properties with this object.
Dim hour() As Byte = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0}
user = New DirectoryEntry(strUserDN)
user.Properties("logonHours").Value = hour
user.CommitChanges()
As always, thanks in advance.
--
Candi
nasnas
2006-04-28 09:51:36 UTC
Permalink
Post by Candi Suriano
I sure hope this is the last thing I struggle with :)
I'm trying to restrict the logon hours for a user. Here's the relevant
pieces of my code (that doesn't work). The strUserDN is correct as I set a
lot of other properties with this object.
Dim hour() As Byte = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0}
user = New DirectoryEntry(strUserDN)
user.Properties("logonHours").Value = hour
user.CommitChanges()
As always, thanks in advance.
--
Candi
nasnas
2006-04-28 09:55:08 UTC
Permalink
Hi,

There is a simple method that I use to set the logon hours.
I have use the DOS Command in my script:

Set adsUser= GetObject("WinNT://YOURDOMAIN/"&user)
set shl = createobject("wscript.shell")
shl.run "command /c net user "&user /times:Sunday-Saturday,16:00-03:00
/YOURDOMAIN"
adsuser.setinfo


Try this.

Loading...