Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Just starting the scripting, and testing simply via:
AddExtender("wwwnt34i.dll") user="xxxxxxxxx" theflags=wntUserGetDat("\\server",user,"logon_hours",0) Message(user,theflags) exit
The result in the message is a hex value such as:
03FCFF03FCFF03FCFF03FCFF03FCFF03FCFF03FCFFIn the help for this it describes the bit values for the 168 bit binary return.
Is there any simple way to convert this to binary - and subsequently extrapolate to readable info? Or am I missing something? I've looked for hex-to-binary functions in help and searched messages for various keywords, but nothing specific to this found. I understand that I probably need to break the result into individual 'words' first.
Take a look at the following code and see if it meets the needs.
#DefineFunction LH_IsHourOn(sLogonHours,nDay,nHour,nTZOffset) Title01 = 'LH_IsHourOn()' ; Validate our input parameters if (StrLen(sLogonHours) != 42) TempMsg = StrCat(Title01,': Error! sLogonHours is not 42 characters in length.') IntControl(79,-1,7000,TempMsg,0) endif if (nDay < 0 || nDay > 6) TempMsg = StrCat(Title01,': Error! nDay is < 0 or is > 6.') IntControl(79,-1,7000,TempMsg,0) endif if (nHour < 0 || nHour > 23) TempMsg = StrCat(Title01,': Error! nHour is < 0 or is > 23.') IntControl(79,-1,7000,TempMsg,0) endif if (nTZOffset < -12 || nTZOffset > 12) TempMsg = StrCat(Title01,': Error! nTZOffset is < -12 or > 12.') IntControl(79,-1,7000,TempMsg,0) endif ; Convert our day & hour into a bit offset. BitOffset = (nDay * 3 * 8) + nHour ; Apply the TZ value to it BitOffset = BitOffset + nTZOffset ; Now test to see if we have "wrapped" around the end of our bit range if (BitOffset > 167) ; We went past the end of the range, wrap around from the beginning BitOffset = (168 - BitOffset) - 1 endif if (BitOffset < 0) ; We went past the beginning of the range, wrap around from the end BitOffset = 168 + BitOffset endif ; Convert our bit offset value into a hex digit pair # and a bit #. HexPairNum = BitOffset / 8 BitNum = BitOffset mod 8 ; Extract the hex digit pair from the logon hours string HexPair = StrSub(sLogonHours, (HexPairNum * 2) + 1, 2) ; Set up a 1 byte binary buffer to use for base conversion operations. ; This is done so we don't need the WILX extender loaded just for this ; particular UDF to work properly. hBuf = BinaryAlloc(1) if (hBuf == 0) TempMsg = StrCat(Title01,': Error! hBuf is zero.') IntControl(79,-1,7000,TempMsg,0) endif ; Poke our hex string into a binary buffer BinaryPokeHex(hBuf,0,HexPair) Byte = BinaryPeek(hBuf,0) if (Byte & (1 << BitNum)) bResult = @TRUE else bResult = @FALSE endif hBuf = BinaryFree(hBuf) return bResult #EndFunction
Article ID: W17055
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38