Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > Sécurité
Sécurité Le forum qui s'occupe de votre préoccupation de sécuriser l'accès à votre application Access, ainsi qu'à la sécurité des données.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 14/09/2006, 19h40   #1
Membre éclairé
 
Avatar de @rkane
 
Homme Patrick
developpeur amateur dans mon cadre professionnel
Inscription : juin 2006
Messages : 499
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Âge : 52
Localisation : France, Val de Marne (Île de France)

Informations professionnelles :
Activité : developpeur amateur dans mon cadre professionnel
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : juin 2006
Messages : 499
Points : 360
Points : 360
Par défaut journal des tentatives d'acces frauduleuses

j'ai un form de connection à ma base avec le code suivant :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
Option Compare Database
Private Const giMaxLogin As Byte = 3 'nombre maxi autorisé de tentative de connexion
 
Private Sub BoutonUtilisateur_Click()
Me.Password = LCase$(Nz(Password))
On Error GoTo errortag
 Dim oDb As DAO.Database
  Dim rst As DAO.Recordset
   Dim sSql As String
    Dim bBadLogin As Boolean, bClose As Boolean
     Static i As Byte
 
   i = i + 1 'incrémente les tentatives
 
   If IsNull(Me.Login) Or IsNull(Me.Password) Then
      bBadLogin = True
   Else
      Set oDb = CurrentDb
      ' Cherche l'utilisateur dans la table, en sachant que login ne peut contenir le caractère <'> ni <">
 sSql = "SELECT * FROM Personnel WHERE  Utilisateur = true AND Nom = '" & Me.Login & "'"
      Set rst = oDb.OpenRecordset(sSql, dbOpenSnapshot)
      If Not rst.EOF Then
      ' Vérifier que le mot de passe est égal au mot de passe saisie crypté
      If rst("password") = Me.Password Then 'Mot de passe ok
            i = 0
            bBadLogin = False
         Else 'Mot de passe incorrect
            bBadLogin = True
         End If
      Else ' pas de login trouvé
         bBadLogin = True
      End If
   End If
   If bBadLogin = True Then 'si tentative mauvaise
      If i < giMaxLogin Then 'si nb tentative < au maxi
         MsgBox "NOM D'UTILISATEUR OU MOT DE PASSE ERRONE" & vbCrLf & "IL VOUS RESTE " & (giMaxLogin - i) & " TENTATIVE(S) DE CONNECTION"
      Else 'si nb tentative >= maxi => on ferme
         MsgBox "VOUS AVEZ DEPASSE LE NOMBRE DE TENTATIVES AUTORISEES !"
         DoCmd.Quit
         'bClose = True
      End If
   End If
fin:
   Set rst = Nothing
   Set oDb = Nothing
   If bBadLogin = False Then
      DoCmd.OpenForm "MenuPrincipal"
    DoCmd.close acForm, Me.Name
   ElseIf bClose = True Then
      DoCmd.close acForm, Me.Name
   End If
   Exit Sub
errortag:
End Sub
Private Sub Form_Unload(Cancel As Integer)
Me.Log.Value = Me.Login.Value
Me.Pass.Value = Password.Value
Me.Heure.Value = Time()
End Sub
Si quelqu'un essaie d'acceder frauduleusement je souhaite enregistrer ces tentatives dans une table (je verrai plus tard pour recuperer le nom du poste "attaquant" dans un champ).
ça fonctionne sur l'evenement OnUnload du form de connection? les données entrees dans les champs sont bien récupérées.
Mais comment pourrais-je subordonner ces enregistrements à une non connection à la base, c'est à dire la non ouverture du form "MenuPrincipal" ? là je ne sais pas par quel bout attraper ce probleme.
Si quelqu'un à une idée à soumettre... avec plaisir !
Patrick
__________________

@rkane est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/09/2006, 08h57   #2
Rédacteur/Modérateur
 
Avatar de Domi2
 
Homme
Inscription : juin 2006
Messages : 6 227
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 52
Localisation : Suisse

Informations professionnelles :
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : juin 2006
Messages : 6 227
Points : 9 924
Points : 9 924
Envoyer un message via Skype™ à Domi2
Bonjour,

Une idée comme ça, faire appel à une fonction LogJournal (pas testée).

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Option Compare Database
Private Const giMaxLogin As Byte = 3 'nombre maxi autorisé de tentative de connexion
 
Private Sub BoutonUtilisateur_Click()
Me.Password = LCase$(Nz(Password))
On Error GoTo errortag
 Dim oDb As DAO.Database
  Dim rst As DAO.Recordset
   Dim sSql As String
    Dim bBadLogin As Boolean, bClose As Boolean
     Static i As Byte
 
   i = i + 1 'incrémente les tentatives
 
   If IsNull(Me.Login) Or IsNull(Me.Password) Then
      bBadLogin = True
   Else
      Set oDb = CurrentDb
      ' Cherche l'utilisateur dans la table, en sachant que login ne peut contenir le caractère <'> ni <">
 sSql = "SELECT * FROM Personnel WHERE  Utilisateur = true AND Nom = '" & Me.Login & "'"
      Set rst = oDb.OpenRecordset(sSql, dbOpenSnapshot)
      If Not rst.EOF Then
      ' Vérifier que le mot de passe est égal au mot de passe saisie crypté
      If rst("password") = Me.Password Then 'Mot de passe ok
            i = 0
            bBadLogin = False
            Call LogJournal("Connexion ok")
         Else 'Mot de passe incorrect
            bBadLogin = True
            Call LogJournal("Mot de passe incorrect")
         End If
      Else ' pas de login trouvé
         bBadLogin = True
         Call LogJournal("Login inconnu")
      End If
   End If
   If bBadLogin = True Then 'si tentative mauvaise
      If i < giMaxLogin Then 'si nb tentative < au maxi
         MsgBox "NOM D'UTILISATEUR OU MOT DE PASSE ERRONE" & vbCrLf & "IL VOUS RESTE " & (giMaxLogin - i) & " TENTATIVE(S) DE CONNECTION"
      Else 'si nb tentative >= maxi => on ferme
         MsgBox "VOUS AVEZ DEPASSE LE NOMBRE DE TENTATIVES AUTORISEES !"
         DoCmd.Quit
         'bClose = True
      End If
   End If
fin:
   Set rst = Nothing
   Set oDb = Nothing
   If bBadLogin = False Then
      DoCmd.OpenForm "MenuPrincipal"
    DoCmd.close acForm, Me.Name
   ElseIf bClose = True Then
      DoCmd.close acForm, Me.Name
   End If
   Exit Sub
errortag:
End Sub
Private Sub Form_Unload(Cancel As Integer)
Me.Log.Value = Me.Login.Value
Me.Pass.Value = Password.Value
Me.Heure.Value = Time()
End Sub
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Public Sub LogJournal(LogMsg As String)
 
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblLog", dbOpenDynaset)
 
With rst
 
.AddNew 
.Fields("DateConnexion").Value = Now
.Fields("Utilisateur").Value = CurrentUser()
.Fields("LogType").Value = LogMsg 
.Update 
.Close
 
End With
 
Set dbs = Nothing 
Set rst = Nothing
En espérant avoir pu t'aider.

Bonne journée.

Domi2
Domi2 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/09/2006, 10h37   #3
Membre éclairé
 
Avatar de @rkane
 
Homme Patrick
developpeur amateur dans mon cadre professionnel
Inscription : juin 2006
Messages : 499
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Âge : 52
Localisation : France, Val de Marne (Île de France)

Informations professionnelles :
Activité : developpeur amateur dans mon cadre professionnel
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : juin 2006
Messages : 499
Points : 360
Points : 360
bonjour Domi,
merci tout d'abord pour ton coup d'oeil.
le code "Public Sub LogJournal" je le colle aussi dans mon form de connection ?
Patrick
__________________

@rkane est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/09/2006, 10h51   #4
Rédacteur/Modérateur
 
Avatar de Domi2
 
Homme
Inscription : juin 2006
Messages : 6 227
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 52
Localisation : Suisse

Informations professionnelles :
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : juin 2006
Messages : 6 227
Points : 9 924
Points : 9 924
Envoyer un message via Skype™ à Domi2
Bonjour,

C'est un peu égal, je pense...

Colle-le comme fonction dans le code du formulaire, ça devrait le faire...

Domi2
Domi2 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 06h05.


 
 
 
 
Partenaires

Hébergement Web