Bonjour à tous,
voilà j'ai un petit problème, j'execute un bout de code qui me permet d'avoir des infos sur les machines de mon réseau. Pour récolter les infos des machines distantes, tout ce passe bien, mais lorsque je veux avoir les infos de ma machine j'obtient ce type d'erreur : User credentials cannot be used for local connections. Or j'utilise un login et un mot de passe administrateur unique pour toute les machines de mon réseau. Quand je met en commentaire le login et le mot de passe, tout ce passe sans problème je sais obtenir les infos de ma machine, mais orsque je le remet, j'ai de nouveau l'erreur qui revient alors que ce login et mot de passe a les droits administrateur sur toutes les machines de mon réseau.
Quelqu'un aurrait-il une idée ?

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
 
<%@ 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.Management.ConnectionOptions" %>
<%@ import Namespace="System.Diagnostics.Process" %>
<script runat="server">
 
    ' Insert page code here
    '
 
 
    Sub Button1_Click(sender As Object, e As EventArgs)
    Dim co As ConnectionOptions = New ConnectionOptions()
 
    With co
        .Impersonation = System.Management.ImpersonationLevel.Impersonate
        '* Use next line for XP
        .Authentication = System.Management.AuthenticationLevel.Packet
        '* Use next line for Win prior XP
        '.Authentication = System.Management.AuthenticationLevel.Connect
    End With
 
    co.Username = "toto"
    co.Password = "toto"
    Dim theScope As New ManagementScope("\\192.168.1.120\root\cimv2",co)
    Dim theQuery As New System.Management.ObjectQuery("SELECT * From Win32_OperatingSystem")
    Dim theSearcher As New ManagementObjectSearcher(theScope, theQuery)
    Dim theCollectionOfResults As ManagementObjectCollection = theSearcher.Get()
 
    For Each currentResult As ManagementObject In theCollectionOfResults
         response.write("Drive:"& currentResult("LastBootUpTime").ToString())
         Response.Write("<br>")
         Response.Write("<br>")
    Next
 
 
 
    End Sub
 
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <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;
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
        </p>
        <!-- Insert content here -->
    </form>
</body>
</html>