2014-02-13 27 views
0

下面的代码应该尝试连接到我的列表中的一个服务器。我的问题是将尝试所有这些组合锁定帐户?ManagementScope的使用

UID = some1 PWD = 1thing

private void connect_all() 
    { 
     // Test 
     string connstr; 
     string[] idt = {"-reu","-ram","-rar"}; 

     uid = textBox1.Text; 
     pwd = textBox2.Text; 
     ConnectionOptions options = new ConnectionOptions(); 
     options.Password = pwd; 

     for (int i = 0; i < servers.Count; i++) 
     { 
      connstr = "\\\\" + servers[i].server + "\\root\\cimv2"; 
      for (int y = 0; y < idt.Length; y++) 
      { 
       options.Username = "-adm-" + uid + idt[y]; 
       try 
       { 
        ManagementScope scope = new ManagementScope(connstr, options); 
        scope.Connect(); 
        MessageBox.Show("Connect"); 
       } 
       catch (Exception Ex) 
       { 
        MessageBox.Show(Ex.Message); 
       } 
      } 
     } 

    } 

回答

0

有,带MangementScope连接将锁定一个帐户。