日期:2011-07-19  浏览次数:20429 次

private string  AddWindowsUser(string   strDoamin,   string   strLogin,   string   strPwd)  
  {  
   DirectoryEntry   obDirEntry   =   null;  
   try  
   {  
    obDirEntry   =   new   DirectoryEntry("WinNT://"   +   strDoamin);  
    DirectoryEntries   entries   =   obDirEntry.Children;  
    DirectoryEntry   obUser   =   entries.Add(strLogin,   "User");  
    obUser.Properties["FullName"].Add("Amigo");  
    object   obRet   =   obUser.Invoke("SetPassword",   strPwd);  
    obUser.CommitChanges(); 
    return "";
   }  
   catch   (Exception   ex)  
   {  
    //MessageBox.Show(ex.Message);  
    return ex.Message;  
   }  
  }