Récuperation de l'adresse IP
Public Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
'
Declare Public Function gethostname Lib "WSOCK32.DLL" (Byval szHost As String, Byval dwHostLen As Long) As Long
Declare Public Function gethostbyname Lib "WSOCK32.DLL" (Byval szHost As String) As Long
Declare Public Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, Byval hpvSource As Long, Byval cbCopy As Long)
'
Dim connectionType As Integer
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
'
' Portal initialization routine
'
' Thierry Cayla 19/12/2001
' RADTeam EY-France
'
'
' first, we determine if network connected
'
Dim session As NotesSession
Dim tempDb As NotesDatabase
Dim portServer As String
Dim portPath As String
'
Dim HostName As String * 256
Dim HostPointer As Long
Dim HostStruct As HOSTENT
Dim HostAddressPointer As Long
Dim HostAddress As Long
Dim AddressNum As String
Dim IPAddress As String
'
Set session = New NotesSession
'
portServer = "FR200/SVR/EY-France/FR"
portPath = "names.nsf"
'
Set tempDb = New NotesDatabase ( portServer, portPath )
If ( tempDb.IsOpen ) Then ' we are network connected
'
' we determine if connection is RAS or LAN
'
gethostname HostName, 256
HostName = Trim$ ( HostName )
HostPointer = gethostbyname ( HostName )
'
CopyMemory HostStruct, HostPointer, Len ( HostStruct )
CopyMemory HostAddressPointer, HostStruct.hAddrList, 4
CopyMemory HostAddress, HostAddressPointer, 4
'
AddressNum = Trim$ ( Hex ( HostAddress ) )
AddressNum = String ( 8 - Len ( AddressNum ), Asc ( "0" ) ) & AddressNum
'
IPAddress = Cstr ( Cint ( "&H" & Mid ( AddressNum, 7 ) ) ) & "." & Cstr ( Cint ( "&H" & Mid ( AddressNum, 5, 2 ) ) ) & "." & Cstr ( Cint ( "&H" & Mid ( AddressNum, 3, 2) ) ) & "." & Cstr ( Cint ( "&H" & Left ( AddressNum, 2 ) ) )
'
Print ">> Votre adresse IP: " & IPAddress
If ( ( Left$ ( IPAddress, 11 ) = "132.220.200" ) Or ( Left$ ( IPAddress, 9 ) = "199.52.81" ) ) Then
Call session.SetEnvironmentVar ( "EY_NET_CONNECTION_TYPE", "2", False )
connectionType = 2
Print ">> Vous êtes connecté en RAS..."
Else
Call session.SetEnvironmentVar ( "EY_NET_CONNECTION_TYPE", "1", False )
connectionType = 1
Print ">> Vous êtes connecté en LAN..."
End If
'
Else ' we are disconnected from the network
Call session.SetEnvironmentVar ( "EY_NET_CONNECTION_TYPE", "0", False )
connectionType = 0
Print ">> Vous êtes déconnecté du réseau..."
End If ' ( tempDb.IsOpen )
'
End Sub
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
'
Declare Public Function gethostname Lib "WSOCK32.DLL" (Byval szHost As String, Byval dwHostLen As Long) As Long
Declare Public Function gethostbyname Lib "WSOCK32.DLL" (Byval szHost As String) As Long
Declare Public Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, Byval hpvSource As Long, Byval cbCopy As Long)
'
Dim connectionType As Integer
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
'
' Portal initialization routine
'
' Thierry Cayla 19/12/2001
' RADTeam EY-France
'
'
' first, we determine if network connected
'
Dim session As NotesSession
Dim tempDb As NotesDatabase
Dim portServer As String
Dim portPath As String
'
Dim HostName As String * 256
Dim HostPointer As Long
Dim HostStruct As HOSTENT
Dim HostAddressPointer As Long
Dim HostAddress As Long
Dim AddressNum As String
Dim IPAddress As String
'
Set session = New NotesSession
'
portServer = "FR200/SVR/EY-France/FR"
portPath = "names.nsf"
'
Set tempDb = New NotesDatabase ( portServer, portPath )
If ( tempDb.IsOpen ) Then ' we are network connected
'
' we determine if connection is RAS or LAN
'
gethostname HostName, 256
HostName = Trim$ ( HostName )
HostPointer = gethostbyname ( HostName )
'
CopyMemory HostStruct, HostPointer, Len ( HostStruct )
CopyMemory HostAddressPointer, HostStruct.hAddrList, 4
CopyMemory HostAddress, HostAddressPointer, 4
'
AddressNum = Trim$ ( Hex ( HostAddress ) )
AddressNum = String ( 8 - Len ( AddressNum ), Asc ( "0" ) ) & AddressNum
'
IPAddress = Cstr ( Cint ( "&H" & Mid ( AddressNum, 7 ) ) ) & "." & Cstr ( Cint ( "&H" & Mid ( AddressNum, 5, 2 ) ) ) & "." & Cstr ( Cint ( "&H" & Mid ( AddressNum, 3, 2) ) ) & "." & Cstr ( Cint ( "&H" & Left ( AddressNum, 2 ) ) )
'
Print ">> Votre adresse IP: " & IPAddress
If ( ( Left$ ( IPAddress, 11 ) = "132.220.200" ) Or ( Left$ ( IPAddress, 9 ) = "199.52.81" ) ) Then
Call session.SetEnvironmentVar ( "EY_NET_CONNECTION_TYPE", "2", False )
connectionType = 2
Print ">> Vous êtes connecté en RAS..."
Else
Call session.SetEnvironmentVar ( "EY_NET_CONNECTION_TYPE", "1", False )
connectionType = 1
Print ">> Vous êtes connecté en LAN..."
End If
'
Else ' we are disconnected from the network
Call session.SetEnvironmentVar ( "EY_NET_CONNECTION_TYPE", "0", False )
connectionType = 0
Print ">> Vous êtes déconnecté du réseau..."
End If ' ( tempDb.IsOpen )
'
End Sub