A brief explanation on how to interpret the 'logon hours' member of the USER_INFO structuresIntroduction
On my Windows 7 machine, I happened upon the Time Limits dialog used by Parental Controls. This intrigued me enough to wonder how this information might be obtained. I quickly found the NetUserGetInfo() function. This function populates one of nine different USER_INFO_x structures with various information about a particular user account on a server. However, each time I found an example of what the members of the structure looked like, they all treated the usriX_logon_hours member the same: as 21 separate bytes. Printing the other structure members formatted with %s or %d is fine, but I found nothing useful from looking at that member formatted with %x. Thus, my mission began...
Reading the arrayMSDN tells us that the usriX_logon_hours member is a 168-bit array (laid out from 0 to 167) with each bit representing an hour of the day. I set one of the user accounts on my computer to have the following allowed times: Sun 13-20; Mon-Thu, Sat 9-20; Fri 9-21. If you laid this array out so that it looked like a typical 24-hour week, you'd have the following (with the alternating shades of gray showing the byte boundaries). Read more: Codeproject
On my Windows 7 machine, I happened upon the Time Limits dialog used by Parental Controls. This intrigued me enough to wonder how this information might be obtained. I quickly found the NetUserGetInfo() function. This function populates one of nine different USER_INFO_x structures with various information about a particular user account on a server. However, each time I found an example of what the members of the structure looked like, they all treated the usriX_logon_hours member the same: as 21 separate bytes. Printing the other structure members formatted with %s or %d is fine, but I found nothing useful from looking at that member formatted with %x. Thus, my mission began...
Reading the arrayMSDN tells us that the usriX_logon_hours member is a 168-bit array (laid out from 0 to 167) with each bit representing an hour of the day. I set one of the user accounts on my computer to have the following allowed times: Sun 13-20; Mon-Thu, Sat 9-20; Fri 9-21. If you laid this array out so that it looked like a typical 24-hour week, you'd have the following (with the alternating shades of gray showing the byte boundaries). Read more: Codeproject
0 comments:
Post a Comment