Bom dia Pessoal,
Sou meio leigo no assunto, e estou fazendo um sistema em access,
ele ja esta quase pronto so falta uma coisa rastrear as alterações dos usuarios(fazer um log) peguei o exemplo do JPaulo, e vi que era sensacional, mas não consigo coloca-lo na minha tabela, alguem pode me ajudar?
o BD ta Anexo...sei que é meio folga mas eu precisava entrgar esse sistema hj =\
obrigado desde ja...
Option Compare Database
Option Explicit
'By JPaulo 2007
Const MAX_IP = 5
Type IPINFO
dwAddr As Long
dwIndex As Long
dwMask As Long
dwBCastAddr As Long
dwReasmSize As Long
unused1 As Integer
unused2 As Integer
End Type
Type MIB_IPADDRTABLE
dEntrys As Long
mIPInfo(MAX_IP) As IPINFO
End Type
Type IP_Array
mBuffer As MIB_IPADDRTABLE
BufferLen As Long
End Type
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
Declare Function TSB_API_GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserName_TSB() As String
Dim lngLen As Long
Dim strBuf As String
Const MaxUserName = 255
strBuf = Space(MaxUserName)
lngLen = MaxUserName
If CBool(TSB_API_GetUserName(strBuf, lngLen)) Then
GetUserName_TSB = Left$(strBuf, lngLen - 1)
Else
GetUserName_TSB = ""
End If
End Function
'Busca o nome do usuário
'Function GetNetworkUser() As String
'GetNetworkUser = Environ("USERNAME")
'End Function
'---------------------------------------------
'Busca o nome do computador
Function GetNetworkComp() As String
GetNetworkComp = Environ("ComputerName")
End Function
Public Function DameIpMaquina() As String
Dim Ret As Long, Tel As Long
Dim bBytes() As Byte
Dim TempList() As String
Dim TempIP As String
Dim Tempi As Long
Dim Listing As MIB_IPADDRTABLE
Dim L3 As String
On Error GoTo END1
GetIpAddrTable ByVal 0&, Ret, True
If Ret <= 0 Then Exit Function
ReDim bBytes(0 To Ret - 1) As Byte
ReDim TempList(0 To Ret - 1) As String
GetIpAddrTable bBytes(0), Ret, False
CopyMemory Listing.dEntrys, bBytes(0), 4
For Tel = 0 To Listing.dEntrys - 1
CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(Tel))
TempList(Tel) = ConvertaaString(Listing.mIPInfo(Tel).dwAddr)
Next Tel
TempIP = TempList(0)
For Tempi = 0 To Listing.dEntrys - 1
L3 = Left(TempList(Tempi), 3)
If L3 <> "169" And L3 <> "127" And L3 <> "192" Then
TempIP = TempList(Tempi)
End If
Next Tempi
DameIpMaquina = TempIP 'devolve o IP
Exit Function
END1:
DameIpMaquina = ""
End Function
Public Function ConvertaaString(longAddr As Long) As String
Dim myByte(3) As Byte
Dim Cnt As Long
CopyMemory myByte(0), longAddr, 4
For Cnt = 0 To 3
ConvertaaString = ConvertaaString + CStr(myByte(Cnt)) + "."
Next Cnt
ConvertaaString = Left$(ConvertaaString, Len(ConvertaaString) - 1)
End Function
Public Function LoggedUser(frm As Form, Optional bHasInactive As Boolean = False) As Boolean
Dim User_Windows As String
Dim CPU As String
Dim IP_Number As String
Dim USER_DB As String
Dim Connect As String
If UserAccessName = Null Then UserAccessName = 0
User_Windows = GetUserName_TSB
CPU = GetNetworkComp
IP_Number = DameIpMaquina()
USER_DB = UserAccessName
Connect = "Connected"
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblLoggeduser ( Data_Acesso,UserAccess,UserWindows,CPU_Name,IP,Status) SELECT '" & Now() & "','" & USER_DB & "','" & User_Windows & "','" & CPU & "','" & IP_Number & "','" & Connect & " ';"
Exit_LoggedUser:
Exit Function
End Function
Sou meio leigo no assunto, e estou fazendo um sistema em access,
ele ja esta quase pronto so falta uma coisa rastrear as alterações dos usuarios(fazer um log) peguei o exemplo do JPaulo, e vi que era sensacional, mas não consigo coloca-lo na minha tabela, alguem pode me ajudar?
o BD ta Anexo...sei que é meio folga mas eu precisava entrgar esse sistema hj =\
obrigado desde ja...
Option Compare Database
Option Explicit
'By JPaulo 2007
Const MAX_IP = 5
Type IPINFO
dwAddr As Long
dwIndex As Long
dwMask As Long
dwBCastAddr As Long
dwReasmSize As Long
unused1 As Integer
unused2 As Integer
End Type
Type MIB_IPADDRTABLE
dEntrys As Long
mIPInfo(MAX_IP) As IPINFO
End Type
Type IP_Array
mBuffer As MIB_IPADDRTABLE
BufferLen As Long
End Type
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
Declare Function TSB_API_GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserName_TSB() As String
Dim lngLen As Long
Dim strBuf As String
Const MaxUserName = 255
strBuf = Space(MaxUserName)
lngLen = MaxUserName
If CBool(TSB_API_GetUserName(strBuf, lngLen)) Then
GetUserName_TSB = Left$(strBuf, lngLen - 1)
Else
GetUserName_TSB = ""
End If
End Function
'Busca o nome do usuário
'Function GetNetworkUser() As String
'GetNetworkUser = Environ("USERNAME")
'End Function
'---------------------------------------------
'Busca o nome do computador
Function GetNetworkComp() As String
GetNetworkComp = Environ("ComputerName")
End Function
Public Function DameIpMaquina() As String
Dim Ret As Long, Tel As Long
Dim bBytes() As Byte
Dim TempList() As String
Dim TempIP As String
Dim Tempi As Long
Dim Listing As MIB_IPADDRTABLE
Dim L3 As String
On Error GoTo END1
GetIpAddrTable ByVal 0&, Ret, True
If Ret <= 0 Then Exit Function
ReDim bBytes(0 To Ret - 1) As Byte
ReDim TempList(0 To Ret - 1) As String
GetIpAddrTable bBytes(0), Ret, False
CopyMemory Listing.dEntrys, bBytes(0), 4
For Tel = 0 To Listing.dEntrys - 1
CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(Tel))
TempList(Tel) = ConvertaaString(Listing.mIPInfo(Tel).dwAddr)
Next Tel
TempIP = TempList(0)
For Tempi = 0 To Listing.dEntrys - 1
L3 = Left(TempList(Tempi), 3)
If L3 <> "169" And L3 <> "127" And L3 <> "192" Then
TempIP = TempList(Tempi)
End If
Next Tempi
DameIpMaquina = TempIP 'devolve o IP
Exit Function
END1:
DameIpMaquina = ""
End Function
Public Function ConvertaaString(longAddr As Long) As String
Dim myByte(3) As Byte
Dim Cnt As Long
CopyMemory myByte(0), longAddr, 4
For Cnt = 0 To 3
ConvertaaString = ConvertaaString + CStr(myByte(Cnt)) + "."
Next Cnt
ConvertaaString = Left$(ConvertaaString, Len(ConvertaaString) - 1)
End Function
Public Function LoggedUser(frm As Form, Optional bHasInactive As Boolean = False) As Boolean
Dim User_Windows As String
Dim CPU As String
Dim IP_Number As String
Dim USER_DB As String
Dim Connect As String
If UserAccessName = Null Then UserAccessName = 0
User_Windows = GetUserName_TSB
CPU = GetNetworkComp
IP_Number = DameIpMaquina()
USER_DB = UserAccessName
Connect = "Connected"
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblLoggeduser ( Data_Acesso,UserAccess,UserWindows,CPU_Name,IP,Status) SELECT '" & Now() & "','" & USER_DB & "','" & User_Windows & "','" & CPU & "','" & IP_Number & "','" & Connect & " ';"
Exit_LoggedUser:
Exit Function
End Function