请问如何通过代码来修改AD帐户信息???

解决方案 »

  1.   

    using System.Diagnostics;public void CreateLocalUser(string username, string password, string homedir)
      {
      if (!Directory.Exists(homedir))
        Directory.CreateDirectory(homedir);
      
      Process MyProc = new Process();
      MyProc.StartInfo.WorkingDirectory = "C:\WINNT\SYSTEM32";
      MyProc.StartInfo.FileName = "net.exe";
      MyProc.StartInfo.UseShellExecute = false;
      MyProc.StartInfo.RedirectStandardError = true;
      MyProc.StartInfo.RedirectStandardInput = true;
      MyProc.StartInfo.RedirectStandardOutput = true;
      MyProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
      
      MyProc.StartInfo.Arguments = @" user " + username + @" " + password + @" /ADD /ACTIVE:YES " +
        @"/EXPIRES:NEVER /FULLNAME:" + username + @" /HOMEDIR:""" + 
        homedir + @""" /PASSWORDCHG:NO /PASSWORDREQ:YES";
      
      MyProc.Start();
      MyProc.WaitForExit();
      MyProc.Close();
      }
      

  2.   

    我想通过代码修改active directory上的帐户信息
      

  3.   

    请查看LDAP,ADSI,WMI的相关资料 
    实际上你可以去微软脚本中心http://www.microsoft.com/china/technet/community/scriptcenter/user/default.mspx 
    去看看 
    虽然都是wsh脚本,不过所用到的技术和对象都是一样的。 
    看明白了,转成net代码也不是很困难的事情呵呵,了解解决方案的本质,比了解代码更重要