LISTING 3: The GetUserInfo Function Public Function GetUserInfo(stUserName As String, stServerName As String) As Long . . . btSNArray = stServerName & vbNullCharbtUNArray = stUserName & vbNullChar '* Call NetAPI function lgResult = NetUserGetInfo(btSNArray(0), btUNArray(0), 3, lgBufferPtr) GetUserInfo = lgResult '* Handle any errors If lgResult = 2221 Then MsgBox "UserName Not Found", vbExclamation + vbOKOnly, "Get Info Error" Exit Function ElseIf lgResult = 2351 Then MsgBox "ServerName Not Found: Invalid ComputerName", vbExclamation + vbOKOnly, "Get Info Error" Exit Function ElseIf lgResult <> 0 Then MsgBox "Error " & lgResult & " when querying User " & stUserName End If BEGIN CALLOUT A '* Dereference the pointer to the data structure CopyMemory UserStruct, lgBufferPtr, LenB(UserStruct) END CALLOUT A BEGIN CALLOUT B stUserInfo(name) = stUserName stUserInfo(password) = "" END CALLOUT B . . . BEGIN CALLOUT C ReDim btCommentArray(255) As Byte CopyMemory btCommentArray(0), UserStruct.lgUsri3_comment, 256 stComment = btCommentArray stComment = TrimUniStr(stComment) stUserInfo(comment) = stComment END CALLOUT C . . . BEGIN CALLOUT D '* Handle the byte array for the logon hours '* The bytes range from 0 to 20; the 22nd byte is null ReDim btHours(21) As Byte CopyMemory btHours(0), UserStruct.lgUsri3_logon_hours, 22 ReDim stMaskArray(21) As String K = 0 For J = 0 To 20 If btHours(J) = 255 Then K = K + 1 End If stMaskArray(J) = ByteToMask(CInt(btHours(J))) Next J If K = 21 Then stUserInfo(logon_hours) = "" ElseIf K < 21 And K >= 0 Then J = 0 For J = 0 To 20 stHoursList = stHoursList & stMaskArray(J) Next J stUserInfo(logon_hours) = stHoursList Else stUserInfo(logon_hours) = "" stProbNote = "Unable to determine value for Logon Hour Restrictions" stProbNote = stProbNote & Chr$(13) & "Default value will be used." stProbNote = stProbNote & Chr$(13) & "If you wanted the account restricted to no logon hours" stProbNote = stProbNote & Chr$(13) & "you should disable the account." MsgBox stProbNote, vbOKOnly + vbExclamation, "Logon Hours Invalid" End If END CALLOUT D . . . BEGIN CALLOUT E '* num_logons Values stUserInfo(num_logons) = CStr(UserStruct.lgUsri3_num_logons) END CALLOUT E . . . End Function