用C#修改Windows 2000用户密码 using System; using System.DirectoryServices; public class MyChangePasswordExample { public static void Main(string[] args) { DirectoryEntry myDirectoryEntry; myDirectoryEntry = new DirectoryEntry (@"WinNT://yourdirectoryserver/TheUsername,User"); myDirectoryEntry.Invoke("setPassword","NewPassword"); myDirectoryEntry.CommitChanges();} }
using System;
using System.DirectoryServices;
public class MyChangePasswordExample
{
public static void Main(string[] args)
{
DirectoryEntry myDirectoryEntry; myDirectoryEntry = new DirectoryEntry (@"WinNT://yourdirectoryserver/TheUsername,User"); myDirectoryEntry.Invoke("setPassword","NewPassword"); myDirectoryEntry.CommitChanges();}
}
C#修改xp 密码
http://www.diybl.com/course/4_webprogram/asp.net/asp_netshl/2008513/115914.html
http://topic.csdn.net/t/20061121/14/5173964.html
{
if (textBox1.Text != textBox2.Text)
{
MessageBox.Show("两次输入的密码不一样!");
return;
}
String str = "WinNT://";
str += System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace(@"\",@"/");
str += ",User";
// MessageBox.Show(str); try
{
DirectoryEntry myDirectoryEntry;
myDirectoryEntry = new DirectoryEntry(str); myDirectoryEntry.Invoke("setPassword", textBox1.Text);
myDirectoryEntry.CommitChanges();
if (textBox1.Text != "")
{
MessageBox.Show("当前用户的密码已经设置为:" + textBox1.Text +"" + "请牢记!");
}
else
{
MessageBox.Show("您设置了空密码!");
}
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString());
}
finally
{
} }
绝对管用!!