0
Answer

Active Directory - logonHours

Dwayne Soare

Dwayne Soare

17y
2.9k
1
Hi, I'm working on a screen saver that will log users out if they are outside of their allowed logon hours. I've done this all ready in vbscript as proof of concept and I'm 95% of the way there in C#. I'm having trouble getting the user logonHours property. It returns a System.Byte[] that should be 21 bytes. Each bit representing an hour out of the week. No matter how I get the property it always returns as a object, and I can't access the values of the byte array to sort them out. My current code to get the object looks like this: object objHours; DirectoryEntry userDSE = new DirectoryEntry("LDAP://" + userDN); objHours = userDSE.Properties["logonHours"][0]; The line that creates the object works, and I have tried creating the object 2 or 3 other ways. Through the logonHours object I cannot access the values of the array. I have also used a binary stream to convert the object in to a byte array, but the byte array returns a 48 byte array that I don't trust to stay constant in size. I would prefer to access the values through the object properly. I need some help. It would be appreciated. Thanks, Dwayne.