Bonjour à tous,
et oui encore moi , voila mon problème, j'essaie depuis plusieurs heures déjà d'afficher la place restante sur le disque C:\ des différentes machines présentes dans mon active directory.

Les premières informations,telles que le nom des machines, la version de l'os etc..., s'affiche sans problème, mais pour ce qui est de la récupération de l'espace restant sur le disque C:\ des différentes machines qui se trouvent dans l'AD, là je bloque complètement. j'ai l'impression qu'il m'affiche uniquement l'espace restant de mon disque C:\ en local, et non de toutes les machines présentent dans l'AD. D'après certaines sources, il faut utiliser WMI, mais je ne suis pas très convaincu et de plus je n'ai jamais utilisé WMI, je sais pas trop comment ça marche.
Si quelqu'un pouvait jeter un coup d'oeil à mon code et m'aider à débloquer la situation, cela sera super gentil de votre part car ça fait plusieurs heures que je suis dessus.
Bien à vous.
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
 
<%@ 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" %>
<script runat="server">
 
    ' Insert page code here
    '
    'Displays all computer names in an Active Directory
    'Written 08/26/02 - John O'Donnell
    '
    'sub Page_load()
    Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
 
        Try
 
            'response.write("Button1_Click")
 
            'lblError.Text = "abc" + 12
            ' Définition des objets
            'Dim UserDE as new
            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 IPHost As IPHostEntry = Dns.Resolve(Dns.GetHostName())
            'Dim addressList As IPAddress() = IPHost.AddressList
            'mémoire physique totale disponible
            'Dim MemoirePhysiqueTotale as UInteger = My.Computer.Info.TotalPhysicalMemory
            'Dim a As IPAddress In addressList
            'Dim dns As Dns
            ' Nom de la machine
            'Dim NomMachine As String = Dns.GetHostName
 
            ' Récupération de la liste des IP de la machine
            'Dim InfoIps As IPHostEntry = Dns.GetHostEntry(NomMachine)
            'Dim MesIp As IPAddress() = InfoIps.AddressList
            Dim largeInteger As Object
            Dim lastLoggedOnDate As Date
 
 
            For Each result As SearchResult In searcher.FindAll
                'Dim IPHost As IPHostEntry = Dns.Resolve(DirEntry.Properties("Name"))
 
                'Dim IPHost As IPHostEntry = Dns.Resolve(Dns.GetHostName())
                ' On récupère l'entrée trouvée lors de la recherche
                DirEntry = result.GetDirectoryEntry
                'Response.Write(DirEntry.)
                'On peut maintenant afficher les informations désirées
                'response.write("Login : " + DirEntry.Properties("SAMAccountName").Value)
                'Nom des machines
                Response.Write("Nom : " + DirEntry.Properties("Name").value)
                'IP
 
                'Dim IPHost As IPHostEntry = DirEntry.Properties("Name")
                Dim IPHost As IPHostEntry = Dns.Resolve(DirEntry.Properties("Name").value)
                Dim addressList As IPAddress() = IPHost.AddressList
                Dim a As IPAddress = addressList(0) ' récupère la première adresse
                Response.Write("IP : " + a.ToString())
                response.write("<br>:")
                Response.write("Os_version : " + DirEntry.Properties("operatingSystemVersion").value)
                response.write("<br>:")
                Response.write("Os : " + DirEntry.Properties("operatingSystem").value)
                response.write("<br>:")
                Response.write("ServicePack :" + DirEntry.Properties("operatingSystemServicePack").value)
                response.write("<br>:")
                'Response.write("groupMembershipSAM :" +DirEntry.Properties("groupMembershipSAM").value)
                'Response.write("localeID :" +DirEntry.Properties("localeID").value)
 
                'Response.write("machineRole :" + DirEntry.Properties("machineRole").value)
 
                'Dim UserDE as userde
                largeInteger = DirEntry.Properties("lastLogOn").Value
                lastLoggedOnDate = ConvertLargeIntToDate(largeInteger)
 
                Response.Write(lastLoggedOnDate)
                Response.Write("<br>")
 
                'c'est ici que j'essaie d'obtenir la place restante sur le disque C:\ des différentes machines 
                'présentent dans l'active directory.
 
                Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
                Dim d As DriveInfo
                For Each d In allDrives
            response.write("Drive  :"& d.Name)
            response.write("<br>:")
            response.write("<br>:")
            'response.write("  File type: "& d.DriveType)
            If d.IsReady = True Then
               ' response.write("  Volume label: "& d.VolumeLabel)
                'response.write("  File system: "& d.DriveFormat)
                response.write("<br>:")
                response.write("<br>:")
                response.write( "  Available space to current user:{0, 15} bytes:"& d.AvailableFreeSpace)
                response.write("<br>:")
                response.write("<br>:")
                End If
                Next
                'response.write("Drive  :"& d.Name)
 
                'Dim highpart,lowpart,lastlogon as long
                'highpart = DirEntry.Properties("LastLogon").Value.Lowpart
                'lowpart = DirEntry.Properties("LastLogon").Value.HighPart
                'lastlogon = (highpart * 2 ^ 32) - lowpart
                'Response.Write("lastLogon:" + DateTime.FromFileTime(lastlogon).ToString())
                'msgbox DateTime.FromFileTime(lastLogon)
 
 
 
                ' DateTime(basis = New DateTime(1601, 1, 1, 0, 0, 0, 0))
 
 
                'double timeStamp = Math.Floor(Double.Parse(DE.Properties["lastLogonTimestamp"].Value)/ 10000.0);
 
 
                ' DateTime(lastLogonDate = basis.AddMilliseconds(timeStamp))
                ' Dim tms As Double
                'tms = Double.Parse(DirEntry.Properties("LastLogonTimeStamp").Value / 10000.0)
 
 
                'Dim base As Date
                'base = New Date(1601, 1, 1, 0, 0, 0, 0)
                'Response.Write(base.AddMilliseconds(tms))
 
                'objLastLogon = DirEntry.Properties("lastLogon")
 
                'intLastLogonTime = objLastLogon.HighPart * (2 ^ 32) + objLastLogon.LowPart
                'intLastLogonTime = intLastLogonTime / (60 * 10000000)
                'intLastLogonTime = intLastLogonTime / 1440
 
 
 
                'response.write(":<br>")
                'Lowpart = UserDE.Properties("LastLogon")(0).Lowpart
                'lastLogon = (HighPart * 2^32) - Lowpart
 
                'Response.write("lastLogon :" +UserDE.Properties(DateTime.FromFileTime(LastLogon)).value)
 
 
                'récupération des infos systèmes (mémoire physique disponible)
                'Dim MemoirePhysiqueDisponible as UInteger = new GetSystemInfo(DirEntry.Properties("Name").value)
                'Response.write("Mémoire_physique_dispo : "+ DirEntry.properties("Name").value)
 
 
 
 
 
            Next
 
 
 
 
 
        Catch Ex As Exception
            'lblError.Text =Ex.tostring
            response.write(Ex.tostring)
 
        End Try
 
 
        'End Sub
 
    End Sub
    ' Sub Button1_Click(sender As Object, e As EventArgs)
    'end sub
    Private Function ConvertLargeIntToDate(ByVal largeInteger As Object) As Date
        Dim typ As Type = largeInteger.GetType()
        Dim highPart As Integer = CInt(typ.InvokeMember("HighPart", Reflection.BindingFlags.GetProperty, Nothing, largeInteger, Nothing))
        Dim lowPart As Integer = CInt(typ.InvokeMember("LowPart", Reflection.BindingFlags.GetProperty, Nothing, largeInteger, Nothing))
        Dim fileTime As Int64 = Convert.ToInt64(highPart * (2 ^ 32))
        Return (DateTime.FromFileTime(fileTime))
    End Function
 
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Lister"></asp:Button>
        <!-- Insert content here -->
    </form>
</body>
</html>