您的位置:首页 > 编程语言 > C#

C#修改window本地帐号密码

2010-07-16 14:27 513 查看
//**后台CS代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.DirectoryServices;

namespace TestAlertWindowUserPassword
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
DirectoryEntry AD = new DirectoryEntry("WinNT://192.168.1.123", "administrator", "ABCabc123");
DirectoryEntry de = AD.Children.Find("ritacc", "user");
try
{
de.Invoke("setPassword", new object[] { "BCabcA123" });
de.CommitChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
de.Close();
de.Dispose();
AD.Close();
AD.Dispose();

}

// AD.Children.
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: