Bonjour à tous,
voilà mon but est de pinger les machines présentent dans mon active directory. Pour ce faire j'ai repris le code du tuto suivant :
http://webman.developpez.com/article...u/vb/net/#L2.1

Quand je l'execute le compilateur me renvoit le message d'erreur suivant pour la ligne 61 :
Compiler Error Message: BC30002: Type 'Ping' is not defined.

Source Error:



Line 59: ' AdresseIP : chaîne de caractère contenant l'adresse IP de l'hôte à "pinger"
Line 60: ' Instanciation d'un objet Ping
Line 61: Dim monPing As New Ping
Line 62: ' Objet PingReply qui nous permettra de récupérer le résultat
Line 63: Dim maReponsePing As PingReply

Pourtant l'objet Ping est déclaré vu que j'ai fait un import de System.Net.NetworkInformation.
A moins que je me trompe? Si quelqu'un peut m'en dire plus
Bien à vous.
voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
<%@ Page Language="VB" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Web.Mail" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.DirectoryServices" %>
<%@ import Namespace="System.Configuration" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Net.DNS" %>
<%@ import Namespace="System.ComponentModel" %>
<%@ import Namespace="System.Management" %>
<%@ import Namespace="System.Runtime.InteropServices" %>
<%@ import Namespace="System" %>
<%@ import Namespace="ActiveDs" %>
<%@ import Namespace="System.Net.NetworkInformation%>
<script runat="server">
 
    ' Test ping
    '
 
    Sub Button1_Click(sender As Object, e As EventArgs)
 
    End Sub
 
    Sub Page_Load()
 
 
            Dim Ldap As DirectoryEntry = New DirectoryEntry("LDAP://tamac.local", "faratbi", "faratbi")
            Dim searcher As DirectorySearcher = New DirectorySearcher(Ldap)
            searcher.Filter = "(objectClass=computer)"
            Dim DirEntry As DirectoryEntry
            Dim Ip As String
            Dim ping As String
            For Each result As SearchResult In searcher.FindAll
            DirEntry = result.GetDirectoryEntry
 
             Dim IPHost As IPHostEntry = Dns.Resolve(DirEntry.Properties("Name").value)
             Dim addressList As IPAddress() = IPHost.AddressList
             Dim b As IPAddress = addressList(0) ' récupère la première adresse
             Ip = b.ToString()
             ping  = getPingTime(Ip)
 
             response.write(ping)
 
              Next
 
 
             'largeInteger = DirEntry.Properties("lastLogOn").Value
             'lastLoggedOnDate = ConvertLargeIntToDate(largeInteger)
             'Response.Write(lastLoggedOnDate)
 
            End Sub
 
 
            ' Obtient le délai du Ping en millisecondes
    Private Function getPingTime(ByVal Ip As String) As String
        ' AdresseIP : chaîne de caractère contenant l'adresse IP de l'hôte à "pinger"
        ' Instanciation d'un objet Ping
        Dim monPing As New Ping
        ' Objet PingReply qui nous permettra de récupérer le résultat
        Dim maReponsePing As PingReply
        Dim resultatPing As String = Nothing
        Try
            ' Récupération du résultat obtenu par la méthode Send()
            maReponsePing = monPing.Send(adresseIP, Nothing)
            ' Formatage du résultat avec récupération du temps en millisecondes
            ' grâce à la propriété RoundtripTime.
            resultatPing = "Réponse de " & adresseIP & " en " & maReponsePing._
			               RoundtripTime.ToString & " ms."
            Return resultatPing
        Catch ex As PingException
            ' Formatage de l'exception affichée
            resultatPing = "Impossible de joindre l'hôte : " & ex.Message
            Return resultatPing
        End Try
    End Function
 
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
        </p>
        <p>
        </p>
        <p>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
            <!-- Insert content here -->
        </p>
    </form>
</body>
</html>