Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


wntUserGetDat and Logon_hours Flag

Keywords: 

Question:

Has anyone used the wntUserGetDat function with the "logon_hours" flag?

I have been unable to decipher the string I am receiving from winbatch. The help file claims to give a 21-byte string, I am receiving a 42 byte string in hexadecimal format.

The call is as follows:

AddExtender("WWWNT34I.DLL")
flags=wntUserGetDat("\\cspdc","smithj","logon_hours")
Can someone give me a little insight on this?

Answer:

There is a 21 byte string that contains the information in a binary format.

WinBatch cannot handle that kind of binary value so it converts it to acsii hexadecimal format, doubling the size. So yes the string you get back is 42 bytes long but it represents only 21 bytes of data.

Each byte is 8 bits.

21 * 8 = 168
there are 168 unique bits of data.
Each week has 7 days
There are 24 hours in a day

7 * 24 = 168

There are 168 hours in a week.

Each bit represents one hour. If the bit is set the user may logon during that hour.
There may be a GMT offset involved.
The easiest way it to set a user up exactly how you want them with user manager, then do a wntUserGetDat on the string and save it.

You can use that same string in a wntUserSetDat.

And another user phrases the answer this way...

You are getting 21 bytes of information encoded as hexadecimal digits. Each pair of digits (nibbles) represents one byte of the actual data. Use the WILX34I.DLL extender to make the xBaseConvert() function available if you want to convert this data to a numeric value.

Each bit that is on represents one hour, starting at 00:00 on, I think, Monday. As you progress through the hours, you cross over into the next day. At 1 hour per bit you get 8 hours per byte. At 24 hours in a day, you get 3 bytes per day and multiplying by 7 days you get 21 bytes.

The time is biased relative to GMT. Your local system will apply your time zone information when processing the logon hours restrictions. This complicates matters a bit when figuring out how to properly manipulate the logon hours setting. User Manager [for Domains] automatically applies the time zone information of the computer on which it is running when diplaying this information and when allowing you to modify it. As an experiment, disable just a single hour at some readily identifiable point like the start, middle or end of one or more days during the week. Then use wntUserGetDat() to obtain the hex string and see what it looks like since it will be stored biased by GMT and not your local time zone.


Article ID:   W14385
Filename:   wntUserGetDat and Logon_hours Flag.txt